Merge pull request #8820 from filecoin-project/asr/deprecate-blocksync

refactor: remove old BlockSyncProtocolID
This commit is contained in:
Łukasz Magiera 2022-06-13 18:36:21 +02:00 committed by GitHub
commit 1cd94f598d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
}