Skip to content

Instantly share code, notes, and snippets.

@sontuphan
Created February 27, 2018 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sontuphan/7f8c9dbe90c75120b5150b65e6d99330 to your computer and use it in GitHub Desktop.
Save sontuphan/7f8c9dbe90c75120b5150b65e6d99330 to your computer and use it in GitHub Desktop.
var merklePatriciaTree = require('merkle-patricia-tree');
var rlp = require('rlp');
var db = global.db;
var Trie = function () {}
Trie.getInfoByAddress = function (root, address) {
var root = new Buffer(root, 'hex');
var address = new Buffer(address, 'hex');
var trie = new merklePatriciaTree(db, root);
trie.get(address, function (er, re) {
if (er) throw new Error(er);
var decoded = rlp.decode(re);
return console.log('Address Data:', decoded);
});
}
Trie.checkRoot = function (root) {
var root = new Buffer(root, 'hex');
var trie = new merklePatriciaTree(db, root);
trie.checkRoot(root, function (er, re) {
return console.log('Check root:', er, re);
});
}
module.exports = Trie
@Yoio
Copy link

Yoio commented Oct 8, 2019

nice work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment