factor out another fn

This commit is contained in:
Tim Williams 2018-07-27 22:28:28 -04:00
parent 142140a3ef
commit 953d405330

View file

@ -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"))
}