From 8685b0a201ff211a0f6c0e568b96111d7d49a201 Mon Sep 17 00:00:00 2001 From: Raul Jordan Date: Mon, 4 Jun 2018 18:02:34 -0400 Subject: [PATCH] sharding: register p2p and txpool in order Former-commit-id: cd4ebad4a45c3f02d9fb14134bdcd3e85187241e [formerly 507ca92b4728a695d67dd416c71b77f0fa4d33e3] Former-commit-id: c1350c2143ebdfb4e17f19f7ffb77351a854db91 --- sharding/node/backend.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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) {