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

Skip fetching event payloads when streaming events #372

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion gossip/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package gossip
import (
"errors"
"fmt"
"io"
"log/slog"
"math"
"math/rand/v2"
"strings"
Expand Down Expand Up @@ -553,7 +555,11 @@ func (h *handler) handle(p *peer) error {
// Handle incoming messages until the connection is torn down
for {
if err := h.handleMsg(p); err != nil {
p.Log().Debug("Message handling failed", "err", err, "peer", p.ID(), "name", p.Name())
level := slog.LevelWarn
if errors.Is(err, io.EOF) {
level = slog.LevelDebug
}
p.Log().Log(level, "Message handling failed", "err", err, "peer", p.ID(), "name", p.Name())
return err
}
}
Expand Down
7 changes: 4 additions & 3 deletions gossip/protocols/dag/dagstream/dagstreamleecher/leecher.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,11 @@ func (d *Leecher) startSession(candidates []string) {
}
}

// We only fetch IDs since fetching IDs and events leads to message decoding
// issues causing the peer connection the request was send to to be closed.
// By requesting IDs only, this issue is avoided. The payloads of events are
// then requested independently using the non-streaming P2P protocol.
typ := dagstream.RequestIDs
if d.callback.PeerEpoch(peer) > d.epoch && d.emptyState && d.session.try == 0 {
typ = dagstream.RequestEvents
}

session := dagstream.Session{
ID: getSessionID(d.epoch, d.session.try),
Expand Down
Loading