mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-13 01:01:02 +00:00
feat: Instead of delisting, push stale nodes to bottom (#161)
This commit is contained in:
@@ -29,13 +29,12 @@ export default class Chain {
|
||||
}
|
||||
|
||||
public get nodeCount(): Types.NodeCount {
|
||||
return this.count as Types.NodeCount;
|
||||
return this.nodes.size as Types.NodeCount;
|
||||
}
|
||||
|
||||
public addNode(node: Node) {
|
||||
console.log(`[${this.label}] new node: ${node.name}`);
|
||||
|
||||
this.count += 1;
|
||||
this.nodes.add(node);
|
||||
this.feeds.broadcast(Feed.addedNode(node));
|
||||
|
||||
@@ -83,12 +82,7 @@ export default class Chain {
|
||||
node.events.removeAllListeners();
|
||||
|
||||
this.nodes.delete(node);
|
||||
|
||||
if (!node.isStale) {
|
||||
this.count -= 1;
|
||||
this.feeds.broadcast(Feed.removedNode(node));
|
||||
}
|
||||
|
||||
this.feeds.broadcast(Feed.removedNode(node));
|
||||
this.events.emit('disconnect', this.nodeCount);
|
||||
|
||||
if (this.height === node.best.number) {
|
||||
@@ -97,8 +91,7 @@ export default class Chain {
|
||||
}
|
||||
|
||||
public staleNode(node: Node) {
|
||||
this.count -= 1;
|
||||
this.feeds.broadcast(Feed.removedNode(node));
|
||||
this.feeds.broadcast(Feed.staleNode(node));
|
||||
|
||||
if (this.height === node.best.number) {
|
||||
this.downgradeBlock();
|
||||
@@ -174,8 +167,6 @@ export default class Chain {
|
||||
|
||||
if (node.isStale) {
|
||||
node.isStale = false;
|
||||
this.feeds.broadcast(Feed.addedNode(node));
|
||||
this.count += 1;
|
||||
} else {
|
||||
this.feeds.broadcast(Feed.imported(node));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user