forked from solarlabsteam/missed-blocks-checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
41 lines (33 loc) · 768 Bytes
/
types.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
package main
import "time"
type Direction int
const (
START_MISSING_BLOCKS Direction = iota
MISSING_BLOCKS
STOPPED_MISSING_BLOCKS
WENT_BACK_TO_NORMAL
JAILED
)
type ReportEntry struct {
ValidatorAddress string
ValidatorMoniker string
Pubkey string
Direction Direction
BeforeBlocksMissing int64
NowBlocksMissing int64
}
func (r ReportEntry) GetTimeToJail() time.Duration {
blocksLeftToJail := MissedBlocksToJail - r.NowBlocksMissing
secondsLeftToJail := AvgBlockTime * float64(blocksLeftToJail)
return time.Duration(secondsLeftToJail) * time.Second
}
type Report struct {
Entries []ReportEntry
}
type Reporter interface {
Serialize(Report) string
Init()
Enabled() bool
SendReport(Report) error
Name() string
}