該項(xiàng)目目標(biāo)是實(shí)現(xiàn)一個(gè)最小的可運(yùn)行版本的類似bitcoin的blockchain。
- 目的:
- 闡述bitcoin的機(jī)制
- 熟悉相關(guān)知識(shí)點(diǎn)
github地址:bitcoinlitelite
v0.1.0地址:bitcoinlitelite
-
說明:
- 目前Transaction,包括概念里,并沒有代幣的概念,之后再加。所以,目前的Transaction里包含的交易雙方的信息,以及一句話。
- 目前的打包邏輯是:
- 遇到5個(gè)Transaction就開始打包
- 1分鐘到了,Transaction不及5個(gè)
測(cè)試運(yùn)行:
目前暫定首個(gè)節(jié)點(diǎn) 端口是 8091,在代碼 https://github.com/jasoncodingnow/bitcoinLiteLite/blob/master/main.go L 110,請(qǐng)自行修改為當(dāng)前機(jī)器的局域網(wǎng)地址
git clone https://github.com/jasoncodingnow/bitcoinLiteLite.git
cd github.com/jasoncodingnow/bitcoinLiteLite
go build .
// 啟動(dòng)第一個(gè)節(jié)點(diǎn)
./bitcoinLiteLite port 8091
// 查看console可以看到第一個(gè)節(jié)點(diǎn)的 publicKey, 假設(shè)是 8091PUBLISKEY
// 啟動(dòng)第二個(gè)節(jié)點(diǎn)
./bitcoinLiteLite port 8092
// 測(cè)試 由第二個(gè)節(jié)點(diǎn)生成一筆Transaction,并廣播
// 目前,5個(gè)Transaction會(huì)打包,或者比如1個(gè)Transaction,會(huì)在1分鐘內(nèi)打包
// 在第二個(gè)節(jié)點(diǎn)的console輸入Transaction命令。第一個(gè)參數(shù)是要傳播給誰,第二個(gè)參數(shù)是消息是什么
8091PUBLISKEY hi
// 等待一分鐘打包