diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-13 07:10:47 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2017-11-13 09:06:13 +0800 |
commit | 84c965d459b948eb03cb8a70a66663bd7b35f463 (patch) | |
tree | fbcb47a43d4b029c2f1a46644eb64ca1d75f5921 /src/order_watcher | |
parent | 22cd6989a0217f2a49e59ce64bcc69b2c238aba4 (diff) | |
download | dexon-sol-tools-84c965d459b948eb03cb8a70a66663bd7b35f463.tar dexon-sol-tools-84c965d459b948eb03cb8a70a66663bd7b35f463.tar.gz dexon-sol-tools-84c965d459b948eb03cb8a70a66663bd7b35f463.tar.bz2 dexon-sol-tools-84c965d459b948eb03cb8a70a66663bd7b35f463.tar.lz dexon-sol-tools-84c965d459b948eb03cb8a70a66663bd7b35f463.tar.xz dexon-sol-tools-84c965d459b948eb03cb8a70a66663bd7b35f463.tar.zst dexon-sol-tools-84c965d459b948eb03cb8a70a66663bd7b35f463.zip |
Remove blockStore and default to numConfirmations === 0
Diffstat (limited to 'src/order_watcher')
-rw-r--r-- | src/order_watcher/event_watcher.ts | 10 | ||||
-rw-r--r-- | src/order_watcher/order_state_watcher.ts | 20 |
2 files changed, 7 insertions, 23 deletions
diff --git a/src/order_watcher/event_watcher.ts b/src/order_watcher/event_watcher.ts index 7e27d5e79..81529a98c 100644 --- a/src/order_watcher/event_watcher.ts +++ b/src/order_watcher/event_watcher.ts @@ -11,7 +11,6 @@ import {AbiDecoder} from '../utils/abi_decoder'; import {intervalUtils} from '../utils/interval_utils'; import {assert} from '../utils/assert'; import {utils} from '../utils/utils'; -import {BlockStore} from '../stores/block_store'; const DEFAULT_EVENT_POLLING_INTERVAL = 200; @@ -29,10 +28,8 @@ export class EventWatcher { private _pollingIntervalMs: number; private _intervalIdIfExists?: NodeJS.Timer; private _lastEvents: Web3.LogEntry[] = []; - private _blockStore: BlockStore; - constructor(web3Wrapper: Web3Wrapper, blockStore: BlockStore, pollingIntervalMs: undefined|number) { + constructor(web3Wrapper: Web3Wrapper, pollingIntervalMs: undefined|number) { this._web3Wrapper = web3Wrapper; - this._blockStore = blockStore; this._pollingIntervalMs = _.isUndefined(pollingIntervalMs) ? DEFAULT_EVENT_POLLING_INTERVAL : pollingIntervalMs; @@ -68,10 +65,9 @@ export class EventWatcher { this._lastEvents = pendingEvents; } private async _getEventsAsync(): Promise<Web3.LogEntry[]> { - const blockNumber = this._blockStore.getBlockNumber(); const eventFilter = { - fromBlock: blockNumber, - toBlock: blockNumber, + fromBlock: BlockParamLiteral.Pending, + toBlock: BlockParamLiteral.Pending, }; const events = await this._web3Wrapper.getLogsAsync(eventFilter); return events; diff --git a/src/order_watcher/order_state_watcher.ts b/src/order_watcher/order_state_watcher.ts index ab80f231f..c40131bcb 100644 --- a/src/order_watcher/order_state_watcher.ts +++ b/src/order_watcher/order_state_watcher.ts @@ -26,7 +26,6 @@ import { ZeroExError, } from '../types'; import {Web3Wrapper} from '../web3_wrapper'; -import {BlockStore} from '../stores/block_store'; import {TokenWrapper} from '../contract_wrappers/token_wrapper'; import {ExchangeWrapper} from '../contract_wrappers/exchange_wrapper'; import {OrderFilledCancelledLazyStore} from '../stores/order_filled_cancelled_lazy_store'; @@ -60,7 +59,6 @@ export class OrderStateWatcher { private _exchange: ExchangeWrapper; private _abiDecoder: AbiDecoder; private _orderStateUtils: OrderStateUtils; - private _blockStore: BlockStore; private _orderFilledCancelledLazyStore: OrderFilledCancelledLazyStore; private _balanceAndProxyAllowanceLazyStore: BalanceAndProxyAllowanceLazyStore; constructor( @@ -75,19 +73,11 @@ export class OrderStateWatcher { this._dependentOrderHashes = {}; const eventPollingIntervalMs = _.isUndefined(config) ? undefined : config.eventPollingIntervalMs; const blockPollingIntervalMs = _.isUndefined(config) ? undefined : config.blockPollingIntervalMs; - const numConfirmations = (_.isUndefined(config) || _.isUndefined(config.numConfirmations)) ? - DEFAULT_NUM_CONFIRMATIONS : - config.numConfirmations; - this._blockStore = new BlockStore(numConfirmations, this._web3Wrapper, blockPollingIntervalMs); - this._eventWatcher = new EventWatcher( - web3Wrapper, this._blockStore, eventPollingIntervalMs, - ); + this._eventWatcher = new EventWatcher(web3Wrapper, eventPollingIntervalMs); this._balanceAndProxyAllowanceLazyStore = new BalanceAndProxyAllowanceLazyStore( - this._token, this._blockStore, - ); - this._orderFilledCancelledLazyStore = new OrderFilledCancelledLazyStore( - this._exchange, this._blockStore, + this._token, ); + this._orderFilledCancelledLazyStore = new OrderFilledCancelledLazyStore(this._exchange); this._orderStateUtils = new OrderStateUtils( this._balanceAndProxyAllowanceLazyStore, this._orderFilledCancelledLazyStore, ); @@ -123,12 +113,11 @@ export class OrderStateWatcher { * @param callback Receives the orderHash of the order that should be re-validated, together * with all the order-relevant blockchain state needed to re-validate the order. */ - public async subscribeAsync(callback: OnOrderStateChangeCallback): Promise<void> { + public subscribe(callback: OnOrderStateChangeCallback): void { assert.isFunction('callback', callback); if (!_.isUndefined(this._callbackIfExistsAsync)) { throw new Error(ZeroExError.SubscriptionAlreadyPresent); } - await this._blockStore.startAsync(); this._callbackIfExistsAsync = callback; this._eventWatcher.subscribe(this._onEventWatcherCallbackAsync.bind(this)); } @@ -139,7 +128,6 @@ export class OrderStateWatcher { if (_.isUndefined(this._callbackIfExistsAsync)) { throw new Error(ZeroExError.SubscriptionNotFound); } - this._blockStore.stop(); this._balanceAndProxyAllowanceLazyStore.deleteAll(); this._orderFilledCancelledLazyStore.deleteAll(); delete this._callbackIfExistsAsync; |