@rainblock/merkle-patricia-tree
An implementation of the modified merkle patricia tree used in Ethereum, optimized for in-memory usage
Last updated a year ago by no2chem .
MPL-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @rainblock/merkle-patricia-tree 
SYNC missed versions from official npm registry.

☔️???? RainBlock's In-Memory Merkle Tree

NPM Package Build Status Coverage Status node

@rainblock/merkle-patricia-tree is an in-memory merkle tree which conforms to the specifications of the modified merkle patricia tree used by Ethereum. It is a fork of the EthereumJS library, and released under the same license, however, the API has changed to be synchronous instead of callback based. The goals of @rainblock/merkle-patricia-tree are to be:

  • In-Memory Optimized. @rainblock/merkle-patricia-tree is optimized for in-memory use and does not support persistence.

  • High performance. By taking advantage of in-memory optimizations, @rainblock/merkle-patricia-tree aims to be high performance - currently, it is 2-8x more performant than EthereumJS's merkle tree on standard benchmarks.

  • Well documented. API documentation is automatically generated from the JSdoc embedded in the typescript source, and the source code aims to be commented and maintainable.

  • Ethereum compatible. The root hashes produced by @rainblock/merkle-patricia-tree should produce the same root hashes as other Ethereum merkle tree libraries given the same input data.

Install

Add @rainblock/merkle-patricia-tree to your project with:

npm install @rainblock/merkle-patricia-tree

Usage

Basic API documentation can be found here, but the following example shows basic use of puts and gets and verification:

import {MerklePatriciaTree, VerifyWitness} from '@rainblock/merkle-patricia-tree';
const tree = new MerklePatriciaTree();

tree.put(Buffer.from('a'), Buffer.from('b'));

// Get returns a witness which contains { value, proof }
const witness = tree.get(Buffer.from('a'));

// VerifyWitness will throw an error if the proof doesn't match the given root
VerifyWitness(witness, tree.root);

Benchmarks

Benchmarks can be run by executing npm run benchmark from the package directory.

Current Tags

  • 4.9.0                                ...           latest (a year ago)

14 Versions

  • 4.9.0                                ...           a year ago
  • 4.8.0                                ...           a year ago
  • 4.7.0                                ...           a year ago
  • 4.6.0                                ...           a year ago
  • 4.5.0                                ...           a year ago
  • 4.4.0                                ...           a year ago
  • 4.3.1                                ...           a year ago
  • 4.3.0                                ...           a year ago
  • 4.2.0                                ...           a year ago
  • 4.1.0                                ...           a year ago
  • 4.0.0                                ...           2 years ago
  • 3.1.0                                ...           2 years ago
  • 3.0.1                                ...           2 years ago
  • 3.0.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (10)
Dev Dependencies (25)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |