usedserials

package
v1.75.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 20, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PartialSize is the size of a partial serial number.
	PartialSize = memory.Size(len(Partial{}))
	// FullSize is the size of a full serial number.
	FullSize = memory.Size(len(storj.SerialNumber{}))
)

Variables

View Source
var (
	// ErrSerials defines the usedserials store error class.
	ErrSerials = errs.Class("usedserials")
	// ErrSerialAlreadyExists defines an error class for duplicate usedserials.
	ErrSerialAlreadyExists = errs.Class("used serial already exists in store")
)

Functions

This section is empty.

Types

type Full

type Full storj.SerialNumber

Full is a copy of the SerialNumber type. It is necessary so we can define a Less function on it.

func (Full) Less

func (a Full) Less(b Full) bool

Less returns true if partial serial a is less than partial serial b and false otherwise.

type Partial

type Partial [8]byte

Partial represents the last 8 bytes of a serial number. It is used when the first 8 are based on the expiration date.

func (Partial) Less

func (a Partial) Less(b Partial) bool

Less returns true if partial serial a is less than partial serial b and false otherwise.

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table is an in-memory store for serial numbers.

func NewTable

func NewTable(maxMemory memory.Size) *Table

NewTable creates and returns a new usedserials in-memory store.

func (*Table) Add

func (table *Table) Add(satelliteID storj.NodeID, serialNumber storj.SerialNumber, expiration time.Time) error

Add adds a serial to the store, or returns an error if the serial number was already added. It randomly deletes items from the store if the set maxMemory is exceeded.

func (*Table) Count

func (table *Table) Count() int

Count iterates over all the items in the table and returns the number.

func (*Table) DeleteExpired

func (table *Table) DeleteExpired(now time.Time)

DeleteExpired deletes expired serial numbers if their expiration hour has passed.

func (*Table) Exists

func (table *Table) Exists(satelliteID storj.NodeID, serialNumber storj.SerialNumber, expiration time.Time) bool

Exists determines whether a serial number exists in the table.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL