Skip to content

Commit 20283ad

Browse files
authored
NOD-525: Optimize PoolRewards with cached hashing (#1321)
* NOD-525: Optimize PoolRewards with cached hashing Replace BufferedRef with HashedBufferedRef in PoolRewards' bakerPoolRewardDetails LFMBTree to cache computed hashes. This optimization eliminates redundant hash calculations previously performed for each block. Technical details: - Switched from BufferedRef to HashedBufferedRef - Affects bakerPoolRewardDetails tree in PoolRewards data
1 parent 19de805 commit 20283ad

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## Unreleased changes
4+
- Replace `BufferedRef` with `HashedBufferedRef` in `PoolRewards`
5+
`bakerPoolRewardDetails::LFMBTree` field to cache computed hashes.
46

57
## 8.0.3
68

concordium-consensus/src/Concordium/GlobalState/Persistent/PoolRewards.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ data PoolRewards (bhv :: BlockHashVersion) (av :: AccountVersion) = PoolRewards
5555
currentCapital :: !(CapitalDistributionRef bhv),
5656
-- | The details of rewards accruing to baker pools.
5757
-- These are indexed by the index of the baker in the capital distribution (_not_ the BakerId).
58-
bakerPoolRewardDetails :: !(LFMBT.LFMBTree Word64 BufferedRef (BakerPoolRewardDetails av)),
58+
bakerPoolRewardDetails :: !(LFMBT.LFMBTree Word64 HashedBufferedRef (BakerPoolRewardDetails av)),
5959
-- | The transaction reward amount accruing to the passive delegators.
6060
passiveDelegationTransactionRewards :: !Amount,
6161
-- | The transaction reward fraction accruing to the foundation.
@@ -140,7 +140,7 @@ migratePoolRewardsP1 curBakers nextBakers blockCounts npEpoch npMintRate = do
140140
passiveDelegatorsCapital = Vec.empty
141141
}
142142
makeBakerCapital (bid, amt) = BakerCapital bid amt Vec.empty
143-
makePRD :: (BakerId, a) -> m (BufferedRef (BakerPoolRewardDetails av))
143+
makePRD :: (BakerId, a) -> m (HashedBufferedRef (BakerPoolRewardDetails av))
144144
makePRD (bid, _) = do
145145
let bprd =
146146
BakerPoolRewardDetails

0 commit comments

Comments
 (0)