forked from go-distributed/epaxos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare.go
74 lines (59 loc) · 1.34 KB
/
prepare.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
package message
import (
"fmt"
)
type Prepare struct {
ReplicaId uint8
InstanceId uint64
Ballot *Ballot
From uint8
}
type PrepareReply struct {
ReplicaId uint8
InstanceId uint64
Status uint8
Cmds Commands
Deps Dependencies
Ballot *Ballot
// These two are used for identical non orignal leader pre-accept reply
OriginalBallot *Ballot
IsFromLeader bool
From uint8
}
func (p *Prepare) Sender() uint8 {
return p.From
}
func (p *Prepare) Type() uint8 {
return PrepareMsg
}
func (p *Prepare) Content() interface{} {
return p
}
func (p *Prepare) Replica() uint8 {
return p.ReplicaId
}
func (p *Prepare) Instance() uint64 {
return p.InstanceId
}
func (p *Prepare) String() string {
return fmt.Sprintf("Prepare, Instance[%v][%v], Ballot[%v]", p.ReplicaId, p.InstanceId, p.Ballot.String())
}
func (p *PrepareReply) Sender() uint8 {
return p.From
}
func (p *PrepareReply) Type() uint8 {
return PrepareReplyMsg
}
func (p *PrepareReply) Content() interface{} {
return p
}
func (p *PrepareReply) Replica() uint8 {
return p.ReplicaId
}
func (p *PrepareReply) Instance() uint64 {
return p.InstanceId
}
func (p *PrepareReply) String() string {
return fmt.Sprintf("PrepareReply, Instance[%v][%v], Ballot[%v], Original Ballot[%v]",
p.ReplicaId, p.InstanceId, p.Ballot.String(), p.OriginalBallot.String())
}