-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
35 lines (26 loc) · 1.08 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"go-blockchain/block"
"go-blockchain/message"
)
func main() {
messageM := message.NewMessage()
messageA := message.NewMessage()
messageB := message.NewMessage()
// コンセンサスアルゴリズム未実装
//tr := message.NewTransaction(messageA.PrivateKey(), messageA.PublicKey(), messageA.BlockchainAddress(), messageB.BlockchainAddress(), "Hello")
blockchain := block.NewBlockchain(messageM.BlockchainAddress())
blockchain.AddTransaction(messageA.BlockchainAddress(), messageB.BlockchainAddress(), "hello")
blockchain.AddTransaction(messageB.BlockchainAddress(), messageA.BlockchainAddress(), "Hi !")
blockchain.Mining()
blockchain.Puts()
blockchain.AddTransaction(messageA.BlockchainAddress(), messageB.BlockchainAddress(), "How are you?")
blockchain.Mining()
blockchain.Puts()
blockchain.AddTransaction(messageB.BlockchainAddress(), messageA.BlockchainAddress(), "I'm fine!")
blockchain.Puts()
blockchain.Mining()
blockchain.Puts()
blockchain.PutsMessageList(messageA.BlockchainAddress())
blockchain.PutsMessageList(messageB.BlockchainAddress())
}