最近看好幾天以太坊的源碼沒(méi)看出個(gè)所以然低斋。一般研究一個(gè)項(xiàng)目代碼一般是把項(xiàng)目先跑起來(lái)黄选〉看了半天沒(méi)找到代碼入口免猾。
https://github.com/ethereum/pyethereum
這個(gè)是目前的分支,可以看到已經(jīng)非常復(fù)雜了眉反。
由github的commit記錄我們可以大致確定以太坊的主要代碼昙啄。即鏈接:https://github.com/ethereum/pyethereum/tree/e476fb19bc0d55fb120772c175e438e21a0cefb1
blocks.py
parser.py
processblock.py
rlp.py
transactions.py
trie.py
trietest.py
這幾部分組成。
從這個(gè)地方我們看到大體的運(yùn)行流程
https://github.com/ethereum/pyethereum/tree/e658ce7386edb20c04910cb3bca6389399bcaaeb
test_rlp.py
test_trie.py
是以太坊的主要組成的兩部分寸五。
rlp應(yīng)該是一種編碼方法
trie應(yīng)該是一種樹(shù)形結(jié)構(gòu)
processblock組織起了transactions和block
blocks.py
transactions.py
如何讀懂以太坊需要先弄明白兩部分梳凛,即rlp,trie與blocks梳杏,transactions韧拒。
runtest是一部分
https://github.com/ethereum/pyethereum/blob/e658ce7386edb20c04910cb3bca6389399bcaaeb/runtest.py
密碼學(xué)、P2P網(wǎng)絡(luò)通信十性、共識(shí)算法
插播
Andreas Antonopoulos的《完全掌握比特幣》(Mastering Bitcoin)
Consensys的《用剛剛夠的比特幣來(lái)搞懂以太坊》(Just Enough Bitcoin for Ethereum)