mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-06-12 19:11:01 +00:00
Sort chains by node count
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ export default class Chain {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public get nodeCount(): number {
|
||||
return this.nodes.size;
|
||||
public get nodeCount(): Types.NodeCount {
|
||||
return this.nodes.size as Types.NodeCount;
|
||||
}
|
||||
|
||||
public addNode(node: Node) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import * as WebSocket from 'ws';
|
||||
import * as EventEmitter from 'events';
|
||||
import Node from './Node';
|
||||
import Chain from './Chain';
|
||||
import { timestamp, Maybe, FeedMessage, Types, idGenerator } from '@dotstats/common';
|
||||
|
||||
const nextId = idGenerator<Types.FeedId>();
|
||||
@@ -66,10 +67,10 @@ export default class Feed {
|
||||
};
|
||||
}
|
||||
|
||||
public static addedChain(label: Types.ChainLabel): FeedMessage.Message {
|
||||
public static addedChain(chain: Chain): FeedMessage.Message {
|
||||
return {
|
||||
action: Actions.AddedChain,
|
||||
payload: label
|
||||
payload: [chain.label, chain.nodeCount]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user