From 2cf96a3555026db2d8793344c1f3bb2cc79769fe Mon Sep 17 00:00:00 2001 From: Xavier Perret <xa.perret@outlook.com> Date: Sun, 30 Oct 2022 11:08:49 +0100 Subject: [PATCH] added request --- app/sender/sender.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/sender/sender.go b/app/sender/sender.go index 4a993e1..8c423b5 100644 --- a/app/sender/sender.go +++ b/app/sender/sender.go @@ -130,10 +130,42 @@ func SendVoteRequestToNode(clientConfig Config, transIDInt int64, address string // SendFakeRequestToNode is a function to send a fake request to a node, used strictly by client func SendFakeRequestToNode(clientConfig Config, transIDInt int64, address string) { + fmt.Println() + fmt.Println("Trying to connect to ", address) + + conn := manage_connection.CreateConnection(address) + mess := Message{ + MessageType: "fakeRequest", + MessageBody: transIDInt, + } + fmt.Println("Sending vote request to node", mess) + encoder := json.NewEncoder(conn) + err := encoder.Encode(mess) + if err != nil { + fmt.Println("Error while encoding the transaction", err) + os.Exit(1) + } + conn.Close() } // SendListTransactionsRequestToNode is a function to ask a node to locally list its transaction in its cli, used strictly by client func SendListTransactionsRequestToNode(clientConfig Config, address string) { + fmt.Println() + fmt.Println("Trying to connect to ", address) + + conn := manage_connection.CreateConnection(address) + mess := Message{ + MessageType: "listTransactionsRequest", + MessageBody: "", + } + fmt.Println("Sending vote request to node", mess) + encoder := json.NewEncoder(conn) + err := encoder.Encode(mess) + if err != nil { + fmt.Println("Error while encoding the transaction", err) + os.Exit(1) + } + conn.Close() } -- GitLab