Add epoch, block number to current-epoch-performance

pull/4116/head
harjas 3 years ago committed by Leo Chen
parent 096f19be1a
commit 68e761b596
  1. 4
      hmy/staking.go
  2. 2
      staking/availability/measure.go
  3. 10
      staking/types/validator.go

@ -326,12 +326,12 @@ func (hmy *Harmony) GetValidatorInformation(
lastBlockOfEpoch := shard.Schedule.EpochLastBlock(hmy.BeaconChain.CurrentBlock().Header().Epoch().Uint64())
computed.BlocksLeftInEpoch = lastBlockOfEpoch - hmy.BeaconChain.CurrentBlock().Header().Number().Uint64()
computed.Block = hmy.BeaconChain.CurrentBlock().Header().Number().Uint64()
computed.Epoch = hmy.BeaconChain.CurrentBlock().Header().Epoch().Uint64()
if defaultReply.CurrentlyInCommittee {
defaultReply.Performance = &staking.CurrentEpochPerformance{
CurrentSigningPercentage: *computed,
Epoch: hmy.BeaconChain.CurrentBlock().Header().Number().Uint64(),
Block: hmy.BeaconChain.CurrentBlock().Header().Epoch().Uint64(),
}
}

@ -143,7 +143,7 @@ func ComputeCurrentSigning(
new(big.Int).Sub(statsNow.NumBlocksToSign, snapToSign)
computed := staking.NewComputed(
signed, toSign, 0, numeric.ZeroDec(), true, 0, 0,
signed, toSign, 0, numeric.ZeroDec(), true,
)
if toSign.Cmp(common.Big0) == 0 {

@ -109,8 +109,6 @@ type Computed struct {
BlocksLeftInEpoch uint64 `json:"-"`
Percentage numeric.Dec `json:"current-epoch-signing-percentage"`
IsBelowThreshold bool `json:"-"`
Epoch uint64 `json:"epoch"`
Block uint64 `json:"block"`
}
func (c Computed) String() string {
@ -123,10 +121,8 @@ func NewComputed(
signed, toSign *big.Int,
blocksLeft uint64,
percent numeric.Dec,
isBelowNow bool,
epoch uint64,
block uint64) *Computed {
return &Computed{signed, toSign, blocksLeft, percent, isBelowNow, epoch, block}
isBelowNow bool) *Computed {
return &Computed{signed, toSign, blocksLeft, percent, isBelowNow}
}
// NewEmptyStats ..
@ -143,6 +139,8 @@ func NewEmptyStats() *ValidatorStats {
// whatever current epoch is
type CurrentEpochPerformance struct {
CurrentSigningPercentage Computed `json:"current-epoch-signing-percent"`
Epoch uint64 `json:"epoch"`
Block uint64 `json:"block"`
}
// ValidatorRPCEnhanced contains extra information for RPC consumer

Loading…
Cancel
Save