forked from forbole/callisto
-
Notifications
You must be signed in to change notification settings - Fork 1
/
consensus.go
51 lines (43 loc) · 1.35 KB
/
consensus.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
44
45
46
47
48
49
50
51
package types
import "time"
// Genesis contains the useful information about the genesis
type Genesis struct {
ChainID string
Time time.Time
InitialHeight int64
}
// NewGenesis allows to build a new Genesis instance
func NewGenesis(chainID string, startTime time.Time, initialHeight int64) *Genesis {
return &Genesis{
ChainID: chainID,
Time: startTime,
InitialHeight: initialHeight,
}
}
// Equal returns true iff g and other contain the same data
func (g *Genesis) Equal(other *Genesis) bool {
return g.ChainID == other.ChainID &&
g.Time.Equal(other.Time) &&
g.InitialHeight == other.InitialHeight
}
// ------------------------------------------------------------------------------------------------------------------
// ConsensusEvent represents a consensus event
type ConsensusEvent struct {
Height int64 `json:"height"`
Round int32 `json:"round"`
Step string `json:"step"`
}
// NewConsensusEvent allows to easily build a new ConsensusEvent object
func NewConsensusEvent(height int64, round int32, step string) *ConsensusEvent {
return &ConsensusEvent{
Height: height,
Round: round,
Step: step,
}
}
// Equal tells whether c and other contain the same data
func (c ConsensusEvent) Equal(other ConsensusEvent) bool {
return c.Height == other.Height &&
c.Round == other.Round &&
c.Step == other.Step
}