rename RawStake() to RawStakePerSlot() and add commnet

pull/4163/head
peekpi 3 years ago committed by Soph
parent 9847d27dbb
commit 9138b10757
  1. 2
      core/blockchain.go
  2. 2
      hmy/staking.go
  3. 4
      staking/types/validator.go

@ -2568,7 +2568,7 @@ func (bc *BlockChain) UpdateValidatorVotingPower(
if snapshot, err := bc.ReadValidatorSnapshotAtEpoch(
newEpochSuperCommittee.Epoch, key,
); err == nil {
spread := snapshot.RawStake()
spread := snapshot.RawStakePerSlot()
for i := range stats.MetricsPerShard {
stats.MetricsPerShard[i].Vote.RawStake = spread
}

@ -46,7 +46,7 @@ func (hmy *Harmony) readAndUpdateRawStakes(
if err != nil {
continue
}
spread = snapshot.RawStake()
spread = snapshot.RawStakePerSlot()
validatorSpreads[slotAddr] = spread
}

@ -387,10 +387,12 @@ func (w *ValidatorWrapper) SanityCheck() error {
return nil
}
func (snapshot *ValidatorSnapshot) RawStake() numeric.Dec {
// RawStakePerSlot return raw stake of each slot key. If HIP16 was activated at that apoch, it only calculate raw stake for keys not exceed the slotsLimit.
func (snapshot ValidatorSnapshot) RawStakePerSlot() numeric.Dec {
wrapper := snapshot.Validator
instance := shard.Schedule.InstanceForEpoch(snapshot.Epoch)
slotsLimit := instance.SlotsLimit()
// HIP16 is acatived
if slotsLimit > 0 {
limitedSlotsCount := 0 // limited slots count for HIP16
shardCount := big.NewInt(int64(instance.NumShards()))

Loading…
Cancel
Save