From f01340f2052dec38fa6d27b399fce129ec7536fd Mon Sep 17 00:00:00 2001 From: psogv0308 Date: Wed, 7 Aug 2024 23:53:33 +0900 Subject: [PATCH] eth/downloader, core/types: adding withdrawal size to downloader queue --- core/types/withdrawal.go | 5 +++++ eth/downloader/queue.go | 3 +++ 2 files changed, 8 insertions(+) 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 }