-
Notifications
You must be signed in to change notification settings - Fork 394
/
common.go
35 lines (28 loc) · 1.22 KB
/
common.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
// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package nodeapiversion
import (
"context"
"storj.io/common/storj"
)
// Version represents a node api version.
type Version int
// These constants describe versions of satellite APIs. You should add one when
// you are creating a feature that needs "ratcheting" behavior, meaning the node
// should no longer be allowed to use an old API after it has started using a
// new API. Later constants always imply earlier constants.
const (
// HasAnything is the base case that every node will have.
HasAnything Version = iota
HasWindowedOrders
)
// DB is the interface to interact with the node api version database.
type DB interface {
// UpdateVersionAtLeast sets the node version to be at least the passed in version.
// Any existing entry for the node will never have the version decreased.
UpdateVersionAtLeast(ctx context.Context, id storj.NodeID, version Version) error
// VersionAtLeast returns true iff the recorded node version is greater than or equal
// to the passed in version. VersionAtLeast always returns true if the passed in version
// is HasAnything.
VersionAtLeast(ctx context.Context, id storj.NodeID, version Version) (bool, error)
}