diff --git a/chain/store/weight.go b/chain/store/weight.go index 999166f89..53c202845 100644 --- a/chain/store/weight.go +++ b/chain/store/weight.go @@ -38,16 +38,16 @@ func (cs *ChainStore) Weight(ctx context.Context, ts *types.TipSet) (types.BigIn if tpow.GreaterThan(zero) { log2P = int64(tpow.BitLen() - 1) } else { - // Not really expect to be here ... + // 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 << 8)) + out.Add(out, big.NewInt(log2P<<8)) // (wFunction(totalPowerAtTipset(ts)) * len(ts.blocks) * wRatio_num * 2^8) / (e * wRatio_den) eWeight := big.NewInt((log2P * int64(len(ts.Blocks())) * build.WRatioNum) << 8) - eWeight.Div(eWeight, big.NewInt(int64(build.BlocksPerEpoch * build.WRatioDen))) + eWeight.Div(eWeight, big.NewInt(int64(build.BlocksPerEpoch*build.WRatioDen))) out.Add(out, eWeight) return types.BigInt{Int: out}, nil diff --git a/chain/types/blockheader.go b/chain/types/blockheader.go index 204208e0f..d65a068d8 100644 --- a/chain/types/blockheader.go +++ b/chain/types/blockheader.go @@ -170,7 +170,7 @@ func PowerCmp(eproof ElectionProof, mpow, totpow BigInt) bool { max(h) == 2^256-1 which in terms of integer math means: (h(vrfout) + 1) * totalPower <= e * minerPower * 2^256 - in 2^256 space, it is equivalent to: + in 2^256 space, it is equivalent to: h(vrfout) * totalPower < e * minerPower * 2^256 */ @@ -183,7 +183,7 @@ func PowerCmp(eproof ElectionProof, mpow, totpow BigInt) bool { // rhs = minerPower << 256 rhs := new(big.Int).Lsh(mpow.Int, 256) rhs = rhs.Mul(rhs, blocksPerEpoch.Int) - + // h(vrfout) * totalPower < e * minerPower * 2^256? return lhs.Cmp(rhs) == -1 }