github.com/MetalBlockchain/metalgo@v1.11.9/snow/uptime/state.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package uptime 5 6 import ( 7 "time" 8 9 "github.com/MetalBlockchain/metalgo/ids" 10 ) 11 12 type State interface { 13 // GetUptime returns [upDuration] and [lastUpdated] of [nodeID] on 14 // [subnetID]. 15 // Returns [database.ErrNotFound] if [nodeID] isn't currently a validator of 16 // the subnet. 17 GetUptime( 18 nodeID ids.NodeID, 19 subnetID ids.ID, 20 ) (upDuration time.Duration, lastUpdated time.Time, err error) 21 22 // SetUptime updates [upDuration] and [lastUpdated] of [nodeID] on 23 // [subnetID]. 24 // Returns [database.ErrNotFound] if [nodeID] isn't currently a validator of 25 // the subnet. 26 // Invariant: expects [lastUpdated] to be truncated (floored) to the nearest 27 // second. 28 SetUptime( 29 nodeID ids.NodeID, 30 subnetID ids.ID, 31 upDuration time.Duration, 32 lastUpdated time.Time, 33 ) error 34 35 // GetStartTime returns the time that [nodeID] started validating 36 // [subnetID]. 37 // Returns [database.ErrNotFound] if [nodeID] isn't currently a validator of 38 // the subnet. 39 GetStartTime( 40 nodeID ids.NodeID, 41 subnetID ids.ID, 42 ) (startTime time.Time, err error) 43 }