Update GetMinerSlashed
This commit is contained in:
parent
dc2a67f13f
commit
50a8b6a184
@ -140,16 +140,6 @@ func StateMinerInfo(ctx context.Context, sm *StateManager, ts *types.TipSet, mad
|
|||||||
return mas.Info, nil
|
return mas.Info, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMinerSectorSizeRaw(ctx context.Context, sm *StateManager, st cid.Cid, maddr address.Address) (abi.SectorSize, error) {
|
|
||||||
var mas miner.State
|
|
||||||
_, err := sm.LoadActorStateRaw(ctx, maddr, &mas, st)
|
|
||||||
if err != nil {
|
|
||||||
return 0, xerrors.Errorf("(get ssize) failed to load miner actor state: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return mas.Info.SectorSize, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (bool, error) {
|
func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, maddr address.Address) (bool, error) {
|
||||||
var mas miner.State
|
var mas miner.State
|
||||||
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
_, err := sm.LoadActorState(ctx, maddr, &mas, ts)
|
||||||
@ -157,8 +147,6 @@ func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, ma
|
|||||||
return false, xerrors.Errorf("(get miner slashed) failed to load miner actor state")
|
return false, xerrors.Errorf("(get miner slashed) failed to load miner actor state")
|
||||||
}
|
}
|
||||||
|
|
||||||
panic("update this")
|
|
||||||
|
|
||||||
var spas power.State
|
var spas power.State
|
||||||
_, err = sm.LoadActorState(ctx, builtin.StoragePowerActorAddr, &spas, ts)
|
_, err = sm.LoadActorState(ctx, builtin.StoragePowerActorAddr, &spas, ts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -167,17 +155,34 @@ func GetMinerSlashed(ctx context.Context, sm *StateManager, ts *types.TipSet, ma
|
|||||||
|
|
||||||
store := sm.cs.Store(ctx)
|
store := sm.cs.Store(ctx)
|
||||||
|
|
||||||
claims, err := adt.AsMap(store, spas.Claims)
|
{
|
||||||
if err != nil {
|
claims, err := adt.AsMap(store, spas.Claims)
|
||||||
return false, err
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ok, err := claims.Get(power.AddrKey(maddr), nil)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if !ok {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ok, err := claims.Get(power.AddrKey(maddr), nil)
|
{
|
||||||
if err != nil {
|
detectedFaulty, err := adt.AsMap(store, spas.PoStDetectedFaultMiners)
|
||||||
return false, err
|
if err != nil {
|
||||||
}
|
return false, err
|
||||||
if !ok {
|
}
|
||||||
return true, nil
|
|
||||||
|
ok, err := detectedFaulty.Get(power.AddrKey(maddr), nil)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
if ok {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false, nil
|
return false, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user