update ethereumjs-blockstream 6.0.0 -> ^7.0.0 (#2089)

This commit is contained in:
Xianny
2019-08-21 18:39:07 -07:00
committed by GitHub
parent d3c714bd17
commit 0fe4f587d8
4 changed files with 39 additions and 48 deletions

View File

@@ -1,4 +1,13 @@
[
{
"version": "5.3.2",
"changes": [
{
"note": "Updated to ethereumjs-blockstream@^7.0.0",
"pr": 2089
}
]
},
{
"timestamp": 1565296576,
"version": "5.3.1",

View File

@@ -48,7 +48,7 @@
"@0x/utils": "^4.5.0",
"@0x/web3-wrapper": "^6.0.10",
"ethereum-types": "^2.1.4",
"ethereumjs-blockstream": "6.0.0",
"ethereumjs-blockstream": "^7.0.0",
"ethereumjs-util": "^5.1.1",
"ethers": "~4.0.4",
"js-sha3": "^0.7.0",

View File

@@ -101,17 +101,23 @@ export class SubscriptionManager<ContractEventArgs, ContractEvents extends strin
const logWithDecodedArgs = abiDecoder.tryToDecodeLogOrNoop(log);
return logWithDecodedArgs;
}
private _onLogStateChanged<ArgsType extends ContractEventArgs>(isRemoved: boolean, rawLog: RawLogEntry): void {
const log: LogEntry = marshaller.unmarshalLog(rawLog);
_.forEach(this._filters, (filter: FilterObject, filterToken: string) => {
if (filterUtils.matchesFilter(log, filter)) {
const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs<ArgsType>;
const logEvent = {
log: decodedLog,
isRemoved,
};
this._filterCallbacks[filterToken](null, logEvent);
}
private _onLogStateChanged<ArgsType extends ContractEventArgs>(
isRemoved: boolean,
blockHash: string,
rawLogs: RawLogEntry[],
): void {
const logs: LogEntry[] = rawLogs.map(rawLog => marshaller.unmarshalLog(rawLog));
logs.forEach(log => {
_.forEach(this._filters, (filter: FilterObject, filterToken: string) => {
if (filterUtils.matchesFilter(log, filter)) {
const decodedLog = this._tryToDecodeLogOrNoop(log) as LogWithDecodedArgs<ArgsType>;
const logEvent = {
log: decodedLog,
isRemoved,
};
this._filterCallbacks[filterToken](null, logEvent);
}
});
});
}
private _startBlockAndLogStream(isVerbose: boolean, blockPollingIntervalMs?: number): void {
@@ -133,11 +139,11 @@ export class SubscriptionManager<ContractEventArgs, ContractEvents extends strin
SubscriptionManager._onBlockAndLogStreamerError.bind(this, isVerbose),
);
let isRemoved = false;
this._onLogAddedSubscriptionToken = this._blockAndLogStreamerIfExists.subscribeToOnLogAdded(
this._onLogAddedSubscriptionToken = this._blockAndLogStreamerIfExists.subscribeToOnLogsAdded(
this._onLogStateChanged.bind(this, isRemoved),
);
isRemoved = true;
this._onLogRemovedSubscriptionToken = this._blockAndLogStreamerIfExists.subscribeToOnLogRemoved(
this._onLogRemovedSubscriptionToken = this._blockAndLogStreamerIfExists.subscribeToOnLogsRemoved(
this._onLogStateChanged.bind(this, isRemoved),
);
}
@@ -171,8 +177,8 @@ export class SubscriptionManager<ContractEventArgs, ContractEvents extends strin
if (this._blockAndLogStreamerIfExists === undefined) {
throw new Error(SubscriptionErrors.SubscriptionNotFound);
}
this._blockAndLogStreamerIfExists.unsubscribeFromOnLogAdded(this._onLogAddedSubscriptionToken as string);
this._blockAndLogStreamerIfExists.unsubscribeFromOnLogRemoved(this._onLogRemovedSubscriptionToken as string);
this._blockAndLogStreamerIfExists.unsubscribeFromOnLogsAdded(this._onLogAddedSubscriptionToken as string);
this._blockAndLogStreamerIfExists.unsubscribeFromOnLogsRemoved(this._onLogRemovedSubscriptionToken as string);
intervalUtils.clearAsyncExcludingInterval(this._blockAndLogStreamIntervalIfExists as NodeJS.Timer);
delete this._blockAndLogStreamerIfExists;
}