Socket
Socket
Sign inDemoInstall

@ethereumjs/blockchain

Package Overview
Dependencies
Maintainers
6
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethereumjs/blockchain - npm Package Compare versions

Comparing version 5.0.0-beta.2 to 5.0.0-rc.1

6

CHANGELOG.md

@@ -9,2 +9,8 @@ # Changelog

## 5.0.0-rc.1 2020-11-19
This is the first release candidate towards a final library release, see [beta.2](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Fblockchain%405.0.0-beta.2) and especially [beta.1](https://github.com/ethereumjs/ethereumjs-vm/releases/tag/%40ethereumjs%2Fblockchain%405.0.0-beta.1) release notes for an overview on the full changes since the last publicly released version.
- Exposed private `Blockchain._getTd()` total difficulty function as `Blockchain.getTotalDifficulty()`, PR [#956](https://github.com/ethereumjs/ethereumjs-vm/issues/956)
## 5.0.0-beta.2 - 2020-11-12

@@ -11,0 +17,0 @@

2

dist.browser/db/manager.d.ts

@@ -60,3 +60,3 @@ /// <reference types="node" />

*/
getTd(blockHash: Buffer, blockNumber: BN): Promise<BN>;
getTotalDifficulty(blockHash: Buffer, blockNumber: BN): Promise<BN>;
/**

@@ -63,0 +63,0 @@ * Performs a block hash to block number lookup.

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

*/
DBManager.prototype.getTd = function (blockHash, blockNumber) {
DBManager.prototype.getTotalDifficulty = function (blockHash, blockNumber) {
return __awaiter(this, void 0, void 0, function () {

@@ -235,0 +235,0 @@ var td;

@@ -222,2 +222,6 @@ /// <reference types="node" />

/**
* Gets total difficulty for a block specified by hash and number
*/
getTotalDifficulty(hash: Buffer, number?: BN): Promise<BN>;
/**
* Looks up many blocks relative to blockId Note: due to `GetBlockHeaders

@@ -339,8 +343,2 @@ * (0x03)` (ETH wire protocol) we have to support skip/reverse as well.

/**
* Gets total difficulty for a block specified by hash and number
*
* @hidden
*/
private _getTd;
/**
* This method either returns a Buffer if there exists one in the DB or if it

@@ -347,0 +345,0 @@ * does not exist (DB throws a `NotFoundError`) then return false If DB throws

@@ -60,3 +60,3 @@ /// <reference types="node" />

*/
getTd(blockHash: Buffer, blockNumber: BN): Promise<BN>;
getTotalDifficulty(blockHash: Buffer, blockNumber: BN): Promise<BN>;
/**

@@ -63,0 +63,0 @@ * Performs a block hash to block number lookup.

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

*/
async getTd(blockHash, blockNumber) {
async getTotalDifficulty(blockHash, blockNumber) {
const td = await this.get(operation_1.DBTarget.TotalDifficulty, { blockHash, blockNumber });

@@ -127,0 +127,0 @@ return new ethereumjs_util_1.BN(rlp.decode(td));

@@ -222,2 +222,6 @@ /// <reference types="node" />

/**
* Gets total difficulty for a block specified by hash and number
*/
getTotalDifficulty(hash: Buffer, number?: BN): Promise<BN>;
/**
* Looks up many blocks relative to blockId Note: due to `GetBlockHeaders

@@ -339,8 +343,2 @@ * (0x03)` (ETH wire protocol) we have to support skip/reverse as well.

/**
* Gets total difficulty for a block specified by hash and number
*
* @hidden
*/
private _getTd;
/**
* This method either returns a Buffer if there exists one in the DB or if it

@@ -347,0 +345,0 @@ * does not exist (DB throws a `NotFoundError`) then return false If DB throws

@@ -332,9 +332,9 @@ "use strict";

if (this._headHeaderHash) {
currentTd.header = await this._getTd(this._headHeaderHash);
currentTd.header = await this.getTotalDifficulty(this._headHeaderHash);
}
if (this._headBlockHash) {
currentTd.block = await this._getTd(this._headBlockHash);
currentTd.block = await this.getTotalDifficulty(this._headBlockHash);
}
// calculate the total difficulty of the new block
const parentTd = await this._getTd(header.parentHash, blockNumber.subn(1));
const parentTd = await this.getTotalDifficulty(header.parentHash, blockNumber.subn(1));
td.iadd(parentTd);

@@ -399,2 +399,11 @@ // save block and total difficulty to the database

/**
* Gets total difficulty for a block specified by hash and number
*/
async getTotalDifficulty(hash, number) {
if (!number) {
number = await this.dbManager.hashToNumber(hash);
}
return this.dbManager.getTotalDifficulty(hash, number);
}
/**
* Looks up many blocks relative to blockId Note: due to `GetBlockHeaders

@@ -754,13 +763,2 @@ * (0x03)` (ETH wire protocol) we have to support skip/reverse as well.

/**
* Gets total difficulty for a block specified by hash and number
*
* @hidden
*/
async _getTd(hash, number) {
if (!number) {
number = await this.dbManager.hashToNumber(hash);
}
return this.dbManager.getTd(hash, number);
}
/**
* This method either returns a Buffer if there exists one in the DB or if it

@@ -767,0 +765,0 @@ * does not exist (DB throws a `NotFoundError`) then return false If DB throws

{
"name": "@ethereumjs/blockchain",
"version": "5.0.0-beta.2",
"version": "5.0.0-rc.1",
"description": "A module to store and interact with blocks",

@@ -35,9 +35,9 @@ "main": "dist/index.js",

"bugs": {
"url": "https://github.com/ethereumjs/ethereumjs-vm/issues?q=is%3Aissue+label%3A\"package%3A+blockchain\""
"url": "https://github.com/ethereumjs/ethereumjs-vm/issues?q=is%3Aissue+label%3A%22package%3A+blockchain%22"
},
"homepage": "https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/blockchain#synopsis",
"homepage": "https://github.com/ethereumjs/ethereumjs-vm/tree/master/packages/blockchain#readme",
"dependencies": {
"@ethereumjs/block": "3.0.0-beta.2",
"@ethereumjs/common": "2.0.0-beta.2",
"@ethereumjs/ethash": "1.0.0-beta.1",
"@ethereumjs/block": "3.0.0-rc.1",
"@ethereumjs/common": "2.0.0-rc.1",
"@ethereumjs/ethash": "1.0.0-rc.1",
"ethereumjs-util": "^7.0.7",

@@ -44,0 +44,0 @@ "level-mem": "^5.0.1",

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

# ethereumjs-blockchain
# @ethereumjs/blockchain

@@ -9,3 +9,4 @@ [![NPM Package][blockchain-npm-badge]][blockchain-npm-link]

A module to store and interact with blocks.
| A module to store and interact with blocks. |
| --- |

@@ -12,0 +13,0 @@ Note: this `README` reflects the state of the library from `v5.0.0` onwards. See `README` from the [standalone repository](https://github.com/ethereumjs/ethereumjs-blockchain) for an introduction on the last preceeding release.

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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