Skip to content

Commit 6d3e04a

Browse files
committed
clean api
1 parent 1f66c4f commit 6d3e04a

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

ballot_protocol.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (b *ballotProtocol) prepareVoted(m *Message) {
122122
//fmt.Println(b.id, "see", m.NodeID, "has voted prepare", m.SlotIndex, m.Counter, string(m.Value))
123123

124124
b.updateBallotCounter(m.NodeID, m.Counter)
125-
ballot := b.ballots.FindOrCreate(m.SlotIndex, m.Counter, m.Value, b.quorumSlices)
125+
ballot := b.ballots.findOrCreate(m.SlotIndex, m.Counter, m.Value, b.quorumSlices)
126126
ballot.prepare.votedBy(m.NodeID)
127127

128128
if !ballot.prepare.accepted && ballot.prepare.votes.reachedQuorumThreshold(b.quorumSlices) {
@@ -133,7 +133,7 @@ func (b *ballotProtocol) prepareVoted(m *Message) {
133133
func (b *ballotProtocol) prepareAccepted(m *Message) {
134134
//fmt.Println(b.id, "see", m.NodeID, "has accepted prepare", m.SlotIndex, m.Counter, string(m.Value))
135135
b.updateBallotCounter(m.NodeID, m.Counter)
136-
ballot := b.ballots.FindOrCreate(m.SlotIndex, m.Counter, m.Value, b.quorumSlices)
136+
ballot := b.ballots.findOrCreate(m.SlotIndex, m.Counter, m.Value, b.quorumSlices)
137137
ballot.prepare.acceptedBy(m.NodeID)
138138

139139
if !ballot.prepare.accepted && ballot.prepare.accepts.reachedBlockingThreshold(b.quorumSlices) {
@@ -148,7 +148,7 @@ func (b *ballotProtocol) prepareAccepted(m *Message) {
148148
func (b *ballotProtocol) commitVoted(m *Message) {
149149
//fmt.Println(b.id, "see", m.NodeID, "has voted commit", m.SlotIndex, m.Counter, string(m.Value))
150150
b.updateBallotCounter(m.NodeID, m.Counter)
151-
ballot := b.ballots.FindOrCreate(m.SlotIndex, m.Counter, m.Value, b.quorumSlices)
151+
ballot := b.ballots.findOrCreate(m.SlotIndex, m.Counter, m.Value, b.quorumSlices)
152152
ballot.commit.votedBy(m.NodeID)
153153

154154
if !ballot.commit.accepted && ballot.commit.votes.reachedQuorumThreshold(b.quorumSlices) {
@@ -159,7 +159,7 @@ func (b *ballotProtocol) commitVoted(m *Message) {
159159
func (b *ballotProtocol) commitAccepted(m *Message) {
160160
//fmt.Println(b.id, "see", m.NodeID, "has accepted commit", m.SlotIndex, m.Counter, string(m.Value))
161161
b.updateBallotCounter(m.NodeID, m.Counter)
162-
ballot := b.ballots.FindOrCreate(m.SlotIndex, m.Counter, m.Value, b.quorumSlices)
162+
ballot := b.ballots.findOrCreate(m.SlotIndex, m.Counter, m.Value, b.quorumSlices)
163163
ballot.commit.acceptedBy(m.NodeID)
164164

165165
if !ballot.commit.accepted && ballot.commit.accepts.reachedBlockingThreshold(b.quorumSlices) {
@@ -172,7 +172,7 @@ func (b *ballotProtocol) commitAccepted(m *Message) {
172172
}
173173

174174
func (b *ballotProtocol) votePrepare() {
175-
ballot := b.ballots.FindOrCreate(
175+
ballot := b.ballots.findOrCreate(
176176
b.currentBallot.slotIndex,
177177
b.currentBallot.counter,
178178
b.currentBallot.value,

ballots.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func newBallots() ballots {
5353
}
5454
}
5555

56-
func (b ballots) FindOrCreate(slotIndex uint64, counter uint32, value Value, slices quorumSlices) *ballot {
56+
func (b ballots) findOrCreate(slotIndex uint64, counter uint32, value Value, slices quorumSlices) *ballot {
5757
bal := &ballot{slotIndex: slotIndex, counter: counter, value: value}
5858
if item := b.btree.Get(bal); item != nil {
5959
return item.(*ballot)

nominates.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,24 @@ func newNominates() nominates {
2323
return nominates{btree.New(100)}
2424
}
2525

26-
func (n nominates) FindOrCreate(value Value, slices quorumSlices) *nominate {
27-
nom := n.Find(value)
26+
func (n nominates) findOrCreate(value Value, slices quorumSlices) *nominate {
27+
nom := n.find(value)
2828
if nom == nil {
29-
nom = n.Create(value, slices)
29+
nom = n.create(value, slices)
3030
}
3131

3232
return nom
3333
}
3434

35-
func (n nominates) Find(value Value) *nominate {
35+
func (n nominates) find(value Value) *nominate {
3636
if item := n.btree.Get(&nominate{value: value}); item != nil {
3737
return item.(*nominate)
3838
}
3939

4040
return nil
4141
}
4242

43-
func (n nominates) Create(value Value, slices quorumSlices) *nominate {
43+
func (n nominates) create(value Value, slices quorumSlices) *nominate {
4444
nominate := &nominate{
4545
value: value,
4646
ratification: newRatification(),

nomination_protocol.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ func (n *nominationProtocol) considerProposal(v Value) {
4646
return
4747
}
4848

49-
if nominate := n.nominates.Find(v); nominate == nil {
50-
nominate = n.nominates.Create(v, n.quorumSlices)
49+
if nominate := n.nominates.find(v); nominate == nil {
50+
nominate = n.nominates.create(v, n.quorumSlices)
5151
n.voteNominate(nominate)
5252
}
5353
}
@@ -87,12 +87,12 @@ func (n *nominationProtocol) reinit(m protocolMessage) {
8787
}
8888

8989
func (n *nominationProtocol) nominateVoted(m *Message) {
90-
nominate := n.nominates.Find(m.Value)
90+
nominate := n.nominates.find(m.Value)
9191
if nominate == nil {
9292
if !n.validator.ValidateValue(m.Value) {
9393
return
9494
}
95-
nominate = n.nominates.Create(m.Value, n.quorumSlices)
95+
nominate = n.nominates.create(m.Value, n.quorumSlices)
9696
n.voteNominate(nominate)
9797
}
9898

@@ -104,7 +104,7 @@ func (n *nominationProtocol) nominateVoted(m *Message) {
104104

105105
func (n *nominationProtocol) nominateAccepted(m *Message) {
106106
//fmt.Println(n.id, "see", m.NodeID, "has accepted nominate", m.SlotIndex, string(m.Value))
107-
nominate := n.nominates.FindOrCreate(m.Value, n.quorumSlices)
107+
nominate := n.nominates.findOrCreate(m.Value, n.quorumSlices)
108108
nominate.acceptedBy(m.NodeID)
109109

110110
if !nominate.accepted && nominate.accepts.reachedBlockingThreshold(n.quorumSlices) {

0 commit comments

Comments
 (0)