package main import ( "fmt" "math/rand" ) var node_ips = []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} var numOfTxns = 1000 var numOfTxnsInBlock = 10 var lenOfRandomString = 10 type Node struct { ip int leader bool } type Nodes struct { Nodes []*Node } type txn struct { tx string } func randomInt(min, max int) int { return min + rand.Intn(max-min) } // Generate a random string of A-Z chars with len = l func randomString(len int) string { bytes := make([]byte, len) for i := 0; i < len; i++ { bytes[i] = byte(randomInt(97, 122)) } return string(bytes) } func (n Node) send() { fmt.Printf("Leader with id: %d has sent message\n", n.ip) } func (n Node) receive() { fmt.Printf("Node: %d received message\n", n.ip) } func createNode(ip int, isLeader bool) Node { n := Node{ip: ip, leader: isLeader} return n } func pickLeader(i int) bool { if i == 0 { return true } else { return false } } var N = make([]Node, 10) func gen() <- chan string{ out := make(chan string) go func() { for i :=0; i