mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
factor out another fn
This commit is contained in:
parent
142140a3ef
commit
953d405330
1 changed files with 22 additions and 19 deletions
|
|
@ -57,27 +57,9 @@ func handleRequest(conn net.Conn) {
|
||||||
|
|
||||||
go readerConn(conn, messages)
|
go readerConn(conn, messages)
|
||||||
go handleMessages(messages, checkBalanceChan)
|
go handleMessages(messages, checkBalanceChan)
|
||||||
|
|
||||||
go checkBalance(checkBalanceChan)
|
go checkBalance(checkBalanceChan)
|
||||||
|
|
||||||
key, _ := crypto.HexToECDSA(testPrivHex)
|
sendRingSignedMsg(conn)
|
||||||
|
|
||||||
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"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleMessages(channel chan []byte, checkBalancesChan chan []byte) {
|
func handleMessages(channel chan []byte, checkBalancesChan chan []byte) {
|
||||||
|
|
@ -159,3 +141,24 @@ func checkBalance(checkBalanceChan chan []byte) {
|
||||||
address := <-checkBalanceChan
|
address := <-checkBalanceChan
|
||||||
fmt.Println("The address for balance check is ", address)
|
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"))
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue