diff --git a/core/types/withdrawal.go b/core/types/withdrawal.go index d1ad918f98..0fea969e67 100644 --- a/core/types/withdrawal.go +++ b/core/types/withdrawal.go @@ -18,6 +18,7 @@ package types import ( "bytes" + "unsafe" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" @@ -42,6 +43,10 @@ type withdrawalMarshaling struct { Amount hexutil.Uint64 } +func (w Withdrawal) Size() common.StorageSize { + return common.StorageSize(unsafe.Sizeof(w)) +} + // Withdrawals implements DerivableList for withdrawals. type Withdrawals []*Withdrawal diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go index 267c23407f..8346d40232 100644 --- a/eth/downloader/queue.go +++ b/eth/downloader/queue.go @@ -385,6 +385,9 @@ func (q *queue) Results(block bool) []*fetchResult { for _, tx := range result.Transactions { size += common.StorageSize(tx.Size()) } + for _, withdrawal := range result.Withdrawals { + size += withdrawal.Size() + } q.resultSize = common.StorageSize(blockCacheSizeWeight)*size + (1-common.StorageSize(blockCacheSizeWeight))*q.resultSize }