-
Notifications
You must be signed in to change notification settings - Fork 2
/
proto.go
51 lines (43 loc) · 943 Bytes
/
proto.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 paxos implements different variants of paxos algorithm.
package paxos
import (
"encoding/gob"
)
func init() {
gob.Register(Prepare{})
gob.Register(Promise{})
gob.Register(Accept{})
gob.Register(Accepted{})
gob.Register(Decided{})
gob.Register(Nack{})
gob.Register(Ballot{})
}
// Prepare request
type Prepare struct {
Ballot *Ballot
}
// Promise response to a Prepare request
type Promise struct {
Ballot *Ballot
Accepted *Ballot
Val interface{} // The associated value
}
// Accept request
type Accept struct {
Ballot *Ballot
Val interface{} // The associated value
}
// Accepted response to an Accept request
type Accepted struct {
Ballot *Ballot
Val interface{} // The associated value
}
// Decided message to broadcast the decided value
type Decided struct {
Ballot *Ballot
Val interface{} // The associated value
}
// Nack is a NotOK acknowledgement
type Nack struct {
Ballot *Ballot
}