From 3f3895f30e11aedb5de608af93197d217274990b Mon Sep 17 00:00:00 2001 From: 0xTopaz Date: Tue, 31 Dec 2024 16:05:22 +0900 Subject: [PATCH] feat: UnitTree, RewardCacheTree Size Support --- staker/reward_calculation_types.gno | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/staker/reward_calculation_types.gno b/staker/reward_calculation_types.gno index 530dd1eaa..88ce727ef 100644 --- a/staker/reward_calculation_types.gno +++ b/staker/reward_calculation_types.gno @@ -66,6 +66,10 @@ func (self *UintTree) ReverseIterate(start, end uint64, fn func(key uint64, valu }) } +func (self *UintTree) Size() uint64 { + return uint64(self.tree.Size()) +} + type RewardCacheTree struct { tree *avl.Tree } @@ -98,6 +102,10 @@ func (self *RewardCacheTree) Iterate(start, end uint64, fn func(key uint64, valu }) } +func (self *RewardCacheTree) Size() uint64 { + return uint64(self.tree.Size()) +} + func (self *RewardCacheTree) CurrentReward(currentHeight uint64) interface{} { result, ok := self.tree.Get(EncodeUint(currentHeight)) if ok { @@ -124,4 +132,4 @@ func (self *RewardCacheTree) RewardPerInterval(startHeight, endHeight uint64, f if endHeight > currentHeight { f(endHeight-currentHeight, currentPoolReward) } -} \ No newline at end of file +}