From ca0c5b9d721875361a70ee4ae01c4774e2e8e995 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sat, 28 Feb 2026 00:50:01 +0100 Subject: [PATCH] eth/protocols/eth: move EncodeForStorage below constructor conventionally, the constructor definition should be as close as possible to the type definition --- eth/protocols/eth/receipt.go | 44 ++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/eth/protocols/eth/receipt.go b/eth/protocols/eth/receipt.go index 263fc7db67..e51c02fa2a 100644 --- a/eth/protocols/eth/receipt.go +++ b/eth/protocols/eth/receipt.go @@ -140,6 +140,28 @@ type ReceiptList struct { items rlp.RawList[Receipt] } +// NewReceiptList creates a receipt list. +// This is slow, and exists for testing purposes. +func NewReceiptList(trs []*types.Receipt) *ReceiptList { + rl := new(ReceiptList) + for _, tr := range trs { + r := newReceipt(tr) + encoded, _ := rlp.EncodeToBytes(&r) + rl.items.AppendRaw(encoded) + } + return rl +} + +// DecodeRLP decodes a list receipts from the network format. +func (rl *ReceiptList) DecodeRLP(s *rlp.Stream) error { + return rl.items.DecodeRLP(s) +} + +// EncodeRLP encodes the list into the network format of eth/69. +func (rl *ReceiptList) EncodeRLP(w io.Writer) error { + return rl.items.EncodeRLP(w) +} + // EncodeForStorage encodes a list of receipts for the database. // It only strips the first element (TxType) from each receipt's // raw RLP without the actual decoding and re-encoding. @@ -169,28 +191,6 @@ func (rl *ReceiptList) EncodeForStorage() (rlp.RawValue, error) { return out.Bytes(), nil } -// NewReceiptList creates a receipt list. -// This is slow, and exists for testing purposes. -func NewReceiptList(trs []*types.Receipt) *ReceiptList { - rl := new(ReceiptList) - for _, tr := range trs { - r := newReceipt(tr) - encoded, _ := rlp.EncodeToBytes(&r) - rl.items.AppendRaw(encoded) - } - return rl -} - -// DecodeRLP decodes a list receipts from the network format. -func (rl *ReceiptList) DecodeRLP(s *rlp.Stream) error { - return rl.items.DecodeRLP(s) -} - -// EncodeRLP encodes the list into the network format of eth/69. -func (rl *ReceiptList) EncodeRLP(w io.Writer) error { - return rl.items.EncodeRLP(w) -} - // Derivable returns a DerivableList, which can be used to decode func (rl *ReceiptList) Derivable() types.DerivableList { var bloomBuf [6]byte