Created
April 9, 2019 02:51
-
-
Save zmitton/aa459f01c3b0d393fc8b0f5b78c3d994 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
/* | |
.load personal/eip161.js | |
*/ | |
var { Account, Header, Log, Proof, Receipt, Transaction } = require('eth-object') | |
var rlp = require('rlp'); | |
var lu = require('levelup') | |
var ld = require('leveldown') | |
var d = ld('/Users/zacharymitton/Library/Ethereum/classic/geth/chaindata') | |
var db = lu(d) | |
var sha3 = require('js-sha3').keccak_256 | |
var h = (x) => { return Buffer.from(sha3(x),'hex') } | |
// stateRoot = new Buffer('97fb274dbf35776cf0837c76438bb0804ea7b6152da3c8b53c663caf00e17be5', 'hex') | |
var stateRoot = new Buffer('c57ceb9cf2c2f1844f4796ca0b384906a011f95b8c556c6025a77f35bf47c33e', 'hex') | |
var Trie = require('merkle-patricia-tree'); | |
var trie = new Trie(db, stateRoot); | |
var _rlp = (e,r)=>{ | |
if(e){ | |
console.log("NOT FOUND") | |
}else{ | |
console.log(rlp.decode(r)) | |
return Account.fromBuffer(r) | |
} | |
} | |
var b = (buf)=>{ | |
let accumulator = [] | |
let chopped = buf.slice(8,103) | |
for (var i = 0; i < 32; i++) { | |
accumulator.push(chopped[i*3]) | |
accumulator.push(chopped[i*3+1]) | |
} | |
return Buffer.from(accumulator.join(''),'hex') | |
} | |
// var trie.get(h(Buffer.from('a195092c8aD03cf3c94f41B9631C4390b9Fd160C','hex')), console.log) | |
trie.db.get(Buffer.from('c57ceb9cf2c2f1844f4796ca0b384906a011f95b8c556c6025a77f35bf47c33e','hex'),_rlp) | |
var total = 0 | |
var getNext = (hash) => { | |
trie.db.get(hash, (hash)=>{ | |
let node = rlp.decode(hash) | |
for (var i = 0; i < node; i++) { | |
if(!node[i].equals(Buffer.alloc(0))){ | |
getNext() | |
} | |
} | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment