minor code change, no function impact
This commit is contained in:
parent
f35c8fe426
commit
a917ffee16
@ -97,6 +97,11 @@ const FilecoinPrecision = 1000000000000000000
|
||||
// Blocks
|
||||
const HalvingPeriodBlocks = 6 * 365 * 24 * 60 * 2
|
||||
|
||||
// constants for Weight calculation
|
||||
// The ratio of weight contributed by short-term vs long-term factors in a given round
|
||||
const WRatioNum = int64(1)
|
||||
const WRatioDen = 2
|
||||
|
||||
// TODO: Move other important consts here
|
||||
|
||||
func init() {
|
||||
|
@ -11,6 +11,8 @@ import (
|
||||
)
|
||||
|
||||
var zero = types.NewInt(0)
|
||||
var wRatio_num = build.WRatioNum
|
||||
var wRatio_den = build.WRatioDen
|
||||
|
||||
func (cs *ChainStore) Weight(ctx context.Context, ts *types.TipSet) (types.BigInt, error) {
|
||||
if ts == nil {
|
||||
@ -37,17 +39,17 @@ func (cs *ChainStore) Weight(ctx context.Context, ts *types.TipSet) (types.BigIn
|
||||
tpow := types.BigFromBytes(ret.Return)
|
||||
if tpow.GreaterThan(zero) {
|
||||
log2P = int64(tpow.BitLen() - 1)
|
||||
} else {
|
||||
// Not really expect to be here ...
|
||||
return types.EmptyInt, xerrors.Errorf("All power in the net is gone. The net is dead!")
|
||||
}
|
||||
|
||||
out.Add(out, big.NewInt(log2P*256))
|
||||
out.Add(out, big.NewInt(log2P << 8))
|
||||
|
||||
// (wFunction(totalPowerAtTipset(ts)) * len(ts.blocks) * wRatio_num * 2^8) / (e * wRatio_den)
|
||||
|
||||
wRatioNum := int64(1)
|
||||
wRatioDen := 2
|
||||
|
||||
eWeight := big.NewInt((log2P * int64(len(ts.Blocks())) * wRatioNum) << 8)
|
||||
eWeight.Div(eWeight, big.NewInt(int64(build.BlocksPerEpoch*wRatioDen)))
|
||||
eWeight := big.NewInt((log2P * int64(len(ts.Blocks())) * wRatio_num) << 8)
|
||||
eWeight.Div(eWeight, big.NewInt(int64(build.BlocksPerEpoch * wRatio_den)))
|
||||
out.Add(out, eWeight)
|
||||
|
||||
return types.BigInt{Int: out}, nil
|
||||
|
Loading…
Reference in New Issue
Block a user