Include block hash

This commit is contained in:
maciejhirsz
2018-06-27 17:03:55 +02:00
parent b57dc22c33
commit fe2419e54b
3 changed files with 7 additions and 5 deletions
+3 -1
View File
@@ -15,6 +15,7 @@ export default class Node extends EventEmitter {
public implementation: Types.NodeImplementation;
public version: Types.NodeVersion;
public config: string;
public best = '' as Types.BlockHash;
public height = 0 as Types.BlockNumber;
public latency = 0 as Types.Milliseconds;
public blockTime = 0 as Types.Milliseconds;
@@ -125,7 +126,7 @@ export default class Node extends EventEmitter {
}
public blockDetails(): Types.BlockDetails {
return [this.height, this.blockTime];
return [this.height, this.best, this.blockTime];
}
public get average(): number {
@@ -174,6 +175,7 @@ export default class Node extends EventEmitter {
if (this.height < height) {
const blockTime = this.getBlockTime(time);
this.best = best;
this.height = height;
this.lastBlockAt = time;
this.blockTimes[height % BLOCK_TIME_HISTORY] = blockTime;
+1 -1
View File
@@ -12,7 +12,7 @@ export type Milliseconds = Opaque<number, 'Milliseconds'>;
export type PeerCount = Opaque<number, 'PeerCount'>;
export type TransactionCount = Opaque<number, 'TransactionCount'>;
export type BlockDetails = [BlockNumber, Milliseconds];
export type BlockDetails = [BlockNumber, BlockHash, Milliseconds];
export type NodeDetails = [NodeName, NodeImplementation, NodeVersion];
export type NodeStats = [PeerCount, TransactionCount];
+3 -3
View File
@@ -36,14 +36,14 @@ export default class App extends React.Component<{}, State> {
<table>
<thead>
<tr>
<th>Node Name</th><th>Node Type</th><th>Peers</th><th>Transactions</th><th>Block</th><th>Block time</th>
<th>Node Name</th><th>Node Type</th><th>Peers</th><th>Transactions</th><th>Last Block</th><th>Block Time</th>
</tr>
</thead>
<tbody>
{
this.nodes().map(([ id, node ]) => {
const [name, implementation, version] = node.nodeDetails;
const [height, blockTime] = node.blockDetails;
const [height, hash, blockTime] = node.blockDetails;
const [peers, txcount] = node.nodeStats;
return (
@@ -52,7 +52,7 @@ export default class App extends React.Component<{}, State> {
<td>{implementation} v{version}</td>
<td>{peers}</td>
<td>{txcount}</td>
<td>{height}</td>
<td>{height} {hash}</td>
<td>{blockTime / 1000}s</td>
</tr>
);