aboutsummaryrefslogtreecommitdiffstats
path: root/src/contract_wrappers/contract_wrapper.ts
diff options
context:
space:
mode:
authorLeonid Logvinov <logvinov.leon@gmail.com>2017-10-05 20:16:51 +0800
committerLeonid Logvinov <logvinov.leon@gmail.com>2017-10-05 20:35:38 +0800
commit118381c1d10315c82a526d94c86e60b569ad3b45 (patch)
tree3bf83d604ea54238d1375af049e06c6e6414758a /src/contract_wrappers/contract_wrapper.ts
parentf2100fa36dae740735f9a2e2811cc7977f4c286c (diff)
downloaddexon-sol-tools-118381c1d10315c82a526d94c86e60b569ad3b45.tar
dexon-sol-tools-118381c1d10315c82a526d94c86e60b569ad3b45.tar.gz
dexon-sol-tools-118381c1d10315c82a526d94c86e60b569ad3b45.tar.bz2
dexon-sol-tools-118381c1d10315c82a526d94c86e60b569ad3b45.tar.lz
dexon-sol-tools-118381c1d10315c82a526d94c86e60b569ad3b45.tar.xz
dexon-sol-tools-118381c1d10315c82a526d94c86e60b569ad3b45.tar.zst
dexon-sol-tools-118381c1d10315c82a526d94c86e60b569ad3b45.zip
Move more logic into _stopBlockAndLogStream and _startBlockAndLogStream
Diffstat (limited to 'src/contract_wrappers/contract_wrapper.ts')
-rw-r--r--src/contract_wrappers/contract_wrapper.ts23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/contract_wrappers/contract_wrapper.ts b/src/contract_wrappers/contract_wrapper.ts
index b6b4aa4be..ee989c700 100644
--- a/src/contract_wrappers/contract_wrapper.ts
+++ b/src/contract_wrappers/contract_wrapper.ts
@@ -46,14 +46,6 @@ export class ContractWrapper {
);
if (_.isEmpty(this._filters)) {
this._startBlockAndLogStream();
- let removed = false;
- this._onLogAddedSubscriptionToken = this._blockAndLogStreamer.subscribeToOnLogAdded(
- this._onLogStateChanged.bind(this, removed),
- );
- removed = true;
- this._onLogRemovedSubscriptionToken = this._blockAndLogStreamer.subscribeToOnLogRemoved(
- this._onLogStateChanged.bind(this, removed),
- );
}
const filterToken = filterUtils.generateUUID();
this._filters[filterToken] = filter;
@@ -67,8 +59,6 @@ export class ContractWrapper {
delete this._filters[filterToken];
delete this._filterCallbacks[filterToken];
if (_.isEmpty(this._filters)) {
- this._blockAndLogStreamer.unsubscribeFromOnLogAdded(this._onLogAddedSubscriptionToken as string);
- this._blockAndLogStreamer.unsubscribeFromOnLogRemoved(this._onLogRemovedSubscriptionToken as string);
this._stopBlockAndLogStream();
}
}
@@ -114,12 +104,23 @@ export class ContractWrapper {
this._web3Wrapper.getBlockAsync.bind(this._web3Wrapper),
this._web3Wrapper.getLogsAsync.bind(this._web3Wrapper),
);
- this._blockAndLogStreamer.addLogFilter({});
+ const catchAllLogFilter = {};
+ this._blockAndLogStreamer.addLogFilter(catchAllLogFilter);
this._blockAndLogStreamInterval = intervalUtils.setAsyncExcludingInterval(
this._reconcileBlockAsync.bind(this), constants.DEFAULT_BLOCK_POLLING_INTERVAL,
);
+ let removed = false;
+ this._onLogAddedSubscriptionToken = this._blockAndLogStreamer.subscribeToOnLogAdded(
+ this._onLogStateChanged.bind(this, removed),
+ );
+ removed = true;
+ this._onLogRemovedSubscriptionToken = this._blockAndLogStreamer.subscribeToOnLogRemoved(
+ this._onLogStateChanged.bind(this, removed),
+ );
}
private _stopBlockAndLogStream(): void {
+ this._blockAndLogStreamer.unsubscribeFromOnLogAdded(this._onLogAddedSubscriptionToken as string);
+ this._blockAndLogStreamer.unsubscribeFromOnLogRemoved(this._onLogRemovedSubscriptionToken as string);
intervalUtils.clearAsyncExcludingInterval(this._blockAndLogStreamInterval);
delete this._blockAndLogStreamer;
}