diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-11 06:30:55 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-13 09:06:13 +0800 |
commit | 009f81fe4f8dd8ed6b671d309553a6d04edd90ca (patch) | |
tree | 56524cf7b3e1933d69acd29535346fe930b155e4 /src/stores | |
parent | 81ce4a02290cc38e6dc30873c18b0f9c8c9c4db3 (diff) | |
download | dexon-sol-tools-009f81fe4f8dd8ed6b671d309553a6d04edd90ca.tar dexon-sol-tools-009f81fe4f8dd8ed6b671d309553a6d04edd90ca.tar.gz dexon-sol-tools-009f81fe4f8dd8ed6b671d309553a6d04edd90ca.tar.bz2 dexon-sol-tools-009f81fe4f8dd8ed6b671d309553a6d04edd90ca.tar.lz dexon-sol-tools-009f81fe4f8dd8ed6b671d309553a6d04edd90ca.tar.xz dexon-sol-tools-009f81fe4f8dd8ed6b671d309553a6d04edd90ca.tar.zst dexon-sol-tools-009f81fe4f8dd8ed6b671d309553a6d04edd90ca.zip |
Clear store cache on events
Diffstat (limited to 'src/stores')
-rw-r--r-- | src/stores/block_store.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/stores/block_store.ts b/src/stores/block_store.ts index 70798a999..d1f6c329a 100644 --- a/src/stores/block_store.ts +++ b/src/stores/block_store.ts @@ -5,7 +5,7 @@ import {BlockParamLiteral, InternalZeroExError, ZeroExError} from '../types'; import {Web3Wrapper} from '../web3_wrapper'; import {intervalUtils} from '../utils/interval_utils'; -const POLLING_INTERVAL_MS = 500; +const DEFAULT_BLOCK_POLLING_INTERVAL_MS = 500; /** * Store for a current latest block number @@ -14,8 +14,10 @@ export class BlockStore { private web3Wrapper?: Web3Wrapper; private latestBlockNumber?: number; private intervalId?: NodeJS.Timer; - constructor(web3Wrapper?: Web3Wrapper) { + private blockPollingIntervalMs: number; + constructor(web3Wrapper?: Web3Wrapper, blockPollingIntervalMs?: number) { this.web3Wrapper = web3Wrapper; + this.blockPollingIntervalMs = blockPollingIntervalMs || DEFAULT_BLOCK_POLLING_INTERVAL_MS; } public getBlockNumberWithNConfirmations(numConfirmations: number): Web3.BlockParam { let blockNumber; @@ -38,7 +40,7 @@ export class BlockStore { public async startAsync(): Promise<void> { await this.updateLatestBlockAsync(); this.intervalId = intervalUtils.setAsyncExcludingInterval( - this.updateLatestBlockAsync.bind(this), POLLING_INTERVAL_MS, + this.updateLatestBlockAsync.bind(this), this.blockPollingIntervalMs, ); } public stop(): void { |