Omit double delaration
This commit is contained in:
parent
a917ffee16
commit
dd8642c43c
@ -11,8 +11,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var zero = types.NewInt(0)
|
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) {
|
func (cs *ChainStore) Weight(ctx context.Context, ts *types.TipSet) (types.BigInt, error) {
|
||||||
if ts == nil {
|
if ts == nil {
|
||||||
@ -41,15 +39,15 @@ func (cs *ChainStore) Weight(ctx context.Context, ts *types.TipSet) (types.BigIn
|
|||||||
log2P = int64(tpow.BitLen() - 1)
|
log2P = int64(tpow.BitLen() - 1)
|
||||||
} else {
|
} 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. 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))
|
out.Add(out, big.NewInt(log2P << 8))
|
||||||
|
|
||||||
// (wFunction(totalPowerAtTipset(ts)) * len(ts.blocks) * wRatio_num * 2^8) / (e * wRatio_den)
|
// (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 := big.NewInt((log2P * int64(len(ts.Blocks())) * build.WRatioNum) << 8)
|
||||||
eWeight.Div(eWeight, big.NewInt(int64(build.BlocksPerEpoch * wRatio_den)))
|
eWeight.Div(eWeight, big.NewInt(int64(build.BlocksPerEpoch * build.WRatioDen)))
|
||||||
out.Add(out, eWeight)
|
out.Add(out, eWeight)
|
||||||
|
|
||||||
return types.BigInt{Int: out}, nil
|
return types.BigInt{Int: out}, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user