Documentation
¶
Index ¶
- Constants
- Variables
- func DataSetRefusesWrites(err error) bool
- func ExtraDataNonce(extraData []byte) (sdktypes.BigInt, error)
- func MaxPieces(dataSetID idtypes.OnChainID, legacyPieceStorageIDLimit uint64, configured int) int
- func NewRequestID() (string, error)
- func ShouldSeal(in SealInput) (bool, time.Duration)
- type Advancer
- func (a *Advancer) Observe(ctx context.Context, c Commit) (observation Observation, observeErr error)
- func (a *Advancer) Prepare(ctx context.Context, c Commit) Prepared
- func (a *Advancer) Prove(ctx context.Context, c Commit) (Proof, error)
- func (a *Advancer) Send(ctx context.Context, c Commit, onSubmitted func(storage.CommitSubmission)) SendResult
- type AttentionCode
- type AttentionRecord
- type Commit
- type Confirmation
- type Observation
- type ObserveKind
- type PrepareOutcome
- type Prepared
- type Proof
- type ProofOutcome
- type Request
- type RequestPiece
- type RequestStatus
- type SealInput
- type SendKind
- type SendResult
Constants ¶
const ( DefaultRequestTimeout = 15 * time.Second DefaultAttentionAfter = 15 * time.Minute )
const CommitQueueWaitReason = "commit_queue"
CommitQueueWaitReason marks collection waiting for the submission queue.
const MaxSubmittedRequestsPerDataSet = 4
MaxSubmittedRequestsPerDataSet bounds the requests of one data set that may be on chain without a known outcome.
const ProviderRejectedWaitReason = "provider_rejected"
ProviderRejectedWaitReason is the wait reason of a request backing off after the provider refused it.
Variables ¶
var ErrNotEligible = errors.New("storage commit request cannot be sent yet")
ErrNotEligible means a ready request cannot be sent yet: its data set has no room, an older request goes first, it is backing off, or a member is still being transferred.
Functions ¶
func DataSetRefusesWrites ¶
DataSetRefusesWrites reports whether err means the data set will not accept a commit, because its storage service ended or its PDP payment did. Both are read from the chain before the provider is contacted.
func ExtraDataNonce ¶
ExtraDataNonce returns the nonce an add-pieces authorization was signed with. FWSS accepts each nonce once per payer, so it names every submission of the same signed request on chain.
func MaxPieces ¶
MaxPieces is how many pieces one request to the data set may carry. Data sets below the deployment's compact cutoff keep the legacy piece limit; every request also stays within the add-pieces message size, which the configured maximum is validated against.
func NewRequestID ¶
NewRequestID returns a random identifier for a new commit request.
Types ¶
type Advancer ¶
type Advancer struct {
// Nonces reads the chain record that proves where a request's pieces landed.
Nonces synapse.CommitNonceReader
RequestTimeout time.Duration
AttentionAfter time.Duration
Now func() time.Time
}
Advancer decides what a request needs next from the provider's answers and the chain. It writes nothing: the caller records every outcome under its task fence.
func (*Advancer) Observe ¶
func (a *Advancer) Observe(ctx context.Context, c Commit) (observation Observation, observeErr error)
Observe resolves a submitted request. The provider's receipt is only a hint: a request is confirmed by its nonce record, and when the provider cannot answer, disagrees, or rejects it, the chain decides.
func (*Advancer) Prepare ¶
Prepare checks a ready request before it is sent. The nonce is read first: an earlier send may already be on chain, and FWSS rejects a reused nonce.
func (*Advancer) Prove ¶
Prove reads the request's FWSS nonce record. FWSS accepts a nonce once per payer and records `(next piece ID << 128) | data set ID`, so a consumed nonce names the piece IDs every send of the request could have produced. Every position is checked against PDPVerifier; a read that fails proves nothing.
func (*Advancer) Send ¶
func (a *Advancer) Send(ctx context.Context, c Commit, onSubmitted func(storage.CommitSubmission)) SendResult
Send submits the request's signed authorization once. onSubmitted runs when the SDK announces the provider's submission, whatever the call returns.
type AttentionCode ¶
type AttentionCode string
AttentionCode identifies a submitted request that needs operator review.
const ( // AttentionSubmissionMismatch means the request's nonce was consumed by // pieces other than the request's own. Nothing more is sent. AttentionSubmissionMismatch AttentionCode = "submission_mismatch" // reached while a send of it may still land. Recovery keeps checking. AttentionDataSetUnavailable AttentionCode = "data_set_unavailable" // AttentionConfirmationTimeout means the request is still unregistered past // the attention threshold. Recovery keeps checking it, and sends it again // whenever no reply from the provider can settle it. AttentionConfirmationTimeout AttentionCode = "confirmation_timeout" )
func ParseAttentionCode ¶
func ParseAttentionCode(value string) (AttentionCode, error)
func (AttentionCode) Valid ¶
func (c AttentionCode) Valid() bool
type AttentionRecord ¶
type AttentionRecord struct {
RequestID string
TaskID *int64
DataSetRowID int64
ProviderID string
DataSetID string
PieceCIDs []string
TxHash *string
ConfirmedTxHash *string
SubmitError string
Code AttentionCode
SubmittedAt time.Time
AttentionAt time.Time
}
AttentionRecord describes one submitted request flagged for operator attention.
type Commit ¶
type Commit struct {
Request Request
// Pieces are the request's piece CIDs in position order.
Pieces []cid.Cid
Target synapse.DataSetTarget
}
Commit is one request as the advancer acts on it.
type Confirmation ¶
type Confirmation struct {
// TxHash is the request's latest recorded submission, if any.
TxHash string
// ConfirmedTxHash is set only when the provider reported the
// transaction that included the pieces. A request proven by its nonce alone
// may have landed in a different send.
ConfirmedTxHash string
FirstPieceID sdktypes.BigInt
}
Confirmation is the chain proof of a request with the submission evidence that accompanied it.
type Observation ¶
type Observation struct {
Kind ObserveKind
Confirmation *Confirmation
// Attention, when set, is flagged on the request with this observation.
Attention AttentionCode
// DropEvidence clears the recorded transaction and status URL: the
// provider's receipt for them did not describe this request.
DropEvidence bool
Cause error
Diagnostic error
}
type ObserveKind ¶
type ObserveKind uint8
ObserveKind is what a submitted request needs next.
const ( // ObservePending means the request needs another observation. ObservePending ObserveKind = iota // ObserveConfirmed means the chain proves the request. ObserveConfirmed // ObserveResendDue means nothing of the request is on chain and it can be // submitted under its original authorization. ObserveResendDue // ObserveStop means the request's nonce was consumed by other pieces. // Nothing more is sent until an operator recovers it. ObserveStop // ObserveAbandon means the data set no longer accepts writes and nothing of // the request is on chain. ObserveAbandon )
type PrepareOutcome ¶
type PrepareOutcome uint8
PrepareOutcome is what a ready request may do next.
const ( // PrepareSend means nothing of the request is on chain and its data set // accepts writes. PrepareSend PrepareOutcome = iota // PrepareConfirmed means an earlier send already landed. PrepareConfirmed // PrepareConflict means the request's nonce was consumed by other pieces. PrepareConflict // PrepareAbandon means the data set no longer accepts writes, so the request // can never land. PrepareAbandon // PrepareRetry means the chain could not be read. PrepareRetry )
type Prepared ¶
type Prepared struct {
Outcome PrepareOutcome
Proof Proof
Cause error
}
type Proof ¶
type Proof struct {
Outcome ProofOutcome
FirstPieceID sdktypes.BigInt
}
type ProofOutcome ¶
type ProofOutcome uint8
ProofOutcome is what the chain says about a request's nonce.
const ( // ProofUnused means the nonce was not consumed: no send of the request has // landed. ProofUnused ProofOutcome = iota // ProofLanded means the request's pieces are on chain, in order, at // consecutive IDs of its data set. ProofLanded // ProofConflict means the nonce was consumed somewhere other than the // request's pieces in its data set, or the request cannot be read. ProofConflict )
type Request ¶
type Request struct {
bun.BaseModel `bun:"table:storage_commit_requests,alias:commit_request"`
RequestID string `bun:"request_id,type:text,pk"`
StorageDataSetID int64 `bun:"storage_data_set_id,notnull"`
Status RequestStatus `bun:"status,type:text,notnull"`
TaskID *int64 `bun:"task_id,nullzero"`
PieceCount int `bun:"piece_count,type:integer,notnull"`
ExtraDataHex *string `bun:"extra_data_hex,type:text,nullzero"`
SealedAt *time.Time `bun:"sealed_at,nullzero"`
FirstSentAt *time.Time `bun:"first_sent_at,nullzero"`
Sends int `bun:"sends,type:integer,notnull"`
SubmittedAt *time.Time `bun:"submitted_at,nullzero"`
LastSentAt *time.Time `bun:"last_sent_at,nullzero"`
TxHash *string `bun:"tx_hash,type:text,nullzero"`
StatusURL *string `bun:"status_url,type:text,nullzero"`
SubmitError *string `bun:"submit_error,type:text,nullzero"`
Refusals int `bun:"refusals,type:integer,notnull"`
RetryAt *time.Time `bun:"retry_at,nullzero"`
FirstPieceID *idtypes.OnChainID `bun:"first_piece_id,type:text"`
ConfirmedTxHash *string `bun:"confirmed_tx_hash,type:text,nullzero"`
ConfirmedAt *time.Time `bun:"confirmed_at,nullzero"`
LastError *string `bun:"last_error,type:text,nullzero"`
AttentionCode *string `bun:"attention_code,type:text,nullzero"`
AttentionAt *time.Time `bun:"attention_at,nullzero"`
CreatedAt time.Time `bun:"created_at,nullzero,notnull"`
UpdatedAt time.Time `bun:"updated_at,nullzero,notnull"`
SealRequestedAt *time.Time `bun:"seal_requested_at,nullzero"`
}
Request records one signed add-pieces authorization and its submission and confirmation evidence. It outlives the copies it registers.
func (*Request) BeforeAppendModel ¶
BeforeAppendModel stamps the audit columns on insert. The database has no timestamp default, so every row is written with one encoding instead of two that sort against each other inside the same second.
type RequestPiece ¶
type RequestPiece struct {
bun.BaseModel `bun:"table:storage_commit_request_pieces"`
ID int64 `bun:"id,pk,autoincrement,identity"`
RequestID string `bun:"request_id,type:text,notnull"`
Position int `bun:"position,type:integer,notnull"`
ContentID int64 `bun:"content_id,notnull"`
StorageDataSetID int64 `bun:"storage_data_set_id,notnull"`
PieceCID string `bun:"piece_cid,type:text,notnull"`
CreatedAt time.Time `bun:"created_at,nullzero,notnull"`
}
RequestPiece names one piece of a sealed request at its position.
func (*RequestPiece) BeforeAppendModel ¶
type RequestStatus ¶
type RequestStatus string
RequestStatus is the lifecycle of one signed add-pieces request.
const ( // RequestStatusCollecting gathers transferred copies of one data set. Nothing // has been signed, so members can still leave. RequestStatusCollecting RequestStatus = "collecting" // RequestStatusReady is signed. No send of it can be pending. RequestStatusReady RequestStatus = "ready" // RequestStatusSubmitted has been sent at least once in this period, and a // send may still land. RequestStatusSubmitted RequestStatus = "submitted" // RequestStatusConfirmed is proven on chain. RequestStatusConfirmed RequestStatus = "confirmed" // RequestStatusAbandoned can never land. RequestStatusAbandoned RequestStatus = "abandoned" )
func (RequestStatus) Terminal ¶
func (s RequestStatus) Terminal() bool
Terminal reports whether the request has been settled.
func (RequestStatus) Valid ¶
func (s RequestStatus) Valid() bool
type SealInput ¶
type SealInput struct {
Members int
// OldestJoinedAt is when the longest-waiting member became ready.
OldestJoinedAt time.Time
Now time.Time
MaxPieces int
MaxWait time.Duration
// Draining means the data set takes no new copies.
Draining bool
CachePressure bool
ManualRequested bool
}
SealInput is what decides whether a collecting request is eligible to be signed.
type SendKind ¶
type SendKind uint8
SendKind classifies what one SubmitCommit call left behind.
const ( // SendAccepted means the provider returned a submission. SendAccepted SendKind = iota // SendRefused means the provider answered with a 4xx. Curio answers every // add-pieces 4xx before sending that call's transaction. SendRefused // SendNotSent means the SDK refused the data set before contacting the // provider. SendNotSent // SendUnknown means a transaction may exist. SendUnknown )
type SendResult ¶
type SendResult struct {
Kind SendKind
Submission *storage.CommitSubmission
Err error
}