Compare commits

...

No commits in common. "713e10d22341fa25a4e031d4aa04ca28b1af33ba" and "a0b20be22c9b22e57de82d09e0a301da7d340e9e" have entirely different histories.

1 changed files with 5 additions and 2 deletions

View File

@ -209,10 +209,13 @@ class TinyRaft extends EventEmitter
this._nextTerm(this.leadershipTimeout > 0 ? this.leadershipTimeout : -1); this._nextTerm(this.leadershipTimeout > 0 ? this.leadershipTimeout : -1);
this.followers = this.votes[this.nodeId]; this.followers = this.votes[this.nodeId];
for (const follower of this.followers) for (const follower of this.followers)
{
if (follower != this.nodeId)
{ {
// Send a heartbeat to confirm leadership // Send a heartbeat to confirm leadership
this.send(follower, { type: PING, term: this.term }); this.send(follower, { type: PING, term: this.term });
} }
}
this.emit('change', { state: this.state, term: this.term, leader: this.nodeId, followers: this.votes[this.nodeId] }); this.emit('change', { state: this.state, term: this.term, leader: this.nodeId, followers: this.votes[this.nodeId] });
} }
else else