refactor: remove old BlockSyncProtocolID

This commit is contained in:
Aayush 2022-06-07 17:21:21 -04:00
parent e3f1eb29a1
commit 789f212f6c
3 changed files with 4 additions and 9 deletions

View File

@ -397,14 +397,14 @@ func (c *client) sendRequestToPeer(ctx context.Context, peer peer.ID, req *Reque
}()
// -- TRACE --
supported, err := c.host.Peerstore().SupportsProtocols(peer, BlockSyncProtocolID, ChainExchangeProtocolID)
supported, err := c.host.Peerstore().SupportsProtocols(peer, ChainExchangeProtocolID)
if err != nil {
c.RemovePeer(peer)
return nil, xerrors.Errorf("failed to get protocols for peer: %w", err)
}
if len(supported) == 0 || (supported[0] != BlockSyncProtocolID && supported[0] != ChainExchangeProtocolID) {
if len(supported) == 0 || (supported[0] != ChainExchangeProtocolID) {
return nil, xerrors.Errorf("peer %s does not support protocols %s",
peer, []string{BlockSyncProtocolID, ChainExchangeProtocolID})
peer, []string{ChainExchangeProtocolID})
}
connectionStart := build.Clock.Now()
@ -413,7 +413,7 @@ func (c *client) sendRequestToPeer(ctx context.Context, peer peer.ID, req *Reque
stream, err := c.host.NewStream(
network.WithNoDial(ctx, "should already have connection"),
peer,
ChainExchangeProtocolID, BlockSyncProtocolID)
ChainExchangeProtocolID)
if err != nil {
c.RemovePeer(peer)
return nil, xerrors.Errorf("failed to open stream to peer: %w", err)

View File

@ -16,10 +16,6 @@ import (
var log = logging.Logger("chainxchg")
const (
// BlockSyncProtocolID is the protocol ID of the former blocksync protocol.
// Deprecated.
BlockSyncProtocolID = "/fil/sync/blk/0.0.1"
// ChainExchangeProtocolID is the protocol ID of the chain exchange
// protocol.
ChainExchangeProtocolID = "/fil/chain/xchg/0.0.1"

View File

@ -98,7 +98,6 @@ func RunPeerMgr(mctx helpers.MetricsCtx, lc fx.Lifecycle, pmgr *peermgr.PeerMgr)
}
func RunChainExchange(h host.Host, svc exchange.Server) {
h.SetStreamHandler(exchange.BlockSyncProtocolID, svc.HandleStream) // old
h.SetStreamHandler(exchange.ChainExchangeProtocolID, svc.HandleStream) // new
}