2019-05-22 15:50:22 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package audit
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/zeebo/errs"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/pb"
|
|
|
|
"storj.io/common/storj"
|
2019-05-22 15:50:22 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// ContainError is the containment errs class
|
|
|
|
ContainError = errs.Class("containment error")
|
|
|
|
|
|
|
|
// ErrContainedNotFound is the errs class for when a pending audit isn't found
|
|
|
|
ErrContainedNotFound = errs.Class("pending audit not found")
|
|
|
|
|
|
|
|
// ErrContainDelete is the errs class for when a pending audit can't be deleted
|
|
|
|
ErrContainDelete = errs.Class("unable to delete pending audit")
|
|
|
|
)
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// PendingAudit contains info needed for retrying an audit for a contained node.
|
2019-05-22 15:50:22 +01:00
|
|
|
type PendingAudit struct {
|
|
|
|
NodeID storj.NodeID
|
|
|
|
PieceID storj.PieceID
|
2019-05-23 21:07:19 +01:00
|
|
|
StripeIndex int64
|
|
|
|
ShareSize int32
|
2019-05-22 15:50:22 +01:00
|
|
|
ExpectedShareHash []byte
|
2019-05-23 21:07:19 +01:00
|
|
|
ReverifyCount int32
|
2019-07-18 19:08:15 +01:00
|
|
|
Path storj.Path
|
2019-05-22 15:50:22 +01:00
|
|
|
}
|
|
|
|
|
2019-05-23 15:37:23 +01:00
|
|
|
// Containment holds information about pending audits for contained nodes
|
2019-09-10 14:24:16 +01:00
|
|
|
//
|
|
|
|
// architecture: Database
|
2019-05-23 15:37:23 +01:00
|
|
|
type Containment interface {
|
2019-05-22 15:50:22 +01:00
|
|
|
Get(ctx context.Context, nodeID pb.NodeID) (*PendingAudit, error)
|
|
|
|
IncrementPending(ctx context.Context, pendingAudit *PendingAudit) error
|
|
|
|
Delete(ctx context.Context, nodeID pb.NodeID) (bool, error)
|
|
|
|
}
|