-
Notifications
You must be signed in to change notification settings - Fork 646
/
state.go
43 lines (37 loc) · 1.14 KB
/
state.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
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package uptime
import (
"time"
"github.com/ava-labs/avalanchego/ids"
)
type State interface {
// GetUptime returns [upDuration] and [lastUpdated] of [nodeID] on
// [subnetID].
// Returns [database.ErrNotFound] if [nodeID] isn't currently a validator of
// the subnet.
GetUptime(
nodeID ids.NodeID,
subnetID ids.ID,
) (upDuration time.Duration, lastUpdated time.Time, err error)
// SetUptime updates [upDuration] and [lastUpdated] of [nodeID] on
// [subnetID].
// Returns [database.ErrNotFound] if [nodeID] isn't currently a validator of
// the subnet.
// Invariant: expects [lastUpdated] to be truncated (floored) to the nearest
// second.
SetUptime(
nodeID ids.NodeID,
subnetID ids.ID,
upDuration time.Duration,
lastUpdated time.Time,
) error
// GetStartTime returns the time that [nodeID] started validating
// [subnetID].
// Returns [database.ErrNotFound] if [nodeID] isn't currently a validator of
// the subnet.
GetStartTime(
nodeID ids.NodeID,
subnetID ids.ID,
) (startTime time.Time, err error)
}