2019-03-18 10:55:06 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package piecestore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"storj.io/storj/pkg/storj"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SerialNumberFn is callback from IterateAll
|
2019-03-18 13:08:24 +00:00
|
|
|
type SerialNumberFn func(satelliteID storj.NodeID, serialNumber storj.SerialNumber, expiration time.Time)
|
2019-03-18 10:55:06 +00:00
|
|
|
|
|
|
|
// UsedSerials is a persistent store for serial numbers.
|
|
|
|
// TODO: maybe this should be in orders.UsedSerials
|
|
|
|
type UsedSerials interface {
|
|
|
|
// Add adds a serial to the database.
|
2019-03-18 13:08:24 +00:00
|
|
|
Add(ctx context.Context, satelliteID storj.NodeID, serialNumber storj.SerialNumber, expiration time.Time) error
|
2019-03-18 10:55:06 +00:00
|
|
|
// DeleteExpired deletes expired serial numbers
|
|
|
|
DeleteExpired(ctx context.Context, now time.Time) error
|
|
|
|
|
|
|
|
// IterateAll iterates all serials.
|
|
|
|
// Note, this will lock the database and should only be used during startup.
|
|
|
|
IterateAll(ctx context.Context, fn SerialNumberFn) error
|
|
|
|
}
|