Created
February 27, 2018 02:32
-
-
Save sontuphan/7f8c9dbe90c75120b5150b65e6d99330 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice work