Skip to content

Commit

Permalink
Emit added event when node is revived
Browse files Browse the repository at this point in the history
  • Loading branch information
goldfire committed Mar 26, 2019
1 parent c7cd27a commit 89bc2d0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/democracy.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,14 @@ class Democracy extends EventEmitter {
if (!this._nodes[data.id]) {
this.addNodeToList(data);
} else {
const revived = this._nodes[data.id].state === 'removed' && data.state !== 'removed';
this._nodes[data.id].last = Date.now();
this._nodes[data.id].state = data.state;
this._nodes[data.id].weight = data.weight;

if (revived) {
this.emit('added', this._nodes[data.id]);
}
}

// Reset the voters since we've now seen this node again.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "democracy",
"version": "3.1.1",
"version": "3.1.2",
"description": "Node.js unicast discovery, master-slave elections and pub/sub.",
"homepage": "https://github.com/goldfire/democracy.js",
"keywords": [
Expand Down

0 comments on commit 89bc2d0

Please sign in to comment.