0xs34n / blockchain-cli

⛓️ A minimal blockchain command-line interface.
Apache License 2.0
1.16k stars 169 forks source link

Fixed time display and hash display #20

Open gengxuelei opened 6 years ago

gengxuelei commented 6 years ago

fix time display

https://github.com/seanjameshan/blockchain-cli/blob/master/lib/cli/util/table.js#L26 the function 'toUTCString' should be changed to 'toISOString' (the toUTCString function will lose milliseconds that lead to sha256(block) different) It's best to get rid of 'timeStamp/1000' but use timeStamp directly

fix hash display

https://github.com/seanjameshan/blockchain-cli/blob/master/lib/cli/util/table.js#L10 this line should be changed to 'colWidths:[20,66]' to show hash fully : https://github.com/seanjameshan/blockchain-cli/issues/13

make judgment more precise

https://github.com/seanjameshan/blockchain-cli/blob/master/lib/blockchain/index.js#L128 this line should be changed to 'return i >= this.difficulty;' ; the hash should contains at least difficulty zero

show mining time:

https://github.com/seanjameshan/blockchain-cli/blob/master/lib/blockchain/index.js#L111 before L111 while there should have a time:

var _beginTime = new Date();

after L116 spinner.clear(); there show have a tips:

console.log("Mining new block use time: ", new Date() - _beginTime, "ms")
ghost commented 4 years ago

Hi, follow this link to download a problem-free version. https://github.com/anders94/blockchain-demo/