Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hello: avoid dialing when fetching hello tipset #6361

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions pkg/net/helloprotocol/hello_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,18 +187,23 @@ func (h *HelloProtocolHandler) handleNewStream(s net.Stream) {

fullTipSet, err := h.loadLocalFullTipset(ctx, types.NewTipSetKey(hello.HeaviestTipSetCids...))
if err != nil {
// We're trying to fetch the tipset from the peer that just said hello to us. No point in
// triggering any dials.
ctx := net.WithNoDial(ctx, "fetching filecoin hello tipset")
fullTipSet, err = h.exchange.GetFullTipSet(ctx, []peer.ID{from}, types.NewTipSetKey(hello.HeaviestTipSetCids...)) //nolint
h.host.ConnManager().TagPeer(from, "new-block", 40)
}
if err != nil {
log.Warnf("failed to get tipset message from peer %s", from)
return
if err != nil {
log.Warnf("failed to get tipset message from peer %s", from)
return
}
}

if fullTipSet == nil {
log.Warnf("handleNewStream get null full tipset, it's scarce!")
return
}

h.host.ConnManager().TagPeer(from, "new-block", 40)

// notify the local node of the new `block.ChainInfo`
ci := types.NewChainInfo(from, from, fullTipSet)
h.peerDiscovered(ci)
Expand Down
Loading