diff options
author | Fabio Berger <me@fabioberger.com> | 2017-11-13 09:49:56 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2017-11-13 09:49:56 +0800 |
commit | a22661670f105a2bf527aca0e803689e0302ed17 (patch) | |
tree | 86042b06c407b388e39be690d9a40db218f82675 /src/order_watcher/event_watcher.ts | |
parent | 442f35a1fdd98846d3985548b3de6f5c620e68a1 (diff) | |
parent | 5aef16c2aacd279a8e688b4e735526bff7e4970f (diff) | |
download | dexon-0x-contracts-a22661670f105a2bf527aca0e803689e0302ed17.tar.gz dexon-0x-contracts-a22661670f105a2bf527aca0e803689e0302ed17.tar.zst dexon-0x-contracts-a22661670f105a2bf527aca0e803689e0302ed17.zip |
Merge branch 'orderWatcher' of github.com:0xProject/0x.js into orderWatcher
* 'orderWatcher' of github.com:0xProject/0x.js: (33 commits)
Remove old tests
Remove unused code
Fix tests
Remove redundant spaces
Don't store empty objects
Fix a typo
Remove duplicate operations
Remove redundant instance variables
Fix tests
Remove blockStore and default to numConfirmations === 0
Add a comment
Store number of confirmations in a blockStore
Remove tautology check
Pass blockStore to eventWatcher
Fix last merge conflicts
Clear cache on unsubscribe
Clear store cache on events
Add more configs for order watcher
Make subscribe function async and make blockStore operational
Adjust tests to new interface
...
Diffstat (limited to 'src/order_watcher/event_watcher.ts')
-rw-r--r-- | src/order_watcher/event_watcher.ts | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/order_watcher/event_watcher.ts b/src/order_watcher/event_watcher.ts index c9e72281c..81529a98c 100644 --- a/src/order_watcher/event_watcher.ts +++ b/src/order_watcher/event_watcher.ts @@ -28,10 +28,8 @@ export class EventWatcher { private _pollingIntervalMs: number; private _intervalIdIfExists?: NodeJS.Timer; private _lastEvents: Web3.LogEntry[] = []; - private _numConfirmations: number; - constructor(web3Wrapper: Web3Wrapper, pollingIntervalMs: undefined|number, numConfirmations: number) { + constructor(web3Wrapper: Web3Wrapper, pollingIntervalMs: undefined|number) { this._web3Wrapper = web3Wrapper; - this._numConfirmations = numConfirmations; this._pollingIntervalMs = _.isUndefined(pollingIntervalMs) ? DEFAULT_EVENT_POLLING_INTERVAL : pollingIntervalMs; @@ -67,16 +65,9 @@ export class EventWatcher { this._lastEvents = pendingEvents; } private async _getEventsAsync(): Promise<Web3.LogEntry[]> { - let latestBlock: BlockParamLiteral|number; - if (this._numConfirmations === 0) { - latestBlock = BlockParamLiteral.Pending; - } else { - const currentBlock = await this._web3Wrapper.getBlockNumberAsync(); - latestBlock = currentBlock - this._numConfirmations; - } const eventFilter = { - fromBlock: latestBlock, - toBlock: latestBlock, + fromBlock: BlockParamLiteral.Pending, + toBlock: BlockParamLiteral.Pending, }; const events = await this._web3Wrapper.getLogsAsync(eventFilter); return events; |