aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contract-wrappers/src/contract_wrappers
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2018-07-03 20:59:49 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2018-07-05 21:56:31 +0800
commitba9d3cbdb84626769bd86cacd234234ada7465e2 (patch)
treefdd54fb432b11dcdb26315983487c23e2611aea2 /packages/contract-wrappers/src/contract_wrappers
parentbcf8d518069e816f451c9ecbc12522722322400a (diff)
downloaddexon-sol-tools-ba9d3cbdb84626769bd86cacd234234ada7465e2.tar
dexon-sol-tools-ba9d3cbdb84626769bd86cacd234234ada7465e2.tar.gz
dexon-sol-tools-ba9d3cbdb84626769bd86cacd234234ada7465e2.tar.bz2
dexon-sol-tools-ba9d3cbdb84626769bd86cacd234234ada7465e2.tar.lz
dexon-sol-tools-ba9d3cbdb84626769bd86cacd234234ada7465e2.tar.xz
dexon-sol-tools-ba9d3cbdb84626769bd86cacd234234ada7465e2.tar.zst
dexon-sol-tools-ba9d3cbdb84626769bd86cacd234234ada7465e2.zip
Make it possible to configure block polling interval in base contract wrapper
Diffstat (limited to 'packages/contract-wrappers/src/contract_wrappers')
-rw-r--r--packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts9
1 files changed, 6 insertions, 3 deletions
diff --git a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
index 7895a42ee..b8ca4d29b 100644
--- a/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
+++ b/packages/contract-wrappers/src/contract_wrappers/contract_wrapper.ts
@@ -12,7 +12,6 @@ import {
ContractWrappersError,
EventCallback,
IndexedFilterValues,
- InternalContractWrappersError,
} from '../types';
import { constants } from '../utils/constants';
import { filterUtils } from '../utils/filter_utils';
@@ -34,6 +33,7 @@ export abstract class ContractWrapper {
protected _web3Wrapper: Web3Wrapper;
protected _networkId: number;
private _blockAndLogStreamerIfExists: BlockAndLogStreamer<Block, Log> | undefined;
+ private _blockPollingIntervalMs: number;
private _blockAndLogStreamIntervalIfExists?: NodeJS.Timer;
private _filters: { [filterToken: string]: FilterObject };
private _filterCallbacks: {
@@ -41,9 +41,12 @@ export abstract class ContractWrapper {
};
private _onLogAddedSubscriptionToken: string | undefined;
private _onLogRemovedSubscriptionToken: string | undefined;
- constructor(web3Wrapper: Web3Wrapper, networkId: number) {
+ constructor(web3Wrapper: Web3Wrapper, networkId: number, blockPollingIntervalMs?: number) {
this._web3Wrapper = web3Wrapper;
this._networkId = networkId;
+ this._blockPollingIntervalMs = _.isUndefined(blockPollingIntervalMs)
+ ? constants.DEFAULT_BLOCK_POLLING_INTERVAL
+ : blockPollingIntervalMs;
this._filters = {};
this._filterCallbacks = {};
this._blockAndLogStreamerIfExists = undefined;
@@ -161,7 +164,7 @@ export abstract class ContractWrapper {
this._blockAndLogStreamerIfExists.addLogFilter(catchAllLogFilter);
this._blockAndLogStreamIntervalIfExists = intervalUtils.setAsyncExcludingInterval(
this._reconcileBlockAsync.bind(this),
- constants.DEFAULT_BLOCK_POLLING_INTERVAL,
+ this._blockPollingIntervalMs,
this._onReconcileBlockError.bind(this),
);
let isRemoved = false;