-
Notifications
You must be signed in to change notification settings - Fork 9
/
state.go
33 lines (27 loc) · 1023 Bytes
/
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
package chainload
import metrics "github.com/rcrowley/go-metrics"
type state metrics.Counter
type stateTracker struct {
state
}
func (s *stateTracker) transition(to state) state {
if s.state != nil {
s.Dec(1)
}
last := s.state
s.state = to
if s.state != nil {
s.Inc(1)
}
return last
}
var (
seederCollectState state = metrics.GetOrRegisterCounter("state/seeder/collect", nil)
seederEnsureFundsState state = metrics.GetOrRegisterCounter("state/seeder/ensureFunds", nil)
seederSeedState state = metrics.GetOrRegisterCounter("state/seeder/seed", nil)
seederUpdateNonceState state = metrics.GetOrRegisterCounter("state/seeder/updateNonce", nil)
senderAssignState state = metrics.GetOrRegisterCounter("state/sender/assign", nil)
senderUpdateGasState state = metrics.GetOrRegisterCounter("state/sender/updateGas", nil)
senderSendState state = metrics.GetOrRegisterCounter("state/sender/send", nil)
senderSeedState state = metrics.GetOrRegisterCounter("state/sender/seed", nil)
)