|
@@ -231,11 +231,20 @@ func (n *node) Tick() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (n *node) Campaign(ctx context.Context) error {
|
|
func (n *node) Campaign(ctx context.Context) error {
|
|
|
- return n.Step(ctx, pb.Message{Type: msgHup})
|
|
|
|
|
|
|
+ return n.step(ctx, pb.Message{Type: msgHup})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (n *node) Propose(ctx context.Context, data []byte) error {
|
|
func (n *node) Propose(ctx context.Context, data []byte) error {
|
|
|
- return n.Step(ctx, pb.Message{Type: msgProp, Entries: []pb.Entry{{Data: data}}})
|
|
|
|
|
|
|
+ return n.step(ctx, pb.Message{Type: msgProp, Entries: []pb.Entry{{Data: data}}})
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+func (n *node) Step(ctx context.Context, m pb.Message) error {
|
|
|
|
|
+ // ignore unexpected local messages receiving over network
|
|
|
|
|
+ if m.Type == msgHup || m.Type == msgBeat {
|
|
|
|
|
+ // TODO: return an error?
|
|
|
|
|
+ return nil
|
|
|
|
|
+ }
|
|
|
|
|
+ return n.step(ctx, m)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func (n *node) ProposeConfChange(ctx context.Context, cc pb.ConfChange) error {
|
|
func (n *node) ProposeConfChange(ctx context.Context, cc pb.ConfChange) error {
|
|
@@ -248,7 +257,7 @@ func (n *node) ProposeConfChange(ctx context.Context, cc pb.ConfChange) error {
|
|
|
|
|
|
|
|
// Step advances the state machine using msgs. The ctx.Err() will be returned,
|
|
// Step advances the state machine using msgs. The ctx.Err() will be returned,
|
|
|
// if any.
|
|
// if any.
|
|
|
-func (n *node) Step(ctx context.Context, m pb.Message) error {
|
|
|
|
|
|
|
+func (n *node) step(ctx context.Context, m pb.Message) error {
|
|
|
ch := n.recvc
|
|
ch := n.recvc
|
|
|
if m.Type == msgProp {
|
|
if m.Type == msgProp {
|
|
|
ch = n.propc
|
|
ch = n.propc
|