forked from Parms-Crypto/CUDA-ORE-DUMP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mine-server.go
56 lines (47 loc) · 1.24 KB
/
mine-server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"fmt"
"net"
)
// Mockup of a function to simulate Keccak hashing
func simulateKeccakHash(input string) string {
// Simulated hash function implementation
return "0000" + "mockedhash" // Simulate 256-bit hash output with leading zeros
}
func handleClient(conn net.Conn) {
defer conn.Close()
fmt.Printf("Client connected: %s\n", conn.RemoteAddr())
// Read data from the client
buffer := make([]byte, 1024)
n, err := conn.Read(buffer)
if err != nil {
fmt.Printf("Error reading from client: %s\n", err)
return
}
data := string(buffer[:n])
fmt.Printf("Received data from client: %s\n", data)
// Simulate Keccak hashing
hash := simulateKeccakHash(data)
// Echo the hash back to the client
_, err = conn.Write([]byte(hash))
if err != nil {
fmt.Printf("Error writing to client: %s\n", err)
}
}
func main() {
listener, err := net.Listen("tcp", "127.0.0.1:8080")
if err != nil {
fmt.Printf("Error starting server: %s\n", err)
return
}
defer listener.Close()
fmt.Println("Server listening on port 8080")
for {
conn, err := listener.Accept()
if err != nil {
fmt.Printf("Error accepting connection: %s\n", err)
continue
}
go handleClient(conn)
}
}