clean up code

This commit is contained in:
Tim Williams 2018-08-13 14:44:36 -04:00
parent 1cbe9bf277
commit 2432128b60

View file

@ -88,12 +88,10 @@ func handleMessages(channel chan []byte, checkBalancesChan chan []byte, sendTran
if prevMsg != nil { if prevMsg != nil {
s := string(prevMsg[:]) s := string(prevMsg[:])
if s == "-- ADDRESS --" { if s == "-- ADDRESS --" {
fmt.Println("putting on channel 1")
addressOfClient = msg addressOfClient = msg
checkBalancesChan <- addressOfClient //checkBalancesChan <- addressOfClient
} }
if s == "-- GET_BALANCE --" { if s == "-- GET_BALANCE --" {
fmt.Println("putting on channel 3")
checkBalancesChan <- msg checkBalancesChan <- msg
} }
if s == "-- SEND_TRANSACTION --" { if s == "-- SEND_TRANSACTION --" {
@ -130,7 +128,7 @@ func handleMessages(channel chan []byte, checkBalancesChan chan []byte, sendTran
pubKey := crypto.ToECDSAPub(rpk) pubKey := crypto.ToECDSAPub(rpk)
recoveredAddr := crypto.PubkeyToAddress(*pubKey) recoveredAddr := crypto.PubkeyToAddress(*pubKey)
fmt.Println("ADDRESS IS ::", recoveredAddr.Hex()) fmt.Println("Client connected with address :", recoveredAddr.Hex())
signatureFromClient = nil signatureFromClient = nil
msgFromClient = nil msgFromClient = nil
} }
@ -161,7 +159,6 @@ func readerConn(conn net.Conn, channel chan []byte) {
} }
func checkBalance(checkBalanceChan chan []byte, conn net.Conn) { func checkBalance(checkBalanceChan chan []byte, conn net.Conn) {
fmt.Println("in check balance function")
c, err := ethclient.Dial("http://127.0.0.1:8545") c, err := ethclient.Dial("http://127.0.0.1:8545")
if err != nil { if err != nil {
fmt.Println("Eth Client not initialized: " , err) fmt.Println("Eth Client not initialized: " , err)
@ -177,13 +174,7 @@ func checkBalance(checkBalanceChan chan []byte, conn net.Conn) {
fmt.Println("Balance at error ", error) fmt.Println("Balance at error ", error)
} }
mutex.Lock() mutex.Lock()
fmt.Println("in broadcasting balance")
fmt.Println("the bal is ", balance)
fmt.Println("The balance for address ", string(address[:]), " is ", balance) fmt.Println("The balance for address ", string(address[:]), " is ", balance)
fmt.Println([]byte("Broadcasting Balance"))
fmt.Println([]byte("\n"))
fmt.Println([]byte(balance.String()))
fmt.Println([]byte("\n"))
conn.Write([]byte("Broadcasting Balance")) conn.Write([]byte("Broadcasting Balance"))
conn.Write([]byte("\n")) conn.Write([]byte("\n"))
conn.Write([]byte(balance.String())) conn.Write([]byte(balance.String()))
@ -193,7 +184,6 @@ func checkBalance(checkBalanceChan chan []byte, conn net.Conn) {
} }
func sendTransaction(sendTransactionChan chan []byte) { func sendTransaction(sendTransactionChan chan []byte) {
fmt.Println("in sendTransaction function")
c, err := ethclient.Dial("http://127.0.0.1:8545") c, err := ethclient.Dial("http://127.0.0.1:8545")
if err != nil { if err != nil {
fmt.Println("Eth Client not initialized: " , err) fmt.Println("Eth Client not initialized: " , err)
@ -227,13 +217,6 @@ func sendRingSignedMsg(conn net.Conn){
} }
mutex.Lock() mutex.Lock()
fmt.Println("in broadcasting message")
fmt.Println([]byte("Broadcasting Message"))
fmt.Println([]byte("\n"))
fmt.Println([]byte(f_msg))
fmt.Println([]byte("\n"))
fmt.Println(new_sig)
fmt.Println([]byte("\n"))
conn.Write([]byte("Broadcasting Message")) conn.Write([]byte("Broadcasting Message"))
conn.Write([]byte("\n")) conn.Write([]byte("\n"))
conn.Write([]byte(f_msg)) conn.Write([]byte(f_msg))