Merge pull request #1315 from filecoin-project/conform-protocol-names-to-spec

conform protocol ids to spec
This commit is contained in:
Whyrusleeping 2020-03-03 16:08:50 -08:00 committed by GitHub
commit 08ce9258d1
5 changed files with 16 additions and 14 deletions

View File

@ -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

View File

@ -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) {

View File

@ -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) {

View File

@ -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 {

View File

@ -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)
}