func (tran *TransactionList) Print() { for _, tx := range tran.Txs { log.Printf("TxId: %v", tx.Hash) log.Print("TxIns:") if tx.TxInCnt == 1 && tx.TxIns[0].InputVout == 4294967295 { log.Printf("TxIn coinbase, newly generated coins") } else { for txin_index, txin := range tx.TxIns { log.Printf("TxIn index: %v", txin_index) log.Printf("TxIn Input_Hash: %v", txin.InputHash) log.Printf("TxIn Input_Index: %v", txin.InputVout) } } log.Print("TxOuts:") for txo_index, txout := range tx.TxOuts { log.Printf("TxOut index: %v", txo_index) log.Printf("TxOut value: %v", txout.Value) txout_addr := txout.Addr if txout_addr != "" { log.Printf("TxOut address: %v", txout_addr) } else { log.Printf("TxOut address: can't decode address") } } } }
// Run initiates a RandHound simulation func (rhs *RHSimulation) Run(config *sda.SimulationConfig) error { leader, err := config.Overlay.CreateProtocolSDA(config.Tree, "RandHound") if err != nil { return err } rh := leader.(*RandHound) err = rh.Setup(uint32(rhs.Hosts), rhs.Trustees, rhs.Purpose) if err != nil { return err } log.Printf("RandHound - group config: %d %d %d %d %d %d\n", rh.Group.N, rh.Group.F, rh.Group.L, rh.Group.K, rh.Group.R, rh.Group.T) log.Printf("RandHound - shards: %d\n", rhs.Shards) if err := rh.StartProtocol(); err != nil { log.Error("Error while starting protcol:", err) } select { case <-rh.Leader.Done: log.Print("RandHound - done") rnd, err := rh.Random() if err != nil { panic(err) } sharding, err := rh.Shard(rnd, rhs.Shards) if err != nil { panic(err) } log.Printf("RandHound - random bytes: %v\n", rnd) log.Printf("RandHound - sharding: %v\n", sharding) case <-time.After(time.Second * 60): log.Print("RandHound - time out") } return nil }
// DumpTypes is used for debugging - it prints out all known types func DumpTypes() { for t, m := range registry.types { log.Print("Type", t, "has message", m) } }