31 lines
498 B
Go
31 lines
498 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
func (cli *CLI) printChain() {
|
||
|
bc := NewBlockchain("")
|
||
|
defer bc.db.Close()
|
||
|
|
||
|
bci := bc.Iterator()
|
||
|
|
||
|
for {
|
||
|
block := bci.Next()
|
||
|
|
||
|
fmt.Printf("Prev. hash: %x\n", block.PrevBlockHash)
|
||
|
fmt.Printf("Hash: %x\n", block.Hash)
|
||
|
pow := NewProofOfWork(block)
|
||
|
fmt.Printf("PoW: %s\n", strconv.FormatBool(pow.Validate()))
|
||
|
for _, tx := range block.Transactions {
|
||
|
fmt.Println(tx)
|
||
|
}
|
||
|
fmt.Println()
|
||
|
|
||
|
if len(block.PrevBlockHash) == 0 {
|
||
|
break
|
||
|
}
|
||
|
}
|
||
|
}
|