diff --git a/api/api_full.go b/api/api_full.go index c33a7abb8..3c28b5982 100644 --- a/api/api_full.go +++ b/api/api_full.go @@ -119,7 +119,7 @@ type FullNode interface { StateMinerSectors(context.Context, address.Address, 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) StateMinerPeerID(ctx context.Context, m address.Address, tsk types.TipSetKey) (peer.ID, error) StateMinerPostState(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*miner.PoStState, error) diff --git a/api/apistruct/struct.go b/api/apistruct/struct.go index 4fc70904c..9eb73c637 100644 --- a/api/apistruct/struct.go +++ b/api/apistruct/struct.go @@ -107,7 +107,7 @@ type FullNodeStruct struct { StateMinerSectors func(context.Context, address.Address, 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"` StateMinerPeerID func(ctx context.Context, m address.Address, tsk types.TipSetKey) (peer.ID, error) `perm:"read"` StateMinerPostState func(ctx context.Context, actor address.Address, tsk types.TipSetKey) (*miner.PoStState, error) `perm:"read"` @@ -446,7 +446,7 @@ func (c *FullNodeStruct) StateMinerProvingSet(ctx context.Context, addr address. 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) } diff --git a/chain/gen/gen.go b/chain/gen/gen.go index 2d1033227..aab6db675 100644 --- a/chain/gen/gen.go +++ b/chain/gen/gen.go @@ -444,7 +444,7 @@ func (cg *ChainGen) YieldRepo() (repo.Repo, error) { type MiningCheckAPI interface { ChainGetRandomness(ctx context.Context, tsk types.TipSetKey, personalization crypto.DomainSeparationTag, randEpoch abi.ChainEpoch, entropy []byte) (abi.Randomness, error) - StateMinerPower(context.Context, address.Address, types.TipSetKey) (api.MinerPower, error) + StateMinerPower(context.Context, address.Address, types.TipSetKey) (*api.MinerPower, error) StateMinerWorker(context.Context, address.Address, types.TipSetKey) (address.Address, error) @@ -469,17 +469,17 @@ func (mca mca) ChainGetRandomness(ctx context.Context, tsk types.TipSetKey, pers return mca.sm.ChainStore().GetRandomness(ctx, pts.Cids(), personalization, int64(randEpoch), entropy) } -func (mca mca) StateMinerPower(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (api.MinerPower, error) { +func (mca mca) StateMinerPower(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (*api.MinerPower, error) { ts, err := mca.sm.ChainStore().LoadTipSet(tsk) if err != nil { - return api.MinerPower{}, xerrors.Errorf("loading tipset %s: %w", tsk, err) + return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) } mpow, tpow, err := stmgr.GetPower(ctx, mca.sm, ts, maddr) if err != nil { - return api.MinerPower{}, err + return nil, err } - return api.MinerPower{ + return &api.MinerPower{ MinerPower: mpow, TotalPower: tpow, }, err diff --git a/node/impl/full/state.go b/node/impl/full/state.go index 7c3c2c8d5..0e7ab49c0 100644 --- a/node/impl/full/state.go +++ b/node/impl/full/state.go @@ -64,27 +64,27 @@ func (a *StateAPI) StateMinerProvingSet(ctx context.Context, addr address.Addres return stmgr.GetMinerProvingSet(ctx, a.StateManager, ts, addr) } -func (a *StateAPI) StateMinerPower(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (api.MinerPower, error) { +func (a *StateAPI) StateMinerPower(ctx context.Context, maddr address.Address, tsk types.TipSetKey) (*api.MinerPower, error) { ts, err := a.Chain.GetTipSetFromKey(tsk) if err != nil { - return api.MinerPower{}, xerrors.Errorf("loading tipset %s: %w", tsk, err) + return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err) } mpow, tpow, err := stmgr.GetPower(ctx, a.StateManager, ts, maddr) if err != nil { - return api.MinerPower{}, err + return nil, err } if maddr != address.Undef { slashed, err := stmgr.GetMinerSlashed(ctx, a.StateManager, ts, maddr) if err != nil { - return api.MinerPower{}, err + return nil, err } if slashed { mpow = types.NewInt(0) } } - return api.MinerPower{ + return &api.MinerPower{ MinerPower: mpow, TotalPower: tpow, }, nil