Merge pull request #2961 from filecoin-project/asr/genesis-premined

Revise TotalCircSupply
This commit is contained in:
Aayush Rajasekaran
2020-08-12 17:12:54 -04:00
committed by GitHub
9 changed files with 278 additions and 218 deletions
+11 -3
View File
@@ -1071,7 +1071,7 @@ func (a *StateAPI) StateMinerInitialPledgeCollateral(ctx context.Context, maddr
duration := pci.Expiration - ts.Height() // NB: not exactly accurate, but should always lead us to *over* estimate, not under
circSupply, err := a.StateManager.CirculatingSupply(ctx, ts)
circSupply, err := a.StateCirculatingSupply(ctx, ts.Key())
if err != nil {
return big.Zero(), xerrors.Errorf("getting circulating supply: %w", err)
}
@@ -1175,7 +1175,7 @@ func (a *StateAPI) StateDealProviderCollateralBounds(ctx context.Context, size a
return api.DealCollateralBounds{}, xerrors.Errorf("getting power and reward actor states: %w")
}
circ, err := a.StateManager.CirculatingSupply(ctx, ts)
circ, err := a.StateCirculatingSupply(ctx, ts.Key())
if err != nil {
return api.DealCollateralBounds{}, xerrors.Errorf("getting total circulating supply: %w")
}
@@ -1193,5 +1193,13 @@ func (a *StateAPI) StateCirculatingSupply(ctx context.Context, tsk types.TipSetK
return abi.TokenAmount{}, xerrors.Errorf("loading tipset %s: %w", tsk, err)
}
return stmgr.GetCirculatingSupply(ctx, a.StateManager, ts)
st, _, err := a.StateManager.TipSetState(ctx, ts)
if err != nil {
return big.Zero(), err
}
cst := cbor.NewCborStore(a.Chain.Blockstore())
sTree, err := state.LoadStateTree(cst, st)
return a.StateManager.GetCirculatingSupply(ctx, ts.Height(), sTree)
}