Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ethereumjs-blockstream

Package Overview
Dependencies
Maintainers
7
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereumjs-blockstream - npm Package Compare versions

Comparing version 6.0.1 to 7.0.0

16

output/source/block-and-log-streamer.d.ts

@@ -21,4 +21,4 @@ import { Block } from "./models/block";

private readonly onBlockRemovedSubscribers;
private readonly onLogAddedSubscribers;
private readonly onLogRemovedSubscribers;
private readonly onLogsAddedSubscribers;
private readonly onLogsRemovedSubscribers;
/**

@@ -34,4 +34,4 @@ * @param getBlockByHash async function that returns a block given a particular hash or null/throws if the block is not found

private readonly onBlockRemoved;
private readonly onLogAdded;
private readonly onLogRemoved;
private readonly onLogsAdded;
private readonly onLogsRemoved;
readonly getLatestReconciledBlock: () => TBlock | null;

@@ -44,6 +44,6 @@ readonly addLogFilter: (filter: Filter) => string;

readonly unsubscribeFromOnBlockRemoved: (token: string) => void;
readonly subscribeToOnLogAdded: (onLogAdded: (log: TLog) => void) => string;
readonly unsubscribeFromOnLogAdded: (token: string) => void;
readonly subscribeToOnLogRemoved: (onLogRemoved: (log: TLog) => void) => string;
readonly unsubscribeFromOnLogRemoved: (token: string) => void;
readonly subscribeToOnLogsAdded: (onLogsAdded: (blockHash: string, logs: TLog[]) => void) => string;
readonly unsubscribeFromOnLogsAdded: (token: string) => void;
readonly subscribeToOnLogsRemoved: (onLogsRemoved: (blockHash: string, logs: TLog[]) => void) => string;
readonly unsubscribeFromOnLogsRemoved: (token: string) => void;
}

@@ -60,4 +60,4 @@ "use strict";

this.onBlockRemovedSubscribers = {};
this.onLogAddedSubscribers = {};
this.onLogRemovedSubscribers = {};
this.onLogsAddedSubscribers = {};
this.onLogsRemovedSubscribers = {};
this.reconcileNewBlock = function (block) { return __awaiter(_this, void 0, void 0, function () {

@@ -105,3 +105,3 @@ var blockHistory, logHistory, error_1;

logFilters = Object.keys(this.logFilters).map(function (key) { return _this.logFilters[key]; });
this.logHistory = log_reconciler_1.reconcileLogHistoryWithAddedBlock(this.getLogs, this.logHistory, block, this.onLogAdded, logFilters, this.blockRetention);
this.logHistory = log_reconciler_1.reconcileLogHistoryWithAddedBlock(this.getLogs, this.logHistory, block, this.onLogsAdded, logFilters, this.blockRetention);
return [4 /*yield*/, this.logHistory];

@@ -119,3 +119,3 @@ case 1:

case 0:
this.logHistory = log_reconciler_1.reconcileLogHistoryWithRemovedBlock(this.logHistory, block, this.onLogRemoved);
this.logHistory = log_reconciler_1.reconcileLogHistoryWithRemovedBlock(this.logHistory, block, this.onLogsRemoved);
return [4 /*yield*/, this.logHistory];

@@ -132,19 +132,19 @@ case 1:

}); };
this.onLogAdded = function (log) { return __awaiter(_this, void 0, void 0, function () {
this.onLogsAdded = function (blockHash, logs) { return __awaiter(_this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
Object.keys(this.onLogAddedSubscribers)
.map(function (key) { return _this.onLogAddedSubscribers[key]; })
Object.keys(this.onLogsAddedSubscribers)
.map(function (key) { return _this.onLogsAddedSubscribers[key]; })
.map(function (callback) { return logAndSwallowWrapper(callback, _this.onError); })
.forEach(function (callback) { return _this.pendingCallbacks.push(function () { return callback(log); }); });
.forEach(function (callback) { return _this.pendingCallbacks.push(function () { return callback(blockHash, logs); }); });
return [2 /*return*/];
});
}); };
this.onLogRemoved = function (log) { return __awaiter(_this, void 0, void 0, function () {
this.onLogsRemoved = function (blockHash, logs) { return __awaiter(_this, void 0, void 0, function () {
var _this = this;
return __generator(this, function (_a) {
Object.keys(this.onLogRemovedSubscribers)
.map(function (key) { return _this.onLogRemovedSubscribers[key]; })
Object.keys(this.onLogsRemovedSubscribers)
.map(function (key) { return _this.onLogsRemovedSubscribers[key]; })
.map(function (callback) { return logAndSwallowWrapper(callback, _this.onError); })
.forEach(function (callback) { return _this.pendingCallbacks.push(function () { return callback(log); }); });
.forEach(function (callback) { return _this.pendingCallbacks.push(function () { return callback(blockHash, logs); }); });
return [2 /*return*/];

@@ -186,21 +186,21 @@ });

};
this.subscribeToOnLogAdded = function (onLogAdded) {
this.subscribeToOnLogsAdded = function (onLogsAdded) {
var uuid = "on log added token " + createUuid();
_this.onLogAddedSubscribers[uuid] = onLogAdded;
_this.onLogsAddedSubscribers[uuid] = onLogsAdded;
return uuid;
};
this.unsubscribeFromOnLogAdded = function (token) {
this.unsubscribeFromOnLogsAdded = function (token) {
if (!token.startsWith("on log added token "))
throw new Error("Expected a log added subscription token. Actual: " + token);
delete _this.onLogAddedSubscribers[token];
delete _this.onLogsAddedSubscribers[token];
};
this.subscribeToOnLogRemoved = function (onLogRemoved) {
this.subscribeToOnLogsRemoved = function (onLogsRemoved) {
var uuid = "on log removed token " + createUuid();
_this.onLogRemovedSubscribers[uuid] = onLogRemoved;
_this.onLogsRemovedSubscribers[uuid] = onLogsRemoved;
return uuid;
};
this.unsubscribeFromOnLogRemoved = function (token) {
this.unsubscribeFromOnLogsRemoved = function (token) {
if (!token.startsWith("on log removed token "))
throw new Error("Expected a log added subscription token. Actual: " + token);
delete _this.onLogRemovedSubscribers[token];
delete _this.onLogsRemovedSubscribers[token];
};

@@ -222,5 +222,5 @@ if (getBlockByHash === undefined)

function logAndSwallowWrapper(callback, onError) {
return function (parameter) {
return function (parameter1, parameter2) {
try {
callback(parameter);
callback(parameter1, parameter2);
}

@@ -227,0 +227,0 @@ catch (error) {

@@ -0,0 +0,0 @@ import { Block } from "./models/block";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ export { Block } from "./models/block";

@@ -0,0 +0,0 @@ "use strict";

import { Block } from "./models/block";
import { Log } from "./models/log";
import { Filter, FilterOptions } from "./models/filters";
export declare const reconcileLogHistoryWithAddedBlock: <TBlock extends Block, TLog extends Log>(getLogs: (filterOptions: FilterOptions) => Promise<TLog[]>, logHistory: import("../../../../../Users/micah/Source/ethereumjs-blockstream/node_modules/immutable").List<TLog> | Promise<import("../../../../../Users/micah/Source/ethereumjs-blockstream/node_modules/immutable").List<TLog>>, newBlock: TBlock, onLogAdded: (log: TLog) => Promise<void>, filters?: Filter[], historyBlockLength?: number) => Promise<import("../../../../../Users/micah/Source/ethereumjs-blockstream/node_modules/immutable").List<TLog>>;
export declare const reconcileLogHistoryWithRemovedBlock: <TBlock extends Block, TLog extends Log>(logHistory: import("../../../../../Users/micah/Source/ethereumjs-blockstream/node_modules/immutable").List<TLog> | Promise<import("../../../../../Users/micah/Source/ethereumjs-blockstream/node_modules/immutable").List<TLog>>, removedBlock: TBlock, onLogRemoved: (log: TLog) => Promise<void>) => Promise<import("../../../../../Users/micah/Source/ethereumjs-blockstream/node_modules/immutable").List<TLog>>;
export declare const reconcileLogHistoryWithAddedBlock: <TBlock extends Block, TLog extends Log>(getLogs: (filterOptions: FilterOptions) => Promise<TLog[]>, logHistory: import("immutable").List<TLog> | Promise<import("immutable").List<TLog>>, newBlock: TBlock, onLogsAdded: (blockHash: string, logs: TLog[]) => Promise<void>, filters?: Filter[], historyBlockLength?: number) => Promise<import("immutable").List<TLog>>;
export declare const reconcileLogHistoryWithRemovedBlock: <TBlock extends Block, TLog extends Log>(logHistory: import("immutable").List<TLog> | Promise<import("immutable").List<TLog>>, removedBlock: TBlock, onLogsRemoved: (blockHash: string, logs: TLog[]) => Promise<void>) => Promise<import("immutable").List<TLog>>;

@@ -40,3 +40,3 @@ "use strict";

var utilities_1 = require("./utilities");
exports.reconcileLogHistoryWithAddedBlock = function (getLogs, logHistory, newBlock, onLogAdded, filters, historyBlockLength) {
exports.reconcileLogHistoryWithAddedBlock = function (getLogs, logHistory, newBlock, onLogsAdded, filters, historyBlockLength) {
if (filters === void 0) { filters = []; }

@@ -54,3 +54,3 @@ if (historyBlockLength === void 0) { historyBlockLength = 100; }

logs = _a.sent();
return [4 /*yield*/, addNewLogsToHead(logHistory, logs, onLogAdded)];
return [4 /*yield*/, addNewLogsToHead(newBlock.hash, logHistory, logs, onLogsAdded)];
case 3:

@@ -81,4 +81,4 @@ logHistory = _a.sent();

}); };
var addNewLogsToHead = function (logHistory, newLogs, onLogAdded) { return __awaiter(_this, void 0, void 0, function () {
var sortedLogs, _loop_1, _i, sortedLogs_1, logToAdd;
var addNewLogsToHead = function (blockHash, logHistory, newLogs, onLogsAdded) { return __awaiter(_this, void 0, void 0, function () {
var sortedLogs, addedLogs, _loop_1, _i, sortedLogs_1, logToAdd;
return __generator(this, function (_a) {

@@ -88,30 +88,21 @@ switch (_a.label) {

sortedLogs = newLogs.sort(function (logA, logB) { return utilities_1.parseHexInt(logA.logIndex) - utilities_1.parseHexInt(logB.logIndex); });
addedLogs = [];
_loop_1 = function (logToAdd) {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
// we may already have this log because two filters can return the same log
if (logHistory.some(function (logInHistory) { return logInHistory.blockHash === logToAdd.blockHash && logInHistory.logIndex === logToAdd.logIndex; }))
return [2 /*return*/, "continue"];
ensureOrder(logHistory.last(), logToAdd);
return [4 /*yield*/, addNewLogToHead(logHistory, logToAdd, onLogAdded)];
case 1:
logHistory = _a.sent();
return [2 /*return*/];
}
});
// we may already have this log because two filters can return the same log
if (logHistory.some(function (logInHistory) { return logInHistory.blockHash === logToAdd.blockHash && logInHistory.logIndex === logToAdd.logIndex; }))
return "continue";
ensureOrder(logHistory.last(), logToAdd);
logHistory = logHistory.push(logToAdd);
addedLogs.push(logToAdd);
};
_i = 0, sortedLogs_1 = sortedLogs;
_a.label = 1;
for (_i = 0, sortedLogs_1 = sortedLogs; _i < sortedLogs_1.length; _i++) {
logToAdd = sortedLogs_1[_i];
_loop_1(logToAdd);
}
// CONSIDER: the user getting this notification won't have any visibility into the updated log history yet. should we announce new logs in a `setTimeout`? should we provide log history with new logs?
return [4 /*yield*/, onLogsAdded(blockHash, addedLogs)];
case 1:
if (!(_i < sortedLogs_1.length)) return [3 /*break*/, 4];
logToAdd = sortedLogs_1[_i];
return [5 /*yield**/, _loop_1(logToAdd)];
case 2:
// CONSIDER: the user getting this notification won't have any visibility into the updated log history yet. should we announce new logs in a `setTimeout`? should we provide log history with new logs?
_a.sent();
_a.label = 3;
case 3:
_i++;
return [3 /*break*/, 1];
case 4: return [2 /*return*/, logHistory];
return [2 /*return*/, logHistory];
}

@@ -126,16 +117,2 @@ });

}); };
var addNewLogToHead = function (logHistory, newLog, onLogAdded) { return __awaiter(_this, void 0, void 0, function () {
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
logHistory = logHistory.push(newLog);
// CONSIDER: the user getting this notification won't have any visibility into the updated log history yet. should we announce new logs in a `setTimeout`? should we provide log history with new logs?
return [4 /*yield*/, onLogAdded(newLog)];
case 1:
// CONSIDER: the user getting this notification won't have any visibility into the updated log history yet. should we announce new logs in a `setTimeout`? should we provide log history with new logs?
_a.sent();
return [2 /*return*/, logHistory];
}
});
}); };
var ensureOrder = function (headLog, newLog) {

@@ -155,3 +132,4 @@ if (headLog === undefined)

};
exports.reconcileLogHistoryWithRemovedBlock = function (logHistory, removedBlock, onLogRemoved) { return __awaiter(_this, void 0, void 0, function () {
exports.reconcileLogHistoryWithRemovedBlock = function (logHistory, removedBlock, onLogsRemoved) { return __awaiter(_this, void 0, void 0, function () {
var removedLogs;
return __generator(this, function (_a) {

@@ -162,11 +140,10 @@ switch (_a.label) {

logHistory = _a.sent();
_a.label = 2;
removedLogs = [];
while (!logHistory.isEmpty() && logHistory.last().blockHash === removedBlock.hash) {
removedLogs.push(logHistory.last());
logHistory = logHistory.pop();
}
return [4 /*yield*/, onLogsRemoved(removedBlock.hash, removedLogs)];
case 2:
if (!(!logHistory.isEmpty() && logHistory.last().blockHash === removedBlock.hash)) return [3 /*break*/, 4];
return [4 /*yield*/, onLogRemoved(logHistory.last())];
case 3:
_a.sent();
logHistory = logHistory.pop();
return [3 /*break*/, 2];
case 4:
// sanity check, no known way to trigger the error

@@ -173,0 +150,0 @@ if (logHistory.some(function (log) { return log.blockHash === removedBlock.hash; }))

import { Block } from "./block";
import { List as ImmutableList } from "immutable";
export declare type BlockHistory<TBlock extends Block> = ImmutableList<TBlock>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=block-history.js.map

@@ -0,0 +0,0 @@ export interface Block {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=block.js.map

@@ -0,0 +0,0 @@ export interface Filter {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=filters.js.map
import { Log } from "./log";
import { List as ImmutableList } from "immutable";
export declare type LogHistory<TLog extends Log> = ImmutableList<TLog>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=log-history.js.map

@@ -0,0 +0,0 @@ export interface Log {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=log.js.map

@@ -0,0 +0,0 @@ export interface Transaction {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=transaction.js.map
export declare const parseHexInt: (value: string) => number;

@@ -0,0 +0,0 @@ "use strict";

{
"name": "ethereumjs-blockstream",
"version": "6.0.1",
"version": "7.0.0",
"description": "A library to turn an unreliable remote source of Ethereum blocks into a reliable stream of blocks with removals on re-orgs and backfills on skips.",

@@ -5,0 +5,0 @@ "main": "output/source/index.js",

@@ -5,2 +5,7 @@ [![Build Status](https://travis-ci.org/ethereumjs/ethereumjs-blockstream.svg?branch=master)](https://travis-ci.org/ethereumjs/ethereumjs-blockstream) [![Coverage Status](https://coveralls.io/repos/ethereumjs/ethereumjs-blockstream/badge.svg?branch=master&service=github)](https://coveralls.io/github/ethereumjs/ethereumjs-blockstream?branch=master) [![npm version](https://badge.fury.io/js/ethereumjs-blockstream.svg)](https://badge.fury.io/js/ethereumjs-blockstream)

# Requirements for supported Ethereum node
Blockstream requires support for [EIP-234](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-234.md) in the configured Ethereum node. EIP-234 was merged Jul 28, 2018 and implemented in Geth and Parity shortly after. Versions that provide the needed functionality:
- Parity: v2.1.0+
- geth: v1.8.13+
# Usage

@@ -7,0 +12,0 @@

@@ -33,4 +33,4 @@ import { Block } from "./models/block";

private readonly onBlockRemovedSubscribers: { [propName: string]: (block: TBlock) => void } = {};
private readonly onLogAddedSubscribers: { [propName: string]: (log: TLog) => void } = {};
private readonly onLogRemovedSubscribers: { [propName: string]: (log: TLog) => void } = {};
private readonly onLogsAddedSubscribers: { [propName: string]: (blockHash: string, logs: Array<TLog>) => void } = {};
private readonly onLogsRemovedSubscribers: { [propName: string]: (blockHash: string, logs: Array<TLog>) => void } = {};

@@ -85,3 +85,3 @@ /**

const logFilters = Object.keys(this.logFilters).map(key => this.logFilters[key]);
this.logHistory = reconcileLogHistoryWithAddedBlock(this.getLogs, this.logHistory, block, this.onLogAdded, logFilters, this.blockRetention);
this.logHistory = reconcileLogHistoryWithAddedBlock(this.getLogs, this.logHistory, block, this.onLogsAdded, logFilters, this.blockRetention);
await this.logHistory;

@@ -91,3 +91,3 @@ };

private readonly onBlockRemoved = async (block: TBlock): Promise<void> => {
this.logHistory = reconcileLogHistoryWithRemovedBlock(this.logHistory, block, this.onLogRemoved);
this.logHistory = reconcileLogHistoryWithRemovedBlock(this.logHistory, block, this.onLogsRemoved);
await this.logHistory;

@@ -101,14 +101,14 @@

private readonly onLogAdded = async (log: TLog): Promise<void> => {
Object.keys(this.onLogAddedSubscribers)
.map((key: string) => this.onLogAddedSubscribers[key])
private readonly onLogsAdded = async (blockHash: string, logs: Array<TLog>): Promise<void> => {
Object.keys(this.onLogsAddedSubscribers)
.map((key: string) => this.onLogsAddedSubscribers[key])
.map(callback => logAndSwallowWrapper(callback, this.onError))
.forEach(callback => this.pendingCallbacks.push(() => callback(log)));
.forEach(callback => this.pendingCallbacks.push(() => callback(blockHash, logs)));
};
private readonly onLogRemoved = async (log: TLog): Promise<void> => {
Object.keys(this.onLogRemovedSubscribers)
.map((key: string) => this.onLogRemovedSubscribers[key])
private readonly onLogsRemoved = async (blockHash: string, logs: Array<TLog>): Promise<void> => {
Object.keys(this.onLogsRemovedSubscribers)
.map((key: string) => this.onLogsRemovedSubscribers[key])
.map(callback => logAndSwallowWrapper(callback, this.onError))
.forEach(callback => this.pendingCallbacks.push(() => callback(log)));
.forEach(callback => this.pendingCallbacks.push(() => callback(blockHash, logs)));
};

@@ -158,30 +158,30 @@

public readonly subscribeToOnLogAdded = (onLogAdded: (log: TLog) => void): string => {
public readonly subscribeToOnLogsAdded = (onLogsAdded: (blockHash: string, logs: Array<TLog>) => void): string => {
const uuid = `on log added token ${createUuid()}`;
this.onLogAddedSubscribers[uuid] = onLogAdded;
this.onLogsAddedSubscribers[uuid] = onLogsAdded;
return uuid;
};
public readonly unsubscribeFromOnLogAdded = (token: string) => {
public readonly unsubscribeFromOnLogsAdded = (token: string) => {
if (!token.startsWith("on log added token ")) throw new Error(`Expected a log added subscription token. Actual: ${token}`);
delete this.onLogAddedSubscribers[token];
delete this.onLogsAddedSubscribers[token];
};
public readonly subscribeToOnLogRemoved = (onLogRemoved: (log: TLog) => void): string => {
public readonly subscribeToOnLogsRemoved = (onLogsRemoved: (blockHash: string, logs: Array<TLog>) => void): string => {
const uuid = `on log removed token ${createUuid()}`;
this.onLogRemovedSubscribers[uuid] = onLogRemoved;
this.onLogsRemovedSubscribers[uuid] = onLogsRemoved;
return uuid;
};
public readonly unsubscribeFromOnLogRemoved = (token: string) => {
public readonly unsubscribeFromOnLogsRemoved = (token: string) => {
if (!token.startsWith("on log removed token ")) throw new Error(`Expected a log added subscription token. Actual: ${token}`);
delete this.onLogRemovedSubscribers[token];
delete this.onLogsRemovedSubscribers[token];
};
}
function logAndSwallowWrapper<T>(callback: (arg: T) => void, onError: (error: Error) => void): (arg: T) => void {
return function (parameter) {
function logAndSwallowWrapper<T, U>(callback: (arg1?: T, arg2?: U) => void, onError: (error: Error) => void): (arg1?: T, arg2?: U) => void {
return function (parameter1, parameter2) {
try {
callback(parameter);
callback(parameter1, parameter2);
} catch (error) {

@@ -188,0 +188,0 @@ onError(error);

@@ -11,3 +11,3 @@ import { Block } from "./models/block";

newBlock: TBlock,
onLogAdded: (log: TLog) => Promise<void>,
onLogsAdded: (blockHash: string, logs: Array<TLog>) => Promise<void>,
filters: Filter[] = [],

@@ -18,3 +18,3 @@ historyBlockLength: number = 100,

const logs = await getFilteredLogs(getLogs, newBlock, filters);
logHistory = await addNewLogsToHead(logHistory, logs, onLogAdded);
logHistory = await addNewLogsToHead(newBlock.hash, logHistory, logs, onLogsAdded);
logHistory = await pruneOldLogs(logHistory, newBlock, historyBlockLength);

@@ -32,4 +32,5 @@ return logHistory;

const addNewLogsToHead = async <TLog extends Log>(logHistory: LogHistory<TLog>, newLogs: Array<TLog>, onLogAdded: (log: TLog) => Promise<void>): Promise<LogHistory<TLog>> => {
const addNewLogsToHead = async <TLog extends Log>(blockHash: string, logHistory: LogHistory<TLog>, newLogs: Array<TLog>, onLogsAdded: (blockHash: string, logs: Array<TLog>) => Promise<void>): Promise<LogHistory<TLog>> => {
const sortedLogs = newLogs.sort((logA, logB) => parseHexInt(logA.logIndex) - parseHexInt(logB.logIndex));
const addedLogs: Array<TLog> = []
for (const logToAdd of sortedLogs) {

@@ -39,4 +40,7 @@ // we may already have this log because two filters can return the same log

ensureOrder(logHistory.last(), logToAdd);
logHistory = await addNewLogToHead(logHistory, logToAdd, onLogAdded);
logHistory = logHistory.push(logToAdd)
addedLogs.push(logToAdd)
}
// CONSIDER: the user getting this notification won't have any visibility into the updated log history yet. should we announce new logs in a `setTimeout`? should we provide log history with new logs?
await onLogsAdded(blockHash, addedLogs)
return logHistory;

@@ -50,9 +54,2 @@ }

const addNewLogToHead = async <TLog extends Log>(logHistory: LogHistory<TLog>, newLog: TLog, onLogAdded: (log: TLog) => Promise<void>): Promise<LogHistory<TLog>> => {
logHistory = logHistory.push(newLog);
// CONSIDER: the user getting this notification won't have any visibility into the updated log history yet. should we announce new logs in a `setTimeout`? should we provide log history with new logs?
await onLogAdded(newLog);
return logHistory;
}
const ensureOrder = <TLog extends Log>(headLog: TLog | undefined, newLog: TLog) => {

@@ -72,10 +69,12 @@ if (headLog === undefined) return;

removedBlock: TBlock,
onLogRemoved: (log: TLog) => Promise<void>,
onLogsRemoved: (blockHash: string, logs: Array<TLog>) => Promise<void>,
): Promise<LogHistory<TLog>> => {
logHistory = await logHistory;
const removedLogs = []
while (!logHistory.isEmpty() && logHistory.last().blockHash === removedBlock.hash) {
await onLogRemoved(logHistory.last());
removedLogs.push(logHistory.last());
logHistory = logHistory.pop();
}
await onLogsRemoved(removedBlock.hash, removedLogs);

@@ -82,0 +81,0 @@ // sanity check, no known way to trigger the error

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc