fc905a15f7
Now that all the reverification changes have been made and the old code is out of the way, this commit renames the new things back to the old names. Mostly, this involves renaming "newContainment" to "containment" or "NewContainment" to "Containment", but there are a few other renames that have been promised and are carried out here. Refs: https://github.com/storj/storj/issues/5230 Change-Id: I34e2b857ea338acbb8421cdac18b17f2974f233c
59 lines
1.8 KiB
Go
59 lines
1.8 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package satellitedb
|
|
|
|
import (
|
|
"context"
|
|
|
|
"storj.io/common/pb"
|
|
"storj.io/storj/satellite/audit"
|
|
)
|
|
|
|
type containment struct {
|
|
reverifyQueue audit.ReverifyQueue
|
|
}
|
|
|
|
var _ audit.Containment = &containment{}
|
|
|
|
// Get gets a pending reverification audit by node id. If there are
|
|
// multiple pending reverification audits, an arbitrary one is returned.
|
|
// If there are none, an error wrapped by audit.ErrContainedNotFound is
|
|
// returned.
|
|
func (containment *containment) Get(ctx context.Context, id pb.NodeID) (_ *audit.ReverificationJob, err error) {
|
|
defer mon.Task()(&ctx)(&err)
|
|
if id.IsZero() {
|
|
return nil, audit.ContainError.New("node ID empty")
|
|
}
|
|
|
|
return containment.reverifyQueue.GetByNodeID(ctx, id)
|
|
}
|
|
|
|
// Insert creates a new pending audit entry.
|
|
func (containment *containment) Insert(ctx context.Context, pendingJob *audit.PieceLocator) (err error) {
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
return containment.reverifyQueue.Insert(ctx, pendingJob)
|
|
}
|
|
|
|
// Delete removes a job from the reverification queue, whether because the job
|
|
// was successful or because the job is no longer necessary. The wasDeleted
|
|
// return value indicates whether the indicated job was actually deleted (if
|
|
// not, there was no such job in the queue).
|
|
func (containment *containment) Delete(ctx context.Context, pendingJob *audit.PieceLocator) (isDeleted, nodeStillContained bool, err error) {
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
isDeleted, err = containment.reverifyQueue.Remove(ctx, pendingJob)
|
|
if err != nil {
|
|
return false, false, audit.ContainError.Wrap(err)
|
|
}
|
|
|
|
nodeStillContained = true
|
|
_, err = containment.reverifyQueue.GetByNodeID(ctx, pendingJob.NodeID)
|
|
if audit.ErrContainedNotFound.Has(err) {
|
|
nodeStillContained = false
|
|
err = nil
|
|
}
|
|
return isDeleted, nodeStillContained, audit.ContainError.Wrap(err)
|
|
}
|