You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
743 B
32 lines
743 B
5 years ago
|
package network
|
||
|
|
||
|
import (
|
||
|
"math/big"
|
||
|
"time"
|
||
|
|
||
|
"github.com/harmony-one/harmony/consensus/engine"
|
||
|
"github.com/harmony-one/harmony/numeric"
|
||
|
)
|
||
|
|
||
|
// UtilityMetric ..
|
||
|
type UtilityMetric struct {
|
||
|
AccumulatorSnapshot *big.Int
|
||
|
CurrentStakedPercentage numeric.Dec
|
||
|
Deviation numeric.Dec
|
||
|
Adjustment numeric.Dec
|
||
|
}
|
||
|
|
||
|
// NewUtilityMetricSnapshot ..
|
||
|
func NewUtilityMetricSnapshot(beaconchain engine.ChainReader) (*UtilityMetric, error) {
|
||
|
soFarDoledOut, percentageStaked, err := WhatPercentStakedNow(
|
||
|
beaconchain, time.Now().Unix(),
|
||
|
)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
howMuchOff, adjustBy := Adjustment(*percentageStaked)
|
||
|
return &UtilityMetric{
|
||
|
soFarDoledOut, *percentageStaked, howMuchOff, adjustBy,
|
||
|
}, nil
|
||
|
}
|