bring back api.StateMinerProvingSet
This commit is contained in:
parent
0336b32fcd
commit
85993848be
@ -118,6 +118,7 @@ type FullNode interface {
|
|||||||
|
|
||||||
StateNetworkName(context.Context) (dtypes.NetworkName, error)
|
StateNetworkName(context.Context) (dtypes.NetworkName, error)
|
||||||
StateMinerSectors(context.Context, address.Address, *abi.BitField, types.TipSetKey) ([]*ChainSectorInfo, error)
|
StateMinerSectors(context.Context, address.Address, *abi.BitField, types.TipSetKey) ([]*ChainSectorInfo, error)
|
||||||
|
StateMinerProvingSet(context.Context, address.Address, types.TipSetKey) ([]*ChainSectorInfo, error)
|
||||||
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error)
|
StateMinerPower(context.Context, address.Address, types.TipSetKey) (*MinerPower, error)
|
||||||
StateMinerWorker(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
StateMinerWorker(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
||||||
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) (*miner.Deadlines, error)
|
StateMinerDeadlines(context.Context, address.Address, types.TipSetKey) (*miner.Deadlines, error)
|
||||||
|
@ -114,11 +114,12 @@ type FullNodeStruct struct {
|
|||||||
|
|
||||||
StateNetworkName func(context.Context) (dtypes.NetworkName, error) `perm:"read"`
|
StateNetworkName func(context.Context) (dtypes.NetworkName, error) `perm:"read"`
|
||||||
StateMinerSectors func(context.Context, address.Address, *abi.BitField, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
|
StateMinerSectors func(context.Context, address.Address, *abi.BitField, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
|
||||||
|
StateMinerProvingSet func(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, error) `perm:"read"`
|
||||||
StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"`
|
StateMinerPower func(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) `perm:"read"`
|
||||||
StateMinerWorker func(context.Context, address.Address, types.TipSetKey) (address.Address, error) `perm:"read"`
|
StateMinerWorker func(context.Context, address.Address, types.TipSetKey) (address.Address, error) `perm:"read"`
|
||||||
StateMinerPeerID func(ctx context.Context, m address.Address, tsk types.TipSetKey) (peer.ID, error) `perm:"read"`
|
StateMinerPeerID func(ctx context.Context, m address.Address, tsk types.TipSetKey) (peer.ID, error) `perm:"read"`
|
||||||
StateMinerSectorSize func(context.Context, address.Address, types.TipSetKey) (abi.SectorSize, error) `perm:"read"`
|
StateMinerSectorSize func(context.Context, address.Address, types.TipSetKey) (abi.SectorSize, error) `perm:"read"`
|
||||||
StateMinerDeadlines func(context.Context, address.Address, types.TipSetKey) (*miner.Deadlines, error)
|
StateMinerDeadlines func(context.Context, address.Address, types.TipSetKey) (*miner.Deadlines, error) `perm:"read"`
|
||||||
StateMinerFaults func(context.Context, address.Address, types.TipSetKey) ([]abi.SectorNumber, error) `perm:"read"`
|
StateMinerFaults func(context.Context, address.Address, types.TipSetKey) ([]abi.SectorNumber, error) `perm:"read"`
|
||||||
StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
|
StateSectorPreCommitInfo func(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error) `perm:"read"`
|
||||||
StateCall func(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error) `perm:"read"`
|
StateCall func(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error) `perm:"read"`
|
||||||
@ -483,6 +484,10 @@ func (c *FullNodeStruct) StateMinerSectors(ctx context.Context, addr address.Add
|
|||||||
return c.Internal.StateMinerSectors(ctx, addr, filter, tsk)
|
return c.Internal.StateMinerSectors(ctx, addr, filter, tsk)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *FullNodeStruct) StateMinerProvingSet(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
||||||
|
return c.Internal.StateMinerProvingSet(ctx, addr, tsk)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *FullNodeStruct) StateMinerPower(ctx context.Context, a address.Address, tsk types.TipSetKey) (*api.MinerPower, error) {
|
func (c *FullNodeStruct) StateMinerPower(ctx context.Context, a address.Address, tsk types.TipSetKey) (*api.MinerPower, error) {
|
||||||
return c.Internal.StateMinerPower(ctx, a, tsk)
|
return c.Internal.StateMinerPower(ctx, a, tsk)
|
||||||
}
|
}
|
||||||
|
@ -371,6 +371,20 @@ func ComputeState(ctx context.Context, sm *StateManager, height abi.ChainEpoch,
|
|||||||
return root, trace, nil
|
return root, trace, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetProvingSetRaw(ctx context.Context, sm *StateManager, mas miner.State) ([]*api.ChainSectorInfo, error) {
|
||||||
|
notProving, err := abi.BitFieldUnion(mas.Faults, mas.Recoveries, mas.NewSectors)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
provset, err := LoadSectorsFromSet(ctx, sm.cs.Blockstore(), mas.Sectors, ¬Proving)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("failed to get proving set: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return provset, nil
|
||||||
|
}
|
||||||
|
|
||||||
func MinerGetBaseInfo(ctx context.Context, sm *StateManager, tsk types.TipSetKey, maddr address.Address) (*api.MiningBaseInfo, error) {
|
func MinerGetBaseInfo(ctx context.Context, sm *StateManager, tsk types.TipSetKey, maddr address.Address) (*api.MiningBaseInfo, error) {
|
||||||
ts, err := sm.ChainStore().LoadTipSet(tsk)
|
ts, err := sm.ChainStore().LoadTipSet(tsk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -388,16 +402,11 @@ func MinerGetBaseInfo(ctx context.Context, sm *StateManager, tsk types.TipSetKey
|
|||||||
return nil, xerrors.Errorf("(get sset) failed to load miner actor state: %w", err)
|
return nil, xerrors.Errorf("(get sset) failed to load miner actor state: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
notProving, err := abi.BitFieldUnion(mas.Faults, mas.Recoveries, mas.NewSectors)
|
provset, err := GetProvingSetRaw(ctx, sm, mas)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
provset, err := LoadSectorsFromSet(ctx, sm.cs.Blockstore(), mas.Sectors, ¬Proving)
|
|
||||||
if err != nil {
|
|
||||||
return nil, xerrors.Errorf("failed to get proving set: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
mpow, tpow, err := getPowerRaw(ctx, sm, st, maddr)
|
mpow, tpow, err := getPowerRaw(ctx, sm, st, maddr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, xerrors.Errorf("failed to get power: %w", err)
|
return nil, xerrors.Errorf("failed to get power: %w", err)
|
||||||
|
@ -225,7 +225,7 @@ var stateSectorsCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
sectors, err := api.StateMinerSectors(ctx, maddr, ts.Key())
|
sectors, err := api.StateMinerSectors(ctx, maddr, nil, ts.Key())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,21 @@ func (a *StateAPI) StateMinerSectors(ctx context.Context, addr address.Address,
|
|||||||
return stmgr.GetMinerSectorSet(ctx, a.StateManager, ts, addr, filter)
|
return stmgr.GetMinerSectorSet(ctx, a.StateManager, ts, addr, filter)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *StateAPI) StateMinerProvingSet(ctx context.Context, addr address.Address, tsk types.TipSetKey) ([]*api.ChainSectorInfo, error) {
|
||||||
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
var mas miner.State
|
||||||
|
_, err = a.StateManager.LoadActorState(ctx, addr, &mas, ts)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("(get sset) failed to load miner actor state: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return stmgr.GetProvingSetRaw(ctx, a.StateManager, mas)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *StateAPI) StateMinerWorker(ctx context.Context, m address.Address, tsk types.TipSetKey) (address.Address, error) {
|
func (a *StateAPI) StateMinerWorker(ctx context.Context, m address.Address, tsk types.TipSetKey) (address.Address, error) {
|
||||||
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -97,6 +112,23 @@ func (a *StateAPI) StateMinerFaults(ctx context.Context, addr address.Address, t
|
|||||||
return stmgr.GetMinerFaults(ctx, a.StateManager, ts, addr)
|
return stmgr.GetMinerFaults(ctx, a.StateManager, ts, addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *StateAPI) StateMinerPower(ctx context.Context, addr address.Address, tsk types.TipSetKey) (*api.MinerPower, error) {
|
||||||
|
ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||||
|
if err != nil {
|
||||||
|
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
m, net, err := stmgr.GetPower(ctx, a.StateManager, ts, addr)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &api.MinerPower{
|
||||||
|
MinerPower: m,
|
||||||
|
TotalPower: net,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *StateAPI) StatePledgeCollateral(ctx context.Context, tsk types.TipSetKey) (types.BigInt, error) {
|
func (a *StateAPI) StatePledgeCollateral(ctx context.Context, tsk types.TipSetKey) (types.BigInt, error) {
|
||||||
/*ts, err := a.Chain.GetTipSetFromKey(tsk)
|
/*ts, err := a.Chain.GetTipSetFromKey(tsk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -51,8 +51,7 @@ type storageMinerApi interface {
|
|||||||
StateCall(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error)
|
StateCall(context.Context, *types.Message, types.TipSetKey) (*api.InvocResult, error)
|
||||||
StateMinerWorker(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
StateMinerWorker(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
||||||
StateMinerDeadlines(ctx context.Context, maddr address.Address, tok types.TipSetKey) (*miner.Deadlines, error)
|
StateMinerDeadlines(ctx context.Context, maddr address.Address, tok types.TipSetKey) (*miner.Deadlines, error)
|
||||||
StateMinerSectors(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, error)
|
StateMinerSectors(context.Context, address.Address, *abi.BitField, types.TipSetKey) ([]*api.ChainSectorInfo, error)
|
||||||
StateMinerProvingSet(context.Context, address.Address, types.TipSetKey) ([]*api.ChainSectorInfo, error)
|
|
||||||
StateMinerSectorSize(context.Context, address.Address, types.TipSetKey) (abi.SectorSize, error)
|
StateMinerSectorSize(context.Context, address.Address, types.TipSetKey) (abi.SectorSize, error)
|
||||||
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
|
StateSectorPreCommitInfo(context.Context, address.Address, abi.SectorNumber, types.TipSetKey) (miner.SectorPreCommitOnChainInfo, error)
|
||||||
StateWaitMsg(context.Context, cid.Cid) (*api.MsgLookup, error) // TODO: removeme eventually
|
StateWaitMsg(context.Context, cid.Cid) (*api.MsgLookup, error) // TODO: removeme eventually
|
||||||
|
Loading…
Reference in New Issue
Block a user