refactor: remove old BlockSyncProtocolID
This commit is contained in:
parent
e3f1eb29a1
commit
789f212f6c
@ -397,14 +397,14 @@ func (c *client) sendRequestToPeer(ctx context.Context, peer peer.ID, req *Reque
|
|||||||
}()
|
}()
|
||||||
// -- TRACE --
|
// -- TRACE --
|
||||||
|
|
||||||
supported, err := c.host.Peerstore().SupportsProtocols(peer, BlockSyncProtocolID, ChainExchangeProtocolID)
|
supported, err := c.host.Peerstore().SupportsProtocols(peer, ChainExchangeProtocolID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.RemovePeer(peer)
|
c.RemovePeer(peer)
|
||||||
return nil, xerrors.Errorf("failed to get protocols for peer: %w", err)
|
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",
|
return nil, xerrors.Errorf("peer %s does not support protocols %s",
|
||||||
peer, []string{BlockSyncProtocolID, ChainExchangeProtocolID})
|
peer, []string{ChainExchangeProtocolID})
|
||||||
}
|
}
|
||||||
|
|
||||||
connectionStart := build.Clock.Now()
|
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(
|
stream, err := c.host.NewStream(
|
||||||
network.WithNoDial(ctx, "should already have connection"),
|
network.WithNoDial(ctx, "should already have connection"),
|
||||||
peer,
|
peer,
|
||||||
ChainExchangeProtocolID, BlockSyncProtocolID)
|
ChainExchangeProtocolID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.RemovePeer(peer)
|
c.RemovePeer(peer)
|
||||||
return nil, xerrors.Errorf("failed to open stream to peer: %w", err)
|
return nil, xerrors.Errorf("failed to open stream to peer: %w", err)
|
||||||
|
@ -16,10 +16,6 @@ import (
|
|||||||
var log = logging.Logger("chainxchg")
|
var log = logging.Logger("chainxchg")
|
||||||
|
|
||||||
const (
|
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
|
// ChainExchangeProtocolID is the protocol ID of the chain exchange
|
||||||
// protocol.
|
// protocol.
|
||||||
ChainExchangeProtocolID = "/fil/chain/xchg/0.0.1"
|
ChainExchangeProtocolID = "/fil/chain/xchg/0.0.1"
|
||||||
|
@ -98,7 +98,6 @@ func RunPeerMgr(mctx helpers.MetricsCtx, lc fx.Lifecycle, pmgr *peermgr.PeerMgr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RunChainExchange(h host.Host, svc exchange.Server) {
|
func RunChainExchange(h host.Host, svc exchange.Server) {
|
||||||
h.SetStreamHandler(exchange.BlockSyncProtocolID, svc.HandleStream) // old
|
|
||||||
h.SetStreamHandler(exchange.ChainExchangeProtocolID, svc.HandleStream) // new
|
h.SetStreamHandler(exchange.ChainExchangeProtocolID, svc.HandleStream) // new
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user