mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-04-25 22:18:01 +00:00
Update block immediately after adding a node to the chain
This commit is contained in:
@@ -45,6 +45,8 @@ export default class Chain {
|
||||
node.events.on('block', () => this.updateBlock(node));
|
||||
node.events.on('stats', () => this.feeds.broadcast(Feed.stats(node)));
|
||||
node.events.on('location', (location) => this.feeds.broadcast(Feed.locatedNode(node, location)));
|
||||
|
||||
this.updateBlock(node);
|
||||
}
|
||||
|
||||
public addFeed(feed: Feed) {
|
||||
|
||||
@@ -64,8 +64,6 @@ export default class Node {
|
||||
this.lastMessage = timestamp();
|
||||
this.socket = socket;
|
||||
|
||||
let start = Date.now();
|
||||
|
||||
socket.on('message', (data) => {
|
||||
const message = parseMessage(data);
|
||||
|
||||
@@ -145,6 +143,7 @@ export default class Node {
|
||||
const timeout = setTimeout(() => {
|
||||
cleanup();
|
||||
|
||||
socket.close();
|
||||
socket.terminate();
|
||||
|
||||
return reject(new Error('Timeout on waiting for system.connected message'));
|
||||
@@ -206,6 +205,7 @@ export default class Node {
|
||||
|
||||
private disconnect() {
|
||||
this.socket.removeAllListeners();
|
||||
this.socket.close();
|
||||
this.socket.terminate();
|
||||
|
||||
this.events.emit('disconnect');
|
||||
@@ -237,11 +237,11 @@ export default class Node {
|
||||
}
|
||||
|
||||
private updateLatency(now: Types.Timestamp) {
|
||||
// if (this.pingStart) {
|
||||
// console.error(`${this.name} timed out on ping message.`);
|
||||
// this.disconnect();
|
||||
// return;
|
||||
// }
|
||||
if (this.pingStart) {
|
||||
console.error(`${this.name} timed out on ping message.`);
|
||||
this.disconnect();
|
||||
return;
|
||||
}
|
||||
|
||||
this.pingStart = now;
|
||||
this.socket.ping(noop);
|
||||
|
||||
@@ -11,11 +11,11 @@ export class Connection {
|
||||
return new Connection(await Connection.socket(), update);
|
||||
}
|
||||
|
||||
private static readonly address = window.location.protocol === 'https:'
|
||||
? `wss://${window.location.hostname}/feed/`
|
||||
: `ws://${window.location.hostname}:8080`;
|
||||
// private static readonly address = window.location.protocol === 'https:'
|
||||
// ? `wss://${window.location.hostname}/feed/`
|
||||
// : `ws://${window.location.hostname}:8080`;
|
||||
|
||||
// private static readonly address = 'wss://telemetry.polkadot.io/feed/';
|
||||
private static readonly address = 'wss://telemetry.polkadot.io/feed/';
|
||||
|
||||
private static async socket(): Promise<WebSocket> {
|
||||
let socket = await Connection.trySocket();
|
||||
|
||||
Reference in New Issue
Block a user