From 130470832f99e522c6a25f7b113cd0f290cfc1fc Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Thu, 19 Mar 2026 11:42:51 +0100 Subject: [PATCH] eth/protocols/eth: add comments in LogsSize --- eth/protocols/eth/receipt.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/eth/protocols/eth/receipt.go b/eth/protocols/eth/receipt.go index a2f5fe52de..4452880965 100644 --- a/eth/protocols/eth/receipt.go +++ b/eth/protocols/eth/receipt.go @@ -207,15 +207,22 @@ func (rl *ReceiptList) Append(other *ReceiptList) { rl.items.AppendList(&other.items) } -// LogsSize returns the total size of log data in this receipts. +// LogsSize returns the total size of log data across all receipts of the list. func (rl *ReceiptList) LogsSize() (uint64, error) { var size uint64 it := rl.items.ContentIterator() for it.Next() { + // The encoded receipts are of the form: + // + // [txType, status, cumulativeGasUsed, [logs...]] + // + // We want to count the size of logs. + // So we strip the outer list first: content, _, err := rlp.SplitList(it.Value()) if err != nil { return 0, fmt.Errorf("invalid receipt structure: %v", err) } + // then skip over txType, status, cumulativeGasUsed: rest := content for range 3 { _, _, rest, err = rlp.Split(rest) @@ -223,6 +230,7 @@ func (rl *ReceiptList) LogsSize() (uint64, error) { return 0, fmt.Errorf("invalid receipt structure: %v", err) } } + // and finally access the logs list to get its inner size: logsContent, _, err := rlp.SplitList(rest) if err != nil { return 0, fmt.Errorf("invalid receipt logs: %v", err)