mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
raft: messages -> byMsgType
This commit is contained in:
parent
ad307c6965
commit
91b62c0fbf
10
raft/node.go
10
raft/node.go
@ -107,7 +107,7 @@ func (n *Node) Propose(ctx context.Context, data []byte) error {
|
||||
// prevent this cluster from making progress. The ctx.Err() will be returned,
|
||||
// if any.
|
||||
func (n *Node) Step(ctx context.Context, msgs []Message) error {
|
||||
sort.Sort(sort.Reverse(messages(msgs)))
|
||||
sort.Sort(sort.Reverse(byMsgType(msgs)))
|
||||
for _, m := range msgs {
|
||||
ch := n.recvc
|
||||
if m.Type == msgProp {
|
||||
@ -138,8 +138,8 @@ func (n *Node) ReadState(ctx context.Context) (st State, ents, cents []Entry, ms
|
||||
}
|
||||
}
|
||||
|
||||
type messages []Message
|
||||
type byMsgType []Message
|
||||
|
||||
func (msgs messages) Len() int { return len(msgs) }
|
||||
func (msgs messages) Less(i, j int) bool { return msgs[i].Type == msgProp }
|
||||
func (msgs messages) Swap(i, j int) { msgs[i], msgs[j] = msgs[i], msgs[j] }
|
||||
func (msgs byMsgType) Len() int { return len(msgs) }
|
||||
func (msgs byMsgType) Less(i, j int) bool { return msgs[i].Type == msgProp }
|
||||
func (msgs byMsgType) Swap(i, j int) { msgs[i], msgs[j] = msgs[i], msgs[j] }
|
||||
|
Loading…
x
Reference in New Issue
Block a user