Improve the printchain command

This commit is contained in:
Ivan Kuznetsov 2017-09-10 14:31:01 +07:00
parent 7b6d5695d3
commit c0b4d6d107
2 changed files with 13 additions and 13 deletions

View File

@ -14,14 +14,14 @@ func (cli *CLI) printChain() {
for { for {
block := bci.Next() block := bci.Next()
fmt.Printf("Prev. hash: %x\n", block.PrevBlockHash) fmt.Printf("============ Block %x ============\n", block.Hash)
fmt.Printf("Hash: %x\n", block.Hash) fmt.Printf("Prev. block: %x\n", block.PrevBlockHash)
pow := NewProofOfWork(block) pow := NewProofOfWork(block)
fmt.Printf("PoW: %s\n", strconv.FormatBool(pow.Validate())) fmt.Printf("PoW: %s\n\n", strconv.FormatBool(pow.Validate()))
for _, tx := range block.Transactions { for _, tx := range block.Transactions {
fmt.Println(tx) fmt.Println(tx)
} }
fmt.Println() fmt.Printf("\n\n")
if len(block.PrevBlockHash) == 0 { if len(block.PrevBlockHash) == 0 {
break break

View File

@ -89,7 +89,7 @@ func (tx *Transaction) Sign(privKey ecdsa.PrivateKey, prevTXs map[string]Transac
func (tx Transaction) String() string { func (tx Transaction) String() string {
var lines []string var lines []string
lines = append(lines, fmt.Sprintf("Transaction %x:", tx.ID)) lines = append(lines, fmt.Sprintf("--- Transaction %x:", tx.ID))
for i, input := range tx.Vin { for i, input := range tx.Vin {