diff --git a/sharding/node/backend.go b/sharding/node/backend.go index 5c8a3cc82..d639e9bd4 100644 --- a/sharding/node/backend.go +++ b/sharding/node/backend.go @@ -71,6 +71,15 @@ func New(ctx *cli.Context) (*ShardEthereum, error) { // Adds the initialized SMCClient to the ShardEthereum instance. shardEthereum.smcClient = smcClient + // TODO: Find a better way to do this??? + if err := shardEthereum.registerP2P(); err != nil { + return nil, err + } + + if err := shardEthereum.registerTXPool(); err != nil { + return nil, err + } + if err := shardEthereum.registerActorService(actorFlag); err != nil { return nil, err } @@ -140,6 +149,20 @@ func (s *ShardEthereum) Register(constructor sharding.ServiceConstructor) error return nil } +func (s *ShardEthereum) registerP2P() error { + return s.Register(func(ctx *sharding.ServiceContext) (sharding.Service, error) { + return shardp2p.NewServer() + }) +} + +func (s *ShardEthereum) registerTXPool() error { + return s.Register(func(ctx *sharding.ServiceContext) (sharding.Service, error) { + var p2p *shardp2p.Server + ctx.Service(&p2p) + return txpool.NewShardTXPool(p2p) + }) +} + // Registers the actor according to CLI flags. Either notary/proposer/observer. func (s *ShardEthereum) registerActorService(actor string) error { return s.Register(func(ctx *sharding.ServiceContext) (sharding.Service, error) {