Skip to content

Commit

Permalink
accept EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
darioush committed Jan 29, 2025
1 parent 7855976 commit 0e78643
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions plugin/evm/statesync/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"bytes"
"context"
"encoding/binary"
"errors"
"fmt"
"io"
"time"

"github.com/ava-labs/avalanchego/ids"
Expand All @@ -16,7 +18,6 @@ import (
"github.com/ava-labs/avalanchego/utils/wrappers"
"github.com/ava-labs/coreth/core"
"github.com/ava-labs/coreth/eth/protocols/snap"
"github.com/ava-labs/libevm/log"
ethp2p "github.com/ava-labs/libevm/p2p"
"github.com/ava-labs/libevm/p2p/enode"
)
Expand Down Expand Up @@ -115,6 +116,8 @@ func toBytes(msg ethp2p.Msg) ([]byte, error) {
bytes := make([]byte, msg.Size+wrappers.LongLen)
binary.BigEndian.PutUint64(bytes, msg.Code)
n, err := msg.Payload.Read(bytes[wrappers.LongLen:])
log.Debug("toBytes", "n", n, "err", err)
if n == int(msg.Size) && errors.Is(err, io.EOF) {
err = nil
}
return bytes, err
}

0 comments on commit 0e78643

Please sign in to comment.