feat: api: new verified registry methods to get all allocations and claims (#11631)
* new verireg methods * update changelog and add itest * update itest and cli * update new method's support till v9 * remove gateway APIs * fix cli internal var names
This commit is contained in:
@@ -866,6 +866,25 @@ func (a *StateAPI) StateGetAllocations(ctx context.Context, clientAddr address.A
|
||||
return allocations, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateGetAllAllocations(ctx context.Context, tsk types.TipSetKey) (map[verifreg.AllocationId]verifreg.Allocation, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
st, err := a.StateManager.GetVerifregState(ctx, ts)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading verifreg state: %w", err)
|
||||
}
|
||||
|
||||
allocations, err := st.GetAllAllocations()
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("getting all allocations: %w", err)
|
||||
}
|
||||
|
||||
return allocations, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateGetClaim(ctx context.Context, providerAddr address.Address, claimId verifreg.ClaimId, tsk types.TipSetKey) (*verifreg.Claim, error) {
|
||||
idAddr, err := a.StateLookupID(ctx, providerAddr, tsk)
|
||||
if err != nil {
|
||||
@@ -917,6 +936,25 @@ func (a *StateAPI) StateGetClaims(ctx context.Context, providerAddr address.Addr
|
||||
return claims, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateGetAllClaims(ctx context.Context, tsk types.TipSetKey) (map[verifreg.ClaimId]verifreg.Claim, error) {
|
||||
ts, err := a.Chain.GetTipSetFromKey(ctx, tsk)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading tipset %s: %w", tsk, err)
|
||||
}
|
||||
|
||||
st, err := a.StateManager.GetVerifregState(ctx, ts)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("loading verifreg state: %w", err)
|
||||
}
|
||||
|
||||
claims, err := st.GetAllClaims()
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("getting all claims: %w", err)
|
||||
}
|
||||
|
||||
return claims, nil
|
||||
}
|
||||
|
||||
func (a *StateAPI) StateComputeDataCID(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) {
|
||||
nv, err := a.StateNetworkVersion(ctx, tsk)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user