Merge pull request #613 from filecoin-project/fix/st-mpow-slashed
StateAPI: account for slashing in StateMinerPower
This commit is contained in:
commit
abb8f29dfa
@ -193,6 +193,16 @@ func GetMinerSectorSize(ctx context.Context, sm *StateManager, ts *types.TipSet,
|
|||||||
return minfo.SectorSize, nil
|
return minfo.SectorSize, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (uint64, error) {
|
||||||
|
var mas actors.StorageMinerActorState
|
||||||
|
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
||||||
|
if err != nil {
|
||||||
|
return 0, xerrors.Errorf("failed to load miner actor state: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return mas.SlashedAt, nil
|
||||||
|
}
|
||||||
|
|
||||||
func GetStorageDeal(ctx context.Context, sm *StateManager, dealId uint64, ts *types.TipSet) (*actors.OnChainDeal, error) {
|
func GetStorageDeal(ctx context.Context, sm *StateManager, dealId uint64, ts *types.TipSet) (*actors.OnChainDeal, error) {
|
||||||
var state actors.StorageMarketState
|
var state actors.StorageMarketState
|
||||||
if _, err := sm.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil {
|
if _, err := sm.LoadActorState(ctx, actors.StorageMarketAddress, &state, ts); err != nil {
|
||||||
|
@ -52,6 +52,14 @@ func (a *StateAPI) StateMinerPower(ctx context.Context, maddr address.Address, t
|
|||||||
return api.MinerPower{}, err
|
return api.MinerPower{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
slashed, err := stmgr.GetMinerSlashed(ctx, a.StateManager, ts, maddr)
|
||||||
|
if err != nil {
|
||||||
|
return api.MinerPower{}, err
|
||||||
|
}
|
||||||
|
if slashed != 0 {
|
||||||
|
mpow = types.NewInt(0)
|
||||||
|
}
|
||||||
|
|
||||||
return api.MinerPower{
|
return api.MinerPower{
|
||||||
MinerPower: mpow,
|
MinerPower: mpow,
|
||||||
TotalPower: tpow,
|
TotalPower: tpow,
|
||||||
|
Loading…
Reference in New Issue
Block a user