You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
874 B
37 lines
874 B
7 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"harmony-benchmark/blockchain"
|
||
|
"math/rand"
|
||
|
"time"
|
||
|
"flag"
|
||
|
"harmony-benchmark/node"
|
||
|
"harmony-benchmark/p2p"
|
||
|
)
|
||
|
|
||
|
func newRandTransaction() blockchain.Transaction {
|
||
|
txin := blockchain.TXInput{[]byte{}, rand.Intn(100), string(rand.Uint64())}
|
||
|
txout := blockchain.TXOutput{rand.Intn(100), string(rand.Uint64())}
|
||
|
tx := blockchain.Transaction{nil, []blockchain.TXInput{txin}, []blockchain.TXOutput{txout}}
|
||
|
tx.SetID()
|
||
|
|
||
|
return tx
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
|
||
|
ip := flag.String("ip", "127.0.0.1", "IP of the leader")
|
||
|
port := flag.String("port", "9000", "port of the leader.")
|
||
|
|
||
|
txs := make([]blockchain.Transaction, 10)
|
||
|
for true {
|
||
|
for i := range txs {
|
||
|
txs[i] = newRandTransaction()
|
||
|
|
||
|
}
|
||
|
msg := node.ConstructTransactionListMessage(txs)
|
||
|
p2p.SendMessage(p2p.Peer{*ip, *port, "n/a"}, msg)
|
||
|
time.Sleep(1 * time.Second) // 10 transactions per second
|
||
|
}
|
||
|
}
|