New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ethereumjs-blockstream

Package Overview
Dependencies
Maintainers
2
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 3.0.0 to 3.1.0

46

output/source/block-and-log-streamer.js

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

var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;
return { next: verb(0), "throw": verb(1), "return": verb(2) };
function verb(n) { return function (v) { return step([n, v]); }; }

@@ -43,3 +43,3 @@ function step(op) {

var createUuid = require("uuid");
var BlockAndLogStreamer = /** @class */ (function () {
var BlockAndLogStreamer = (function () {
function BlockAndLogStreamer(getBlockByHash, getLogs, configuration) {

@@ -190,26 +190,26 @@ var _this = this;

}
BlockAndLogStreamer.createCallbackStyle = function (getBlockByHash, getLogs, configuration) {
var wrappedGetBlockByHash = function (hash) {
return new Promise(function (resolve, reject) {
getBlockByHash(hash, function (error, block) {
if (error)
throw error;
else
resolve(block);
});
});
};
var wrappedGetLogs = function (filterOptions) { return new Promise(function (resolve, reject) {
getLogs(filterOptions, function (error, logs) {
return BlockAndLogStreamer;
}());
BlockAndLogStreamer.createCallbackStyle = function (getBlockByHash, getLogs, configuration) {
var wrappedGetBlockByHash = function (hash) {
return new Promise(function (resolve, reject) {
getBlockByHash(hash, function (error, block) {
if (error)
throw error;
if (!logs)
throw new Error("Received null/undefined logs and no error.");
resolve(logs);
else
resolve(block);
});
}); };
return new BlockAndLogStreamer(wrappedGetBlockByHash, wrappedGetLogs, configuration);
});
};
return BlockAndLogStreamer;
}());
var wrappedGetLogs = function (filterOptions) { return new Promise(function (resolve, reject) {
getLogs(filterOptions, function (error, logs) {
if (error)
throw error;
if (!logs)
throw new Error("Received null/undefined logs and no error.");
resolve(logs);
});
}); };
return new BlockAndLogStreamer(wrappedGetBlockByHash, wrappedGetLogs, configuration);
};
exports.BlockAndLogStreamer = BlockAndLogStreamer;

@@ -216,0 +216,0 @@ function logAndSwallowWrapper(callback) {

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

var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;
return { next: verb(0), "throw": verb(1), "return": verb(2) };
function verb(n) { return function (v) { return step([n, v]); }; }

@@ -52,20 +52,27 @@ function step(op) {

case 3:
if (!isOlderThanOldestBlock(blockHistory, newBlock)) return [3 /*break*/, 6];
return [4 /*yield*/, rollback(blockHistory, onBlockRemoved)];
case 4:
blockHistory = _a.sent();
return [4 /*yield*/, addNewHeadBlock(blockHistory, newBlock, onBlockAdded, blockRetention)];
case 5: return [2 /*return*/, _a.sent()];
case 6:
if (isAlreadyInHistory(blockHistory, newBlock))
return [2 /*return*/, blockHistory];
if (!isNewHeadBlock(blockHistory, newBlock)) return [3 /*break*/, 5];
if (!isNewHeadBlock(blockHistory, newBlock)) return [3 /*break*/, 8];
return [4 /*yield*/, addNewHeadBlock(blockHistory, newBlock, onBlockAdded, blockRetention)];
case 4: return [2 /*return*/, _a.sent()];
case 5:
if (!parentHashIsInHistory(blockHistory, newBlock)) return [3 /*break*/, 10];
_a.label = 6;
case 6:
if (!(blockHistory.last().hash !== newBlock.parentHash)) return [3 /*break*/, 8];
case 7: return [2 /*return*/, _a.sent()];
case 8:
if (!parentHashIsInHistory(blockHistory, newBlock)) return [3 /*break*/, 13];
_a.label = 9;
case 9:
if (!(blockHistory.last().hash !== newBlock.parentHash)) return [3 /*break*/, 11];
return [4 /*yield*/, removeHeadBlock(blockHistory, onBlockRemoved)];
case 7:
case 10:
blockHistory = _a.sent();
return [3 /*break*/, 6];
case 8: return [4 /*yield*/, addNewHeadBlock(blockHistory, newBlock, onBlockAdded, blockRetention)];
case 9: return [2 /*return*/, _a.sent()];
case 10: return [4 /*yield*/, backfill(getBlockByHash, blockHistory, newBlock, onBlockAdded, onBlockRemoved, blockRetention)];
case 11: return [2 /*return*/, _a.sent()];
return [3 /*break*/, 9];
case 11: return [4 /*yield*/, addNewHeadBlock(blockHistory, newBlock, onBlockAdded, blockRetention)];
case 12: return [2 /*return*/, _a.sent()];
case 13: return [4 /*yield*/, backfill(getBlockByHash, blockHistory, newBlock, onBlockAdded, onBlockRemoved, blockRetention)];
case 14: return [2 /*return*/, _a.sent()];
}

@@ -145,2 +152,5 @@ });

};
var isOlderThanOldestBlock = function (blockHistory, newBlock) {
return parseInt(blockHistory.first().number, 16) > parseInt(newBlock.number, 16);
};
var isAlreadyInHistory = function (blockHistory, newBlock) {

@@ -147,0 +157,0 @@ // `block!` is required until the next version of `immutable` is published to NPM (current version 3.8.1) which improves the type definitions

@@ -1,2 +0,1 @@

"use strict";
// NOTE --

@@ -9,2 +8,3 @@ // Commented out to avoid cross origin error produced when running again webpack

// sourceMapSupport.install();
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

@@ -11,0 +11,0 @@ var block_and_log_streamer_1 = require("./block-and-log-streamer");

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

var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;
return { next: verb(0), "throw": verb(1), "return": verb(2) };
function verb(n) { return function (v) { return step([n, v]); }; }

@@ -15,0 +15,0 @@ function step(op) {

{
"name": "ethereumjs-blockstream",
"version": "3.0.0",
"version": "3.1.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",

@@ -19,2 +19,7 @@ import { Block } from "./models/block";

if (isOlderThanOldestBlock(blockHistory, newBlock)) {
blockHistory = await rollback(blockHistory, onBlockRemoved);
return await addNewHeadBlock(blockHistory, newBlock, onBlockAdded, blockRetention);
}
if (isAlreadyInHistory(blockHistory, newBlock))

@@ -71,6 +76,10 @@ return blockHistory;

const isFirstBlock = <TBlock extends Block>(blockHistory: BlockHistory<TBlock>, ): boolean => {
const isFirstBlock = <TBlock extends Block>(blockHistory: BlockHistory<TBlock>): boolean => {
return blockHistory.isEmpty();
}
const isOlderThanOldestBlock = <TBlock extends Block>(blockHistory: BlockHistory<TBlock>, newBlock: TBlock): boolean => {
return parseInt(blockHistory.first().number, 16) > parseInt(newBlock.number, 16);
}
const isAlreadyInHistory = <TBlock extends Block>(blockHistory: BlockHistory<TBlock>, newBlock: TBlock): boolean => {

@@ -77,0 +86,0 @@ // `block!` is required until the next version of `immutable` is published to NPM (current version 3.8.1) which improves the type definitions

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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