Skip to content

Commit

Permalink
Skip fetching event payloads when streaming events
Browse files Browse the repository at this point in the history
  • Loading branch information
HerbertJordan committed Dec 3, 2024
1 parent d7fc6bf commit d206e10
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
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

0 comments on commit d206e10

Please sign in to comment.