From a9ae555b88cc36ff2cbd92fdd37a339702860c01 Mon Sep 17 00:00:00 2001 From: Leonid Logvinov Date: Sun, 12 Nov 2017 13:06:25 -0500 Subject: Store number of confirmations in a blockStore --- src/order_watcher/event_watcher.ts | 7 ++----- src/order_watcher/order_state_watcher.ts | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'src/order_watcher') diff --git a/src/order_watcher/event_watcher.ts b/src/order_watcher/event_watcher.ts index 5303bb651..7e27d5e79 100644 --- a/src/order_watcher/event_watcher.ts +++ b/src/order_watcher/event_watcher.ts @@ -29,13 +29,10 @@ export class EventWatcher { private _pollingIntervalMs: number; private _intervalIdIfExists?: NodeJS.Timer; private _lastEvents: Web3.LogEntry[] = []; - private _numConfirmations: number; private _blockStore: BlockStore; - constructor(web3Wrapper: Web3Wrapper, blockStore: BlockStore, pollingIntervalMs: undefined|number, - numConfirmations: number) { + constructor(web3Wrapper: Web3Wrapper, blockStore: BlockStore, pollingIntervalMs: undefined|number) { this._web3Wrapper = web3Wrapper; this._blockStore = blockStore; - this._numConfirmations = numConfirmations; this._pollingIntervalMs = _.isUndefined(pollingIntervalMs) ? DEFAULT_EVENT_POLLING_INTERVAL : pollingIntervalMs; @@ -71,7 +68,7 @@ export class EventWatcher { this._lastEvents = pendingEvents; } private async _getEventsAsync(): Promise { - const blockNumber = this._blockStore.getBlockNumberWithNConfirmations(this._numConfirmations); + const blockNumber = this._blockStore.getBlockNumber(); const eventFilter = { fromBlock: blockNumber, toBlock: blockNumber, diff --git a/src/order_watcher/order_state_watcher.ts b/src/order_watcher/order_state_watcher.ts index e6250cef5..0f5b5c30c 100644 --- a/src/order_watcher/order_state_watcher.ts +++ b/src/order_watcher/order_state_watcher.ts @@ -78,15 +78,15 @@ export class OrderStateWatcher { const numConfirmations = (_.isUndefined(config) || _.isUndefined(config.numConfirmations)) ? DEFAULT_NUM_CONFIRMATIONS : config.numConfirmations; - this._blockStore = new BlockStore(this._web3Wrapper, blockPollingIntervalMs); + this._blockStore = new BlockStore(numConfirmations, this._web3Wrapper, blockPollingIntervalMs); this._eventWatcher = new EventWatcher( - web3Wrapper, this._blockStore, eventPollingIntervalMs, numConfirmations, + web3Wrapper, this._blockStore, eventPollingIntervalMs, ); this._balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( - this._token, this._blockStore, numConfirmations, + this._token, this._blockStore, ); this._orderFilledCancelledLazyStore = new OrderFilledCancelledLazyStore( - this._exchange, this._blockStore, numConfirmations, + this._exchange, this._blockStore, ); this._orderStateUtils = new OrderStateUtils( this._balanceAndProxyAllowanceLazyStore, this._orderFilledCancelledLazyStore, -- cgit v1.2.3