From 953d40533077e3d75e121dc6a7e1daa6384b88d8 Mon Sep 17 00:00:00 2001 From: Tim Williams Date: Fri, 27 Jul 2018 22:28:28 -0400 Subject: [PATCH] factor out another fn --- shyftRingWalletConn/app.go | 41 ++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/shyftRingWalletConn/app.go b/shyftRingWalletConn/app.go index b8a87beca4..009914fed9 100644 --- a/shyftRingWalletConn/app.go +++ b/shyftRingWalletConn/app.go @@ -57,27 +57,9 @@ func handleRequest(conn net.Conn) { go readerConn(conn, messages) go handleMessages(messages, checkBalanceChan) - go checkBalance(checkBalanceChan) - key, _ := crypto.HexToECDSA(testPrivHex) - - f_msg := "Hello World" - first_message := []byte(f_msg) - new_msg2 := crypto.Keccak256(first_message) - - //send_message := append(new_msg2, []byte{byte(10)}...) - new_sig, err := crypto.Sign(new_msg2, key) - if err != nil { - fmt.Println("The crypto.Sign err is ", err) - } - - conn.Write([]byte("Broadcasting Message")) - conn.Write([]byte("\n")) - conn.Write([]byte(f_msg)) - conn.Write([]byte("\n")) - conn.Write(new_sig) - conn.Write([]byte("\n")) + sendRingSignedMsg(conn) } func handleMessages(channel chan []byte, checkBalancesChan chan []byte) { @@ -159,3 +141,24 @@ func checkBalance(checkBalanceChan chan []byte) { address := <-checkBalanceChan fmt.Println("The address for balance check is ", address) } + +func sendRingSignedMsg(conn net.Conn){ + key, _ := crypto.HexToECDSA(testPrivHex) + + f_msg := "Hello World" + first_message := []byte(f_msg) + new_msg2 := crypto.Keccak256(first_message) + + //send_message := append(new_msg2, []byte{byte(10)}...) + new_sig, err := crypto.Sign(new_msg2, key) + if err != nil { + fmt.Println("The crypto.Sign err is ", err) + } + + conn.Write([]byte("Broadcasting Message")) + conn.Write([]byte("\n")) + conn.Write([]byte(f_msg)) + conn.Write([]byte("\n")) + conn.Write(new_sig) + conn.Write([]byte("\n")) +} \ No newline at end of file