-
Notifications
You must be signed in to change notification settings - Fork 402
/
containment.go
47 lines (37 loc) · 1.4 KB
/
containment.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
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package audit
import (
"context"
"github.com/zeebo/errs"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/storj"
)
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")
// ErrAlreadyExists is the errs class for when a pending audit with the same nodeID but different share data already exists
ErrAlreadyExists = errs.Class("pending audit already exists for nodeID")
)
// PendingAudit contains info needed for retrying an audit for a contained node
type PendingAudit struct {
NodeID storj.NodeID
PieceID storj.PieceID
StripeIndex int64
ShareSize int32
ExpectedShareHash []byte
ReverifyCount int32
Path storj.Path
}
// Containment holds information about pending audits for contained nodes
//
// architecture: Database
type Containment interface {
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)
}