apply comments

This commit is contained in:
psogv0308 2024-08-08 16:51:56 +09:00
parent 1638bd3d05
commit 330582e1b3
2 changed files with 7 additions and 9 deletions

View file

@ -43,18 +43,18 @@ type withdrawalMarshaling struct {
Amount hexutil.Uint64 Amount hexutil.Uint64
} }
var withdrawalSize = common.StorageSize(reflect.TypeOf(Withdrawal{}).Size())
func (w Withdrawal) Size() common.StorageSize {
return common.StorageSize(withdrawalSize)
}
// Withdrawals implements DerivableList for withdrawals. // Withdrawals implements DerivableList for withdrawals.
type Withdrawals []*Withdrawal type Withdrawals []*Withdrawal
// Len returns the length of s. // Len returns the length of s.
func (s Withdrawals) Len() int { return len(s) } func (s Withdrawals) Len() int { return len(s) }
var withdrawalSize = int(reflect.TypeOf(Withdrawal{}).Size())
func (s Withdrawals) Size() int {
return withdrawalSize * len(s)
}
// EncodeIndex encodes the i'th withdrawal to w. Note that this does not check for errors // EncodeIndex encodes the i'th withdrawal to w. Note that this does not check for errors
// because we assume that *Withdrawal will only ever contain valid withdrawals that were either // because we assume that *Withdrawal will only ever contain valid withdrawals that were either
// constructed by decoding or via public API in this package. // constructed by decoding or via public API in this package.

View file

@ -385,9 +385,7 @@ 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 += common.StorageSize(result.Withdrawals.Size())
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
} }