搭建迷你区块链

网课笔记码住

代码开源如下:​​https://github.com/betachen/tinychain​

搭建迷你区块链_3d


搭建迷你区块链_3d_02


搭建迷你区块链_区块链_03

tinychain
├── blockchain
├── consensus
├── database
├── network
├── http-server
└── node

搭建迷你区块链_区块链_04

cli-tinychain
├── JSON
└── http-client

搭建迷你区块链_3d_05

基础组件
├── log
├── JSON-paser
├── sha256
└── key-pair

搭建迷你区块链_json_06

{
“target_bits” : “4575460831240”,
“hash” :
“4a9169e2f4f8673ac9627be0fa0f9e15a9e3b1bc5cd697d96954d25acacd92df”,
“merkle_tree_hash” : “3d228afc50bc52491f5dd8aa8c416da0d9a16bf829790ea0b7635e5b4d44ab4f”,
“nonce” : “3852714822920177480”,
“height” : 1234567,
“previous_block_hash” : “4d2544e044bfd2f342220a711b10842bb6cfae551b1bc1ed6152ff5c7f3ff654”,
“time_stamp” : 1528070857,
“transaction_count” : 1,
“version” : 1
}

搭建迷你区块链_json_07

{
“hash”: “8c14f0db3df150123e6f3dbbf30f8b955a8249b62ac1d1ff16284aefa3d06d87”,
“version”: 1,
“input_size”: 1,
“output_size”: 1,
“size”: 135,
“inputs”: [{
“prev_out”: {
“hash”: “0000000000000000000000000000000000000000000000000000000000000000”,
“index”:0
iq },
}],
“out”: [{
“value”: “5000000000”,
“address”: “f3e6066078e815bb2”
}],
}

搭建迷你区块链_3d_08


搭建迷你区块链_json_09


一些Python实现迷你区块链的例子:

​http://adilmoujahid.com/posts/2018/03/intro-blockchain-bitcoin-python/​