Skip to content

Instantly share code, notes, and snippets.

Phan Sơn Tự sontuphan

  • Ho Chi Minh City University of Technology (Bach Khoa)
  • Ho Chi Minh City
Block or report user

Report or block sontuphan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View accountParser.js
var db = global.db;
var ethBlock = require('ethereumjs-block');
var rlp = require('rlp');
var utils = require('./libs/utils');
var geth = require('./libs/geth');
var trie = require('./libs/trie');
View trie.js
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);
View leveldb.js
var path = require('path');
var levelup = require('levelup');
var leveldown = require('leveldown');
/**
* Level DB
*/
var levelDBPath = path.relative('./', '/Users/User/Library/Ethereum/ropsten/geth/chaindata');
var db = levelup(leveldown(levelDBPath));
View geth.js
var Web3 = require('web3');
var web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
console.log("\n===========================================");
console.log("========== Geth connected:", web3.isConnected(), "===========");
console.log("===========================================\n");
var Geth = function () {}
Geth.getStateRoot = function (blockNumber) {
View merkledataset.js
{
'cab8': 'dog',
'cabe': 'cat',
'39': 'chicken',
'395': 'duck',
'56f0': 'horse'
}
View dataset.js
{
do: 0,
dog: 1,
dax: 2,
dogu: 3,
dodo: 4,
house: 5,
houses: 6
}
View ExHPencoding
> [ 1, 2, 3, 4, 5]
'11 23 45'
> [ 0, 1, 2, 3, 4, 5]
'00 01 23 45'
> [ 0, f, 1, c, b, 8, 16]
'20 0f 1c b8'
> [ f, 1, c, b, 8, 16]
'3f 1c b8'
View HPencoding
node type path length | prefix hexchar
--------------------------------------------------
extension even | 0000 0x0
extension odd | 0001 0x1
leaf even | 0010 0x2
leaf odd | 0011 0x3
View trie.js
Root: {1: 'Dog', 2: B, 3: A}
A: {1: C, 2: D, 3: 'Cat'}
B: {1: 'Goat', 2: 'Bear', 3: 'Rat'}
C: {1: 'Eagle', 2: 'Parrot', 3: E}
D: {1: 'Shark', 2: 'Dolphin', 3: 'Whale'}
E: {1: 'Duck', 2: 'Chinken', 3: 'Pig'}
View hashOfCombination.js
// Hash algorithm is Keccak256
var s = Math.floor((Math.random() * 1000000000) + 1); // s = 830178382
var selection = ‘rock’;
var combination = selection + s; // combination = ‘rock830178382’
var hashOfCombination = keccak256(combination);
// hashOfCombination = 4d49bb261ecb887e152051da601d028e070635d24da07da2828fca8fecedee50
You can’t perform that action at this time.