-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
32 lines (26 loc) · 773 Bytes
/
Copy pathmain.go
File metadata and controls
32 lines (26 loc) · 773 Bytes
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
package main
import (
"encoding/json"
"log"
"github.com/stinkymonkeyph/gopher-blocks/blockchain"
"github.com/stinkymonkeyph/gopher-blocks/constants"
)
func init() {
log.SetPrefix(constants.BLOCKCHAIN_NAME + ": ")
}
func main() {
block := blockchain.NewBlock("0x0", 0, 0, nil)
bc := blockchain.NewBlockchain(block)
bc.Airdrop("0x1")
bc.Mining()
log.Print(bc.ToJSON())
transaction1 := blockchain.NewTransaction("0x1", "0x2", 12, []byte{})
bc.AddTransactionToTransactionPool(transaction1)
bc.Mining()
log.Print(bc.ToJSON())
senderBalance := bc.CalculateBalance("0x1")
log.Printf("\n\n\nSender Balance: %d \n", senderBalance)
walletTxns := bc.WalletIndex.GetWalletTransactions("0x1")
wbytes, _ := json.Marshal(walletTxns)
log.Println(string(wbytes))
}