-
Notifications
You must be signed in to change notification settings - Fork 25
/
pre_accept.go
105 lines (83 loc) · 1.86 KB
/
pre_accept.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
package message
import (
"fmt"
)
type PreAccept struct {
ReplicaId uint8
InstanceId uint64
Cmds Commands
Deps Dependencies
Ballot *Ballot
From uint8
}
// we don't need ReplicaId in PreAcceptOk,
// because only the leader will receive this message.
type PreAcceptOk struct {
ReplicaId uint8
InstanceId uint64
From uint8
}
type PreAcceptReply struct {
ReplicaId uint8
InstanceId uint64
Deps Dependencies
Ballot *Ballot
From uint8
}
// PreAccept
func (p *PreAccept) Sender() uint8 {
return p.From
}
func (p *PreAccept) Type() uint8 {
return PreAcceptMsg
}
func (p *PreAccept) Content() interface{} {
return p
}
func (p *PreAccept) Replica() uint8 {
return p.ReplicaId
}
func (p *PreAccept) Instance() uint64 {
return p.InstanceId
}
func (p *PreAccept) String() string {
return fmt.Sprintf("PreAccept, Instance[%v][%v], Ballot[%v]", p.ReplicaId, p.InstanceId, p.Ballot.String())
}
// PreAcceptOk
func (p *PreAcceptOk) Sender() uint8 {
return p.From
}
func (p *PreAcceptOk) Type() uint8 {
return PreAcceptOkMsg
}
func (p *PreAcceptOk) Content() interface{} {
return p
}
func (p *PreAcceptOk) Replica() uint8 {
return p.ReplicaId
}
func (p *PreAcceptOk) Instance() uint64 {
return p.InstanceId
}
func (p *PreAcceptOk) String() string {
return fmt.Sprintf("PreAcceptOk, Instance[%v][%v]", p.ReplicaId, p.InstanceId)
}
// PreAcceptReply
func (p *PreAcceptReply) Sender() uint8 {
return p.From
}
func (p *PreAcceptReply) Type() uint8 {
return PreAcceptReplyMsg
}
func (p *PreAcceptReply) Content() interface{} {
return p
}
func (p *PreAcceptReply) Replica() uint8 {
return p.ReplicaId
}
func (p *PreAcceptReply) Instance() uint64 {
return p.InstanceId
}
func (p *PreAcceptReply) String() string {
return fmt.Sprintf("PreAcceptReply, Instance[%v][%v], Ballot[%v]", p.ReplicaId, p.InstanceId, p.Ballot.String())
}