blockchain_go/main.go

31 lines
514 B
Go
Raw Normal View History

2017-08-15 02:05:02 -05:00
package main
import (
"fmt"
"strconv"
)
2017-08-15 02:20:34 -05:00
2017-08-15 02:05:02 -05:00
func main() {
bc := NewBlockchain()
2017-08-15 02:20:34 -05:00
2017-08-28 01:57:27 -05:00
// bc.AddBlock("Send 1 BTC to Ivan")
// bc.AddBlock("Send 2 more BTC to Ivan")
bci := bc.Iterator()
for {
block := bci.Next()
fmt.Printf("Prev. hash: %x\n", block.PrevBlockHash)
2017-08-16 02:20:18 -05:00
fmt.Printf("Data: %s\n", block.Data)
fmt.Printf("Hash: %x\n", block.Hash)
pow := NewProofOfWork(block)
fmt.Printf("PoW: %s\n", strconv.FormatBool(pow.Validate()))
2017-08-16 02:20:18 -05:00
fmt.Println()
2017-08-28 01:57:27 -05:00
if len(block.PrevBlockHash) == 0 {
break
}
}
2017-08-15 02:05:02 -05:00
}