eth/downloader, core/types: adding withdrawal size to downloader queue

This commit is contained in:
psogv0308 2024-08-07 23:53:33 +09:00
parent b37ac5c102
commit f01340f205
2 changed files with 8 additions and 0 deletions

View file

@ -18,6 +18,7 @@ package types
import ( import (
"bytes" "bytes"
"unsafe"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
@ -42,6 +43,10 @@ type withdrawalMarshaling struct {
Amount hexutil.Uint64 Amount hexutil.Uint64
} }
func (w Withdrawal) Size() common.StorageSize {
return common.StorageSize(unsafe.Sizeof(w))
}
// Withdrawals implements DerivableList for withdrawals. // Withdrawals implements DerivableList for withdrawals.
type Withdrawals []*Withdrawal type Withdrawals []*Withdrawal

View file

@ -385,6 +385,9 @@ func (q *queue) Results(block bool) []*fetchResult {
for _, tx := range result.Transactions { for _, tx := range result.Transactions {
size += common.StorageSize(tx.Size()) size += common.StorageSize(tx.Size())
} }
for _, withdrawal := range result.Withdrawals {
size += withdrawal.Size()
}
q.resultSize = common.StorageSize(blockCacheSizeWeight)*size + q.resultSize = common.StorageSize(blockCacheSizeWeight)*size +
(1-common.StorageSize(blockCacheSizeWeight))*q.resultSize (1-common.StorageSize(blockCacheSizeWeight))*q.resultSize
} }