Skip to content

Commit

Permalink
feat: add getblockchaininfo
Browse files Browse the repository at this point in the history
  • Loading branch information
gridcat committed Jun 30, 2021
1 parent 9991c67 commit 8891fb7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
11 changes: 11 additions & 0 deletions src/RPC/Network.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Block, BlockWithTX } from '../contracts/block';
import { BlockchainInfo } from '../contracts/blockchainInfo';
import { CurrentTime } from '../contracts/currentTime';
import { RPCBase } from '../RPCBase';

Expand Down Expand Up @@ -109,4 +110,14 @@ export class Network extends RPCBase {
): Promise<Type extends true ? BlockWithTX : Block> {
return this.call('getblockbynumber', number, txinfo);
}

/**
* Displays data on current blockchain
*
* @returns {Promise<BlockchainInfo>}
* @memberof Network
*/
public async getBlockchainInfo(): Promise<BlockchainInfo> {
return this.call('getblockchaininfo');
}
}
15 changes: 0 additions & 15 deletions src/contracts/blockChainInfo.ts

This file was deleted.

19 changes: 19 additions & 0 deletions src/contracts/blockchainInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export interface BlockchainDifficulty {
current: number;
target: number;
}

export interface BlockchainInfo {
/**
* the current number of blocks processed in the server
*
* @type {number}
* @memberof BlockchainInfo
*/
blocks: number;
inSync: boolean;
moneysupply: number;
difficulty: BlockchainDifficulty;
testnet: boolean;
errors: string;
}

0 comments on commit 8891fb7

Please sign in to comment.