Fix leader change event
parent
b559f9b555
commit
857cf668f2
|
@ -238,7 +238,7 @@ class TinyRaft extends EventEmitter
|
|||
if (this.state == CANDIDATE && this.term == msg.term && from == this.leader)
|
||||
{
|
||||
this.state = FOLLOWER;
|
||||
this.emit('change', { state: this.state, term: this.term, leader: this.nodeId });
|
||||
this.emit('change', { state: this.state, term: this.term, leader: this.leader });
|
||||
}
|
||||
if (this.state == FOLLOWER && from == this.leader)
|
||||
{
|
||||
|
|
|
@ -200,7 +200,7 @@ async function testRestart()
|
|||
checkQuorum(nodes, 5);
|
||||
if (leaderChanges >= 3)
|
||||
{
|
||||
throw new Error("leaderChanges = "+leaderChanges+" (expected < 3)")
|
||||
throw new Error("leaderChanges = "+leaderChanges+" (expected < 3)");
|
||||
}
|
||||
// Stop a follower
|
||||
let restarted = 1 + (prevLeader % 5);
|
||||
|
|
Loading…
Reference in New Issue