Omit double delaration

This commit is contained in:
steven004 2019-11-01 09:43:22 +08:00
parent a917ffee16
commit dd8642c43c

View File

@ -11,8 +11,6 @@ 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 {
@ -41,15 +39,15 @@ func (cs *ChainStore) Weight(ctx context.Context, ts *types.TipSet) (types.BigIn
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!")
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))
// (wFunction(totalPowerAtTipset(ts)) * len(ts.blocks) * wRatio_num * 2^8) / (e * wRatio_den)
eWeight := big.NewInt((log2P * int64(len(ts.Blocks())) * wRatio_num) << 8)
eWeight.Div(eWeight, big.NewInt(int64(build.BlocksPerEpoch * wRatio_den)))
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