Merge pull request #2561 from filecoin-project/feat/better-hello-logging

add some better logging for hello handshake failures
This commit is contained in:
Łukasz Magiera 2020-07-24 02:26:27 +02:00 committed by GitHub
commit a33b5a9526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -5,6 +5,7 @@ import (
"time"
"github.com/filecoin-project/specs-actors/actors/abi"
xerrors "golang.org/x/xerrors"
"github.com/filecoin-project/specs-actors/actors/abi/big"
"github.com/ipfs/go-cid"
@ -125,7 +126,7 @@ func (hs *Service) HandleStream(s inet.Stream) {
func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error {
s, err := hs.h.NewStream(ctx, pid, ProtocolID)
if err != nil {
return err
return xerrors.Errorf("error opening stream: %w", err)
}
hts := hs.cs.GetHeaviestTipSet()
@ -149,7 +150,7 @@ func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error {
t0 := build.Clock.Now()
if err := cborutil.WriteCborRPC(s, hmsg); err != nil {
return err
return xerrors.Errorf("writing rpc to peer: %w", err)
}
go func() {

View File

@ -41,7 +41,9 @@ func RunHello(mctx helpers.MetricsCtx, lc fx.Lifecycle, h host.Host, svc *hello.
pic := evt.(event.EvtPeerIdentificationCompleted)
go func() {
if err := svc.SayHello(helpers.LifecycleCtx(mctx, lc), pic.Peer); err != nil {
log.Warnw("failed to say hello", "error", err, "peer", pic.Peer)
protos, _ := h.Peerstore().GetProtocols(pic.Peer)
agent, _ := h.Peerstore().Get(pic.Peer, "AgentVersion")
log.Warnw("failed to say hello", "error", err, "peer", pic.Peer, "supported", protos, "agent", agent)
return
}
}()