func (r *RelayerModule) Run() error {
	shardAddr, err := utils.MultiaddrStringToDialString(r.Options.ShardRPC)
	if err != nil {
		return err
	}

	shards, err := utils.ParseRanges(r.Options.Shards)
	if err != nil {
		return err
	}

	shardConn, err := grpc.Dial(shardAddr, grpc.WithInsecure())
	if err != nil {
		return fmt.Errorf("error dialing shard module: %s", err)
	}

	addr, err := ma.NewMultiaddr(r.Options.P2PListen)
	if err != nil {
		return err
	}

	hn, err := p2p.NewHostNode(context.Background(), p2p.HostNodeOptions{
		ListenAddresses: []ma.Multiaddr{
			addr,
		},
		PrivateKey:         nil,
		ConnManagerOptions: p2p.ConnectionManagerOptions{},
		Timeout:            0,
	})
	if err != nil {
		return err
	}

	shardRPC := pb.NewShardRPCClient(shardConn)

	// TODO: save state to disk
	r.relayers = make([]*shardrelayer.ShardRelayer, len(shards))
	for i, s := range shards {
		stateDB := csmt.NewInMemoryTreeDB()
		genesisBlock := primitives.GetGenesisBlockForShard(uint64(s))
		genesisHash, _ := ssz.HashTreeRoot(genesisBlock)

		m := mempool.NewShardMempool(stateDB, 0, genesisHash, state.ShardInfo{
			CurrentCode: transfer.Code,
			ShardID:     uint32(s),
		})

		relayerP2P, err := shardp2p.NewRelayerSyncManager(hn, m, uint64(s))
		if err != nil {
			return err
		}

		r.relayers[i] = shardrelayer.NewShardRelayer(uint64(s), shardRPC, m, relayerP2P)
	}

	if err := r.createRPCServer(); err != nil {
		return err
	}

	for _, relayer := range r.relayers {
		relayer.ListenForActions()
	}

	<-make(chan struct{})

	return nil
}
// Run runs the relayer module.
Run runs the relayer module.
// Run runs the relayer module .
func (r *RelayerModule) Run() error {
	shardAddr, err := utils.MultiaddrStringToDialString(r.Options.ShardRPC)
	if err != nil {
		return err
	}
	shards, err := utils.ParseRanges(r.Options.Shards)
	if err != nil {
		return err
	}
	shardConn, err := grpc.Dial(shardAddr, grpc.WithInsecure())
	if err != nil {
		return fmt.Errorf("error dialing shard module: %s", err)
	}
	addr, err := ma.NewMultiaddr(r.Options.P2PListen)
	if err != nil {
		return err
	}
	hn, err := p2p.NewHostNode(context.Background(), p2p.HostNodeOptions{
		ListenAddresses: []ma.Multiaddr{
			addr,
		},
		PrivateKey:         nil,
		ConnManagerOptions: p2p.ConnectionManagerOptions{},
		Timeout:            0,
	})
	if err != nil {
		return err
	}
	shardRPC := pb.NewShardRPCClient(shardConn)
	r.relayers = make([]*shardrelayer.ShardRelayer, len(shards))
	for i, s := range shards {
		stateDB := csmt.NewInMemoryTreeDB()
		genesisBlock := primitives.GetGenesisBlockForShard(uint64(s))
		genesisHash, _ := ssz.HashTreeRoot(genesisBlock)
		m := mempool.NewShardMempool(stateDB, 0, genesisHash, state.ShardInfo{
			CurrentCode: transfer.Code,
			ShardID:     uint32(s),
		})
		relayerP2P, err := shardp2p.NewRelayerSyncManager(hn, m, uint64(s))
		if err != nil {
			return err
		}
		r.relayers[i] = shardrelayer.NewShardRelayer(uint64(s), shardRPC, m, relayerP2P)
	}
	if err := r.createRPCServer(); err != nil {
		return err
	}
	for _, relayer := range r.relayers {
		relayer.ListenForActions()
	}
	<-make(chan struct{})
	return nil
}
func ( r * RelayerModule ) Run ( ) error { shardAddr , err := utils . MultiaddrStringToDialString ( r . Options . ShardRPC ) if err != nil { return err } shards , err := utils . ParseRanges ( r . Options . Shards ) if err != nil { return err } shardConn , err := grpc . Dial ( shardAddr , grpc . WithInsecure ( ) ) if err != nil { return fmt . Errorf ( " " , err ) } addr , err := ma . NewMultiaddr ( r . Options . P2PListen ) if err != nil { return err } hn , err := p2p . NewHostNode ( context . Background ( ) , p2p . HostNodeOptions { ListenAddresses : [ ] ma . Multiaddr { addr , } , PrivateKey : nil , ConnManagerOptions : p2p . ConnectionManagerOptions { } , Timeout : 0 , } ) if err != nil { return err } shardRPC := pb . NewShardRPCClient ( shardConn ) r . relayers = make ( [ ] * shardrelayer . ShardRelayer , len ( shards ) ) for i , s := range shards { stateDB := csmt . NewInMemoryTreeDB ( ) genesisBlock := primitives . GetGenesisBlockForShard ( uint64 ( s ) ) genesisHash , _ := ssz . HashTreeRoot ( genesisBlock ) m := mempool . NewShardMempool ( stateDB , 0 , genesisHash , state . ShardInfo { CurrentCode : transfer . Code , ShardID : uint32 ( s ) , } ) relayerP2P , err := shardp2p . NewRelayerSyncManager ( hn , m , uint64 ( s ) ) if err != nil { return err } r . relayers [ i ] = shardrelayer . NewShardRelayer ( uint64 ( s ) , shardRPC , m , relayerP2P ) } if err := r . createRPCServer ( ) ; err != nil { return err } for _ , relayer := range r . relayers { relayer . ListenForActions ( ) } <- make ( chan struct { } ) return nil }
Run runs the relayer module.
Run runs the relayer module .
// TODO: save state to disk