Skip to content

Commit

Permalink
feat: UnitTree, RewardCacheTree Size Support
Browse files Browse the repository at this point in the history
  • Loading branch information
onlyhyde committed Dec 31, 2024
1 parent 85ef73b commit 3f3895f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion staker/reward_calculation_types.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand All @@ -124,4 +132,4 @@ func (self *RewardCacheTree) RewardPerInterval(startHeight, endHeight uint64, f
if endHeight > currentHeight {
f(endHeight-currentHeight, currentPoolReward)
}
}
}

0 comments on commit 3f3895f

Please sign in to comment.