aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web3-wrapper
diff options
context:
space:
mode:
authorAlex Browne <stephenalexbrowne@gmail.com>2018-07-04 01:40:54 +0800
committerAlex Browne <stephenalexbrowne@gmail.com>2018-07-04 01:40:54 +0800
commitc5fcea1dbd5e64e72eb5cf360558de9f9b886a16 (patch)
treebd135d491f1bd794985e5789af2888dcf98abdb0 /packages/web3-wrapper
parent5b64b3ea937326978b5742ec1b3692ebe5c41991 (diff)
downloaddexon-sol-tools-c5fcea1dbd5e64e72eb5cf360558de9f9b886a16.tar
dexon-sol-tools-c5fcea1dbd5e64e72eb5cf360558de9f9b886a16.tar.gz
dexon-sol-tools-c5fcea1dbd5e64e72eb5cf360558de9f9b886a16.tar.bz2
dexon-sol-tools-c5fcea1dbd5e64e72eb5cf360558de9f9b886a16.tar.lz
dexon-sol-tools-c5fcea1dbd5e64e72eb5cf360558de9f9b886a16.tar.xz
dexon-sol-tools-c5fcea1dbd5e64e72eb5cf360558de9f9b886a16.tar.zst
dexon-sol-tools-c5fcea1dbd5e64e72eb5cf360558de9f9b886a16.zip
Actually cache node type in web3-wrapper
Diffstat (limited to 'packages/web3-wrapper')
-rw-r--r--packages/web3-wrapper/src/web3_wrapper.ts6
1 files changed, 6 insertions, 0 deletions
diff --git a/packages/web3-wrapper/src/web3_wrapper.ts b/packages/web3-wrapper/src/web3_wrapper.ts
index e4df31def..c2754a13e 100644
--- a/packages/web3-wrapper/src/web3_wrapper.ts
+++ b/packages/web3-wrapper/src/web3_wrapper.ts
@@ -49,6 +49,7 @@ export class Web3Wrapper {
private _web3: Web3;
private _txDefaults: Partial<TxData>;
private _jsonRpcRequestId: number;
+ private _nodeType: NodeType | undefined;
/**
* Check if an address is a valid Ethereum address
* @param address Address to check
@@ -501,10 +502,15 @@ export class Web3Wrapper {
* function caches the result and so subsequent calls are fast.
*/
public async getNodeTypeAsync(): Promise<NodeType> {
+ if (!_.isUndefined(this._nodeType)) {
+ return this._nodeType;
+ }
const version = await this.getNodeVersionAsync();
if (_.includes(version, uniqueVersionIds.geth)) {
+ this._nodeType = NodeType.Geth;
return NodeType.Geth;
} else if (_.includes(version, uniqueVersionIds.ganache)) {
+ this._nodeType = NodeType.Ganache;
return NodeType.Ganache;
} else {
throw new Error(`Unknown client version: ${version}`);