handle potential overallocation

This commit is contained in:
whyrusleeping 2020-08-18 10:56:54 -07:00
parent 8942c02f28
commit 42730bcf1c

View File

@ -273,6 +273,9 @@ func MakeInitialStateTree(ctx context.Context, bs bstore.Blockstore, template ge
totalFil := big.Mul(big.NewInt(int64(build.FilBase)), big.NewInt(int64(build.FilecoinPrecision)))
remainingFil := big.Sub(totalFil, totalFilAllocated)
if remainingFil.Sign() < 0 {
return nil, nil, xerrors.Errorf("somehow overallocated filecoin (allocated = %s)", types.FIL(totalFilAllocated))
}
template.RemainderAccount.Balance = remainingFil