VOL-2112 move to voltha-lib-go
Change-Id: Ic1af08003c1d2c698c0cce371e64f47b47b8d875
diff --git a/vendor/go.etcd.io/etcd/raft/read_only.go b/vendor/go.etcd.io/etcd/raft/read_only.go
index aecc6b2..6987f1b 100644
--- a/vendor/go.etcd.io/etcd/raft/read_only.go
+++ b/vendor/go.etcd.io/etcd/raft/read_only.go
@@ -29,7 +29,11 @@
type readIndexStatus struct {
req pb.Message
index uint64
- acks map[uint64]struct{}
+ // NB: this never records 'false', but it's more convenient to use this
+ // instead of a map[uint64]struct{} due to the API of quorum.VoteResult. If
+ // this becomes performance sensitive enough (doubtful), quorum.VoteResult
+ // can change to an API that is closer to that of CommittedIndex.
+ acks map[uint64]bool
}
type readOnly struct {
@@ -50,26 +54,25 @@
// the read only request.
// `m` is the original read only request message from the local or remote node.
func (ro *readOnly) addRequest(index uint64, m pb.Message) {
- ctx := string(m.Entries[0].Data)
- if _, ok := ro.pendingReadIndex[ctx]; ok {
+ s := string(m.Entries[0].Data)
+ if _, ok := ro.pendingReadIndex[s]; ok {
return
}
- ro.pendingReadIndex[ctx] = &readIndexStatus{index: index, req: m, acks: make(map[uint64]struct{})}
- ro.readIndexQueue = append(ro.readIndexQueue, ctx)
+ ro.pendingReadIndex[s] = &readIndexStatus{index: index, req: m, acks: make(map[uint64]bool)}
+ ro.readIndexQueue = append(ro.readIndexQueue, s)
}
// recvAck notifies the readonly struct that the raft state machine received
// an acknowledgment of the heartbeat that attached with the read only request
// context.
-func (ro *readOnly) recvAck(m pb.Message) int {
- rs, ok := ro.pendingReadIndex[string(m.Context)]
+func (ro *readOnly) recvAck(id uint64, context []byte) map[uint64]bool {
+ rs, ok := ro.pendingReadIndex[string(context)]
if !ok {
- return 0
+ return nil
}
- rs.acks[m.From] = struct{}{}
- // add one to include an ack from local node
- return len(rs.acks) + 1
+ rs.acks[id] = true
+ return rs.acks
}
// advance advances the read only request queue kept by the readonly struct.