Offline indicator, average block time and stuff

This commit is contained in:
maciejhirsz
2018-07-13 23:20:29 +02:00
parent 799da38a9b
commit ef3f52f5c8
16 changed files with 166 additions and 37 deletions
+10 -3
View File
@@ -2,7 +2,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';
import { VERSION, timestamp, Maybe, FeedMessage, Types, idGenerator } from '@dotstats/common';
const nextId = idGenerator<Types.FeedId>();
const { Actions } = FeedMessage;
@@ -25,10 +25,17 @@ export default class Feed {
socket.on('close', () => this.disconnect());
}
public static bestBlock(height: Types.BlockNumber, ts: Types.Timestamp): FeedMessage.Message {
public static feedVersion(): FeedMessage.Message {
return {
action: Actions.FeedVersion,
payload: VERSION
};
}
public static bestBlock(height: Types.BlockNumber, ts: Types.Timestamp, avg: Maybe<Types.Milliseconds>): FeedMessage.Message {
return {
action: Actions.BestBlock,
payload: [height, ts]
payload: [height, ts, avg]
};
}