Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add API methods to get allocations and claims #9437

Merged
merged 1 commit into from
Oct 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions api/api_full.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,12 @@ type FullNode interface {
StateGetAllocationForPendingDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error) //perm:read
// StateGetAllocation returns the allocation for a given address and allocation ID.
StateGetAllocation(ctx context.Context, clientAddr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error) //perm:read
// StateGetAllocations returns the all the allocations for a given client.
StateGetAllocations(ctx context.Context, clientAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) //perm:read
// StateGetClaim returns the claim for a given address and claim ID.
StateGetClaim(ctx context.Context, providerAddr address.Address, claimId verifregtypes.ClaimId, tsk types.TipSetKey) (*verifregtypes.Claim, error) //perm:read
// StateGetClaims returns the all the claims for a given provider.
StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) //perm:read
// StateComputeDataCID computes DataCID from a set of on-chain deals
StateComputeDataCID(ctx context.Context, maddr address.Address, sectorType abi.RegisteredSealProof, deals []abi.DealID, tsk types.TipSetKey) (cid.Cid, error) //perm:read
// StateLookupID retrieves the ID address of the given address
Expand Down
5 changes: 5 additions & 0 deletions api/docgen/docgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ func init() {
allocationId := verifreg.AllocationId(0)
addExample(allocationId)
addExample(&allocationId)
addExample(map[verifreg.AllocationId]verifreg.Allocation{})
claimId := verifreg.ClaimId(0)
addExample(claimId)
addExample(&claimId)
addExample(map[verifreg.ClaimId]verifreg.Claim{})
addExample(map[string]int{"name": 42})
addExample(map[string]time.Time{"name": time.Unix(1615243938, 0).UTC()})
addExample(&types.ExecutionTrace{
Expand Down
45 changes: 45 additions & 0 deletions api/mocks/mock_full.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions api/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions api/v0api/full.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,12 @@ type FullNode interface {
StateGetAllocationForPendingDeal(ctx context.Context, dealId abi.DealID, tsk types.TipSetKey) (*verifregtypes.Allocation, error)
// StateGetAllocation returns the allocation for a given address and allocation ID.
StateGetAllocation(ctx context.Context, clientAddr address.Address, allocationId verifregtypes.AllocationId, tsk types.TipSetKey) (*verifregtypes.Allocation, error) //perm:read
// StateGetAllocations returns the all the allocations for a given client.
StateGetAllocations(ctx context.Context, clientAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error) //perm:read
// StateGetClaim returns the claim for a given address and claim ID.
StateGetClaim(ctx context.Context, providerAddr address.Address, claimId verifregtypes.ClaimId, tsk types.TipSetKey) (*verifregtypes.Claim, error) //perm:read
// StateGetClaims returns the all the claims for a given provider.
StateGetClaims(ctx context.Context, providerAddr address.Address, tsk types.TipSetKey) (map[verifregtypes.ClaimId]verifregtypes.Claim, error) //perm:read
// StateLookupID retrieves the ID address of the given address
StateLookupID(context.Context, address.Address, types.TipSetKey) (address.Address, error) //perm:read
// StateAccountKey returns the public key address of the given ID address
Expand Down
39 changes: 39 additions & 0 deletions api/v0api/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions api/v0api/v0mocks/mock_full.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified build/openrpc/full.json.gz
Binary file not shown.
Binary file modified build/openrpc/gateway.json.gz
Binary file not shown.
Binary file modified build/openrpc/miner.json.gz
Binary file not shown.
Binary file modified build/openrpc/worker.json.gz
Binary file not shown.
3 changes: 3 additions & 0 deletions chain/actors/builtin/verifreg/actor.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,8 @@ type State interface {
ForEachVerifier(func(addr address.Address, dcap abi.StoragePower) error) error
ForEachClient(func(addr address.Address, dcap abi.StoragePower) error) error
GetAllocation(clientIdAddr address.Address, allocationId verifregtypes.AllocationId) (*verifregtypes.Allocation, bool, error)
GetAllocations(clientIdAddr address.Address) (map[verifregtypes.AllocationId]verifregtypes.Allocation, error)
GetClaim(providerIdAddr address.Address, claimId verifregtypes.ClaimId) (*verifregtypes.Claim, bool, error)
GetClaims(providerIdAddr address.Address) (map[verifregtypes.ClaimId]verifregtypes.Claim, error)
GetState() interface{}
}
26 changes: 25 additions & 1 deletion chain/actors/builtin/verifreg/state.go.template
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,28 @@ func (s *state{{.v}}) GetAllocation(clientIdAddr address.Address, allocationId v
{{else}}
return s.FindAllocation(s.store, clientIdAddr, allocationId)
{{end}}
}
}

func (s *state{{.v}}) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {
{{if (le .v 8)}}
return nil, xerrors.Errorf("unsupported in actors v{{.v}}")
{{else}}
return s.LoadAllocationsToMap(s.store, clientIdAddr)
{{end}}
}

func (s *state{{.v}}) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {
{{if (le .v 8)}}
return nil, false, xerrors.Errorf("unsupported in actors v{{.v}}")
{{else}}
return s.FindClaim(s.store, providerIdAddr, claimId)
{{end}}
}

func (s *state{{.v}}) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {
{{if (le .v 8)}}
return nil, xerrors.Errorf("unsupported in actors v{{.v}}")
{{else}}
return s.LoadClaimsToMap(s.store, providerIdAddr)
{{end}}
}
18 changes: 18 additions & 0 deletions chain/actors/builtin/verifreg/v0.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,21 @@ func (s *state0) GetAllocation(clientIdAddr address.Address, allocationId verifr
return nil, false, xerrors.Errorf("unsupported in actors v0")

}

func (s *state0) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {

return nil, xerrors.Errorf("unsupported in actors v0")

}

func (s *state0) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {

return nil, false, xerrors.Errorf("unsupported in actors v0")

}

func (s *state0) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {

return nil, xerrors.Errorf("unsupported in actors v0")

}
18 changes: 18 additions & 0 deletions chain/actors/builtin/verifreg/v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,21 @@ func (s *state2) GetAllocation(clientIdAddr address.Address, allocationId verifr
return nil, false, xerrors.Errorf("unsupported in actors v2")

}

func (s *state2) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {

return nil, xerrors.Errorf("unsupported in actors v2")

}

func (s *state2) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {

return nil, false, xerrors.Errorf("unsupported in actors v2")

}

func (s *state2) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {

return nil, xerrors.Errorf("unsupported in actors v2")

}
18 changes: 18 additions & 0 deletions chain/actors/builtin/verifreg/v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,21 @@ func (s *state3) GetAllocation(clientIdAddr address.Address, allocationId verifr
return nil, false, xerrors.Errorf("unsupported in actors v3")

}

func (s *state3) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {

return nil, xerrors.Errorf("unsupported in actors v3")

}

func (s *state3) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {

return nil, false, xerrors.Errorf("unsupported in actors v3")

}

func (s *state3) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {

return nil, xerrors.Errorf("unsupported in actors v3")

}
18 changes: 18 additions & 0 deletions chain/actors/builtin/verifreg/v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,21 @@ func (s *state4) GetAllocation(clientIdAddr address.Address, allocationId verifr
return nil, false, xerrors.Errorf("unsupported in actors v4")

}

func (s *state4) GetAllocations(clientIdAddr address.Address) (map[verifreg9.AllocationId]verifreg9.Allocation, error) {

return nil, xerrors.Errorf("unsupported in actors v4")

}

func (s *state4) GetClaim(providerIdAddr address.Address, claimId verifreg9.ClaimId) (*verifreg9.Claim, bool, error) {

return nil, false, xerrors.Errorf("unsupported in actors v4")

}

func (s *state4) GetClaims(providerIdAddr address.Address) (map[verifreg9.ClaimId]verifreg9.Claim, error) {

return nil, xerrors.Errorf("unsupported in actors v4")

}
Loading