-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmsg.go
47 lines (39 loc) · 861 Bytes
/
msg.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
package consensus
import (
"encoding/gob"
"fmt"
"github.com/salemmohammed/BigBFT"
)
func init() {
gob.Register(Propose{})
gob.Register(Vote{})
}
type Propose struct {
Ballot BigBFT.Ballot
Request BigBFT.Request
Command BigBFT.Command
Slot int
ID BigBFT.ID
Leader bool
}
func (m Propose) String() string {
return fmt.Sprintf("Propose {b=%v Command=%v slot=%v Leader=%v}", m.Ballot, m.Command, m.Slot, m.Leader)
}
type Vote struct {
Slot int
Id BigBFT.ID
L map[int]*CommandBallot
}
func (m Vote) String() string {
return fmt.Sprintf("Vote {L=%v}", m.L)
}
// CommandBallot conbines each command with its ballot number
type CommandBallot struct {
//Request BigBFT.Request
Command BigBFT.Command
Slot int
Id BigBFT.ID
}
func (cb CommandBallot) String() string {
return fmt.Sprintf("cmd=%v s=%v", cb.Command, cb.Slot)
}