Sort chains by node count

This commit is contained in:
maciejhirsz
2018-07-12 16:04:04 +02:00
parent 47b80ad30e
commit ea8d7ad77d
10 changed files with 63 additions and 25 deletions
+4 -2
View File
@@ -16,13 +16,15 @@ export default class Aggregator {
let chain = this.getChain(node.chain);
chain.addNode(node);
this.feeds.broadcast(Feed.addedChain(chain));
}
public addFeed(feed: Feed) {
this.feeds.add(feed);
for (const chain of this.chains.values()) {
feed.sendMessage(Feed.addedChain(chain.label));
feed.sendMessage(Feed.addedChain(chain));
}
feed.events.on('subscribe', (label: Types.ChainLabel) => {
@@ -68,7 +70,7 @@ export default class Aggregator {
this.chains.set(label, chain);
console.log(`New chain: ${label}`);
this.feeds.broadcast(Feed.addedChain(label));
this.feeds.broadcast(Feed.addedChain(chain));
return chain;
}