/
verifreg_types.go
232 lines (197 loc) · 6.06 KB
/
verifreg_types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
package verifreg
import (
addr "github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
"github.com/filecoin-project/go-state-types/crypto"
"github.com/filecoin-project/go-state-types/exitcode"
"github.com/ipfs/go-cid"
"github.com/multiformats/go-varint"
)
// RemoveDataCapProposal A verifier who wants to send/agree to a RemoveDataCapRequest should sign a RemoveDataCapProposal and send the signed proposal to the root key holder.
type RemoveDataCapProposal struct {
// VerifiedClient is the client address to remove the DataCap from
// The address must be an ID address
VerifiedClient addr.Address
// DataCapAmount is the amount of DataCap to be removed from the VerifiedClient address
DataCapAmount DataCap
// RemovalProposalID is the counter of the proposal sent by the Verifier for the VerifiedClient
RemovalProposalID RmDcProposalID
}
// RemoveDataCapRequest A verifier who wants to submit a request should send their RemoveDataCapRequest to the RKH.
type RemoveDataCapRequest struct {
// Verifier is the verifier address used for VerifierSignature.
// The address can be address.SECP256K1 or address.BLS
Verifier addr.Address
// VerifierSignature is the Verifier's signature over a RemoveDataCapProposal
VerifierSignature crypto.Signature
}
type AddVerifierParams struct {
Address addr.Address
Allowance DataCap
}
type AddVerifiedClientParams struct {
Address addr.Address
Allowance DataCap
}
type UseBytesParams struct {
// Address of verified client.
Address addr.Address
// Number of bytes to use.
DealSize abi.StoragePower
}
type RestoreBytesParams struct {
Address addr.Address
DealSize abi.StoragePower
}
type RemoveDataCapParams struct {
VerifiedClientToRemove addr.Address
DataCapAmountToRemove DataCap
VerifierRequest1 RemoveDataCapRequest
VerifierRequest2 RemoveDataCapRequest
}
type RemoveDataCapReturn struct {
VerifiedClient addr.Address
DataCapRemoved DataCap
}
type RemoveExpiredAllocationsParams struct {
Client abi.ActorID
AllocationIds []AllocationId
}
type RemoveExpiredAllocationsReturn struct {
Considered []AllocationId
Results BatchReturn
DataCapRecovered DataCap
}
type BatchReturn struct {
SuccessCount uint64
FailCodes []FailCode
}
type FailCode struct {
Idx uint64
Code exitcode.ExitCode
}
type AllocationId uint64
func (a AllocationId) Key() string {
return string(varint.ToUvarint(uint64(a)))
}
type ClaimId uint64
func (a ClaimId) Key() string {
return string(varint.ToUvarint(uint64(a)))
}
type ClaimAllocationsParams struct {
Sectors []SectorAllocationClaim
AllOrNothing bool
}
type SectorAllocationClaim struct {
Client abi.ActorID
AllocationId AllocationId
Data cid.Cid
Size abi.PaddedPieceSize
Sector abi.SectorNumber
SectorExpiry abi.ChainEpoch
}
type ClaimAllocationsReturn struct {
BatchInfo BatchReturn
ClaimedSpace big.Int
}
type GetClaimsParams struct {
Provider abi.ActorID
ClaimIds []ClaimId
}
type GetClaimsReturn struct {
BatchInfo BatchReturn
Claims []Claim
}
type Claim struct {
// The provider storing the data (from allocation).
Provider abi.ActorID
// The client which allocated the DataCap (from allocation).
Client abi.ActorID
// Identifier of the data committed (from allocation).
Data cid.Cid
// The (padded) size of data (from allocation).
Size abi.PaddedPieceSize
// The min period which the provider must commit to storing data
TermMin abi.ChainEpoch
// The max period for which provider can earn QA-power for the data
TermMax abi.ChainEpoch
// The epoch at which the (first range of the) piece was committed.
TermStart abi.ChainEpoch
// ID of the provider's sector in which the data is committed.
Sector abi.SectorNumber
}
type Allocation struct {
// The verified client which allocated the DataCap.
Client abi.ActorID
// The provider (miner actor) which may claim the allocation.
Provider abi.ActorID
// Identifier of the data to be committed.
Data cid.Cid
// The (padded) size of data.
Size abi.PaddedPieceSize
// The minimum duration which the provider must commit to storing the piece to avoid
// early-termination penalties (epochs).
TermMin abi.ChainEpoch
// The maximum period for which a provider can earn quality-adjusted power
// for the piece (epochs).
TermMax abi.ChainEpoch
// The latest epoch by which a provider must commit data before the allocation expires.
Expiration abi.ChainEpoch
}
type UniversalReceiverParams struct {
Type_ ReceiverType
Payload []byte
}
type ReceiverType uint64
type AllocationsResponse struct {
AllocationResults BatchReturn
ExtensionResults BatchReturn
NewAllocations []AllocationId
}
type ExtendClaimTermsParams struct {
Terms []ClaimTerm
}
type ClaimTerm struct {
Provider abi.ActorID
ClaimId ClaimId
TermMax abi.ChainEpoch
}
type ExtendClaimTermsReturn BatchReturn
type RemoveExpiredClaimsParams struct {
Provider abi.ActorID
ClaimIds []ClaimId
}
type RemoveExpiredClaimsReturn struct {
Considered []AllocationId
Results BatchReturn
}
type AllocationRequest struct {
// The provider (miner actor) which may claim the allocation.
Provider abi.ActorID
// Identifier of the data to be committed.
Data cid.Cid
// The (padded) size of data.
Size abi.PaddedPieceSize
// The minimum duration which the provider must commit to storing the piece to avoid
// early-termination penalties (epochs).
TermMin abi.ChainEpoch
// The maximum period for which a provider can earn quality-adjusted power
// for the piece (epochs).
TermMax abi.ChainEpoch
// The latest epoch by which a provider must commit data before the allocation expires.
Expiration abi.ChainEpoch
}
type ClaimExtensionRequest struct {
// The provider (miner actor) which may claim the allocation.
Provider abi.ActorID
// Identifier of the claim to be extended.
Claim ClaimId
// The new maximum period for which a provider can earn quality-adjusted power
// for the piece (epochs).
TermMax abi.ChainEpoch
}
type AllocationRequests struct {
Allocations []AllocationRequest
Extensions []ClaimExtensionRequest
}