func NewValidatorApp(options config.Options) (*ValidatorApp, error) {
	beaconAddr, err := utils.MultiaddrStringToDialString(options.BeaconRPC)
	if err != nil {
		return nil, err
	}

	shardAddr, err := utils.MultiaddrStringToDialString(options.ShardRPC)
	if err != nil {
		return nil, err
	}

	beaconConn, err := grpc.Dial(beaconAddr, grpc.WithInsecure())
	if err != nil {
		return nil, err
	}

	shardConn, err := grpc.Dial(shardAddr, grpc.WithInsecure())
	if err != nil {
		return nil, err
	}

	networkConfig, found := beaconconfig.NetworkIDs[options.NetworkID]
	if !found {
		return nil, fmt.Errorf("could not find network config %s", options.NetworkID)
	}

	c := config.ValidatorConfig{
		BeaconConn:    beaconConn,
		ShardConn:     shardConn,
		RootKey:       options.RootKey,
		NetworkConfig: &networkConfig,
	}
	c.ParseValidatorIndices(options.Validators)

	ctx, cancel := context.WithCancel(context.Background())
	return &ValidatorApp{
		config: c,
		ctx:    ctx,
		cancel: cancel,
	}, nil
}
// NewValidatorApp creates a new validator app from the config.
NewValidatorApp creates a new validator app from the config.
// NewValidatorApp creates a new validator app from the config .
func NewValidatorApp(options config.Options) (*ValidatorApp, error) {
	beaconAddr, err := utils.MultiaddrStringToDialString(options.BeaconRPC)
	if err != nil {
		return nil, err
	}
	shardAddr, err := utils.MultiaddrStringToDialString(options.ShardRPC)
	if err != nil {
		return nil, err
	}
	beaconConn, err := grpc.Dial(beaconAddr, grpc.WithInsecure())
	if err != nil {
		return nil, err
	}
	shardConn, err := grpc.Dial(shardAddr, grpc.WithInsecure())
	if err != nil {
		return nil, err
	}
	networkConfig, found := beaconconfig.NetworkIDs[options.NetworkID]
	if !found {
		return nil, fmt.Errorf("could not find network config %s", options.NetworkID)
	}
	c := config.ValidatorConfig{
		BeaconConn:    beaconConn,
		ShardConn:     shardConn,
		RootKey:       options.RootKey,
		NetworkConfig: &networkConfig,
	}
	c.ParseValidatorIndices(options.Validators)
	ctx, cancel := context.WithCancel(context.Background())
	return &ValidatorApp{
		config: c,
		ctx:    ctx,
		cancel: cancel,
	}, nil
}
func NewValidatorApp ( options config . Options ) ( * ValidatorApp , error ) { beaconAddr , err := utils . MultiaddrStringToDialString ( options . BeaconRPC ) if err != nil { return nil , err } shardAddr , err := utils . MultiaddrStringToDialString ( options . ShardRPC ) if err != nil { return nil , err } beaconConn , err := grpc . Dial ( beaconAddr , grpc . WithInsecure ( ) ) if err != nil { return nil , err } shardConn , err := grpc . Dial ( shardAddr , grpc . WithInsecure ( ) ) if err != nil { return nil , err } networkConfig , found := beaconconfig . NetworkIDs [ options . NetworkID ] if ! found { return nil , fmt . Errorf ( " " , options . NetworkID ) } c := config . ValidatorConfig { BeaconConn : beaconConn , ShardConn : shardConn , RootKey : options . RootKey , NetworkConfig : & networkConfig , } c . ParseValidatorIndices ( options . Validators ) ctx , cancel := context . WithCancel ( context . Background ( ) ) return & ValidatorApp { config : c , ctx : ctx , cancel : cancel , } , nil }
NewValidatorApp creates a new validator app from the config.
NewValidatorApp creates a new validator app from the config .