diff --git a/build/params_shared.go b/build/params_shared.go index b202c5925..a4c986e1b 100644 --- a/build/params_shared.go +++ b/build/params_shared.go @@ -8,6 +8,11 @@ import ( // Core network constants +const NetworkName = "interop" +const BlocksTopic = "/fil/blocks/" + NetworkName +const MessagesTopic = "/fil/msgs/" + NetworkName +const DhtProtocolName = "/fil/kad/" + NetworkName + // ///// // Storage diff --git a/chain/messagepool/messagepool.go b/chain/messagepool/messagepool.go index 7cd1aaa26..f63dfa2cb 100644 --- a/chain/messagepool/messagepool.go +++ b/chain/messagepool/messagepool.go @@ -45,8 +45,6 @@ var ( ) const ( - msgTopic = "/fil/messages" - localMsgsDs = "/mpool/local" localUpdates = "update" @@ -237,7 +235,7 @@ func (mp *MessagePool) repubLocal() { continue } - err = mp.api.PubSubPublish(msgTopic, msgb) + err = mp.api.PubSubPublish(build.MessagesTopic, msgb) if err != nil { errout = multierr.Append(errout, xerrors.Errorf("could not publish: %w", err)) continue @@ -282,7 +280,7 @@ func (mp *MessagePool) Push(m *types.SignedMessage) (cid.Cid, error) { } mp.lk.Unlock() - return m.Cid(), mp.api.PubSubPublish(msgTopic, msgb) + return m.Cid(), mp.api.PubSubPublish(build.MessagesTopic, msgb) } func (mp *MessagePool) Add(m *types.SignedMessage) error { @@ -480,7 +478,7 @@ func (mp *MessagePool) PushWithNonce(addr address.Address, cb func(uint64) (*typ log.Errorf("addLocal failed: %+v", err) } - return msg, mp.api.PubSubPublish(msgTopic, msgb) + return msg, mp.api.PubSubPublish(build.MessagesTopic, msgb) } func (mp *MessagePool) Remove(from address.Address, nonce uint64) { diff --git a/node/impl/full/sync.go b/node/impl/full/sync.go index 4a769502b..48ae34d84 100644 --- a/node/impl/full/sync.go +++ b/node/impl/full/sync.go @@ -4,6 +4,7 @@ import ( "context" "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain" "github.com/filecoin-project/lotus/chain/types" cid "github.com/ipfs/go-cid" @@ -76,7 +77,7 @@ func (a *SyncAPI) SyncSubmitBlock(ctx context.Context, blk *types.BlockMsg) erro } // TODO: anything else to do here? - return a.PubSub.Publish("/fil/blocks", b) + return a.PubSub.Publish(build.MessagesTopic, b) } func (a *SyncAPI) SyncIncomingBlocks(ctx context.Context) (<-chan *types.BlockHeader, error) { diff --git a/node/modules/lp2p/host.go b/node/modules/lp2p/host.go index af02fdba1..be2379bb9 100644 --- a/node/modules/lp2p/host.go +++ b/node/modules/lp2p/host.go @@ -80,7 +80,7 @@ func DHTRouting(client bool) interface{} { dhtopts.Client(client), dhtopts.Datastore(dstore), dhtopts.Validator(validator), - dhtopts.Protocols("/lotus/kad/1.0.0"), + dhtopts.Protocols(build.DhtProtocolName), ) if err != nil { diff --git a/node/modules/services.go b/node/modules/services.go index d87058b5d..cac24391b 100644 --- a/node/modules/services.go +++ b/node/modules/services.go @@ -12,6 +12,7 @@ import ( "github.com/filecoin-project/go-fil-markets/retrievalmarket" "github.com/filecoin-project/go-fil-markets/retrievalmarket/discovery" "github.com/filecoin-project/go-fil-markets/storagemarket" + "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain" "github.com/filecoin-project/lotus/chain/blocksync" "github.com/filecoin-project/lotus/chain/messagepool" @@ -23,9 +24,6 @@ import ( "github.com/filecoin-project/lotus/node/modules/helpers" ) -const BlocksTopic = "/fil/blocks" -const MessagesTopic = "/fil/messages" - func RunHello(mctx helpers.MetricsCtx, lc fx.Lifecycle, h host.Host, svc *hello.Service) { h.SetStreamHandler(hello.ProtocolID, svc.HandleStream) @@ -53,7 +51,7 @@ func RunBlockSync(h host.Host, svc *blocksync.BlockSyncService) { func HandleIncomingBlocks(mctx helpers.MetricsCtx, lc fx.Lifecycle, ps *pubsub.PubSub, s *chain.Syncer, h host.Host) { ctx := helpers.LifecycleCtx(mctx, lc) - blocksub, err := ps.Subscribe(BlocksTopic) + blocksub, err := ps.Subscribe(build.BlocksTopic) if err != nil { panic(err) } @@ -63,7 +61,7 @@ func HandleIncomingBlocks(mctx helpers.MetricsCtx, lc fx.Lifecycle, ps *pubsub.P h.ConnManager().TagPeer(p, "badblock", -1000) }) - if err := ps.RegisterTopicValidator(BlocksTopic, v.Validate); err != nil { + if err := ps.RegisterTopicValidator(build.BlocksTopic, v.Validate); err != nil { panic(err) } @@ -73,7 +71,7 @@ func HandleIncomingBlocks(mctx helpers.MetricsCtx, lc fx.Lifecycle, ps *pubsub.P func HandleIncomingMessages(mctx helpers.MetricsCtx, lc fx.Lifecycle, ps *pubsub.PubSub, mpool *messagepool.MessagePool) { ctx := helpers.LifecycleCtx(mctx, lc) - msgsub, err := ps.Subscribe(MessagesTopic) + msgsub, err := ps.Subscribe(build.MessagesTopic) if err != nil { panic(err) } @@ -89,7 +87,7 @@ func HandleIncomingMessages(mctx helpers.MetricsCtx, lc fx.Lifecycle, ps *pubsub return true } - if err := ps.RegisterTopicValidator(MessagesTopic, v); err != nil { + if err := ps.RegisterTopicValidator(build.MessagesTopic, v); err != nil { panic(err) }