Merge pull request #515 from steven004/weight
minor weight function change
This commit is contained in:
commit
28367c5ba1
@ -103,8 +103,10 @@ const FilecoinPrecision = 1_000_000_000_000_000_000
|
||||
// Blocks
|
||||
const HalvingPeriodBlocks = 6 * 365 * 24 * 60 * 2
|
||||
|
||||
// Blocks
|
||||
const AdjustmentPeriod = 7 * 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
|
||||
|
||||
|
@ -37,17 +37,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. You network might be disconnected, or 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())) * build.WRatioNum) << 8)
|
||||
eWeight.Div(eWeight, big.NewInt(int64(build.BlocksPerEpoch * build.WRatioDen)))
|
||||
out.Add(out, eWeight)
|
||||
|
||||
return types.BigInt{Int: out}, nil
|
||||
|
Loading…
Reference in New Issue
Block a user