Skip to content

Commit 10b7574

Browse files
committed
init
1 parent 7ea14cd commit 10b7574

File tree

7 files changed

+78
-0
lines changed

7 files changed

+78
-0
lines changed

build.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
echo "Building the sample program..."
4+
go build -o sample sample.go
5+
6+
if [ $? -eq 0 ]; then
7+
echo "Build successful."
8+
else
9+
echo "Build failed."
10+
exit 1
11+
fi

dummy-go-project

2.45 MB
Binary file not shown.

go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/layer-edge/dummy-go-project
2+
3+
go 1.23.2
4+
5+
require gopkg.in/zeromq/goczmq.v4 v4.1.0 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
gopkg.in/zeromq/goczmq.v4 v4.1.0 h1:CE+FE81mGVs2aSlnbfLuS1oAwdcVywyMM2AC1g33imI=
2+
gopkg.in/zeromq/goczmq.v4 v4.1.0/go.mod h1:h4IlfePEYMpFdywGr5gAwKhBBj+hiBl/nF4VoSE4k+0=

run.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
if [ -f sample ]; then
4+
echo "Running the sample program..."
5+
if [ $# -eq 1 ]; then
6+
./sample "$1"
7+
else
8+
./sample
9+
fi
10+
else
11+
echo "Executable not found. Please run ./build.sh first."
12+
exit 1
13+
fi

sample

2.47 MB
Binary file not shown.

sample.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
"fmt"
6+
"gopkg.in/zeromq/goczmq.v4"
7+
"log"
8+
"os"
9+
"strings"
10+
"time"
11+
)
12+
13+
func main() {
14+
ep := "tcp://34.71.52.251:40000"
15+
sample := goczmq.NewReqChanneler(ep)
16+
if sample == nil {
17+
log.Fatal("Failed to subscribe to endpoint: ", ep)
18+
}
19+
defer sample.Destroy()
20+
21+
// Prompt the user for input
22+
reader := bufio.NewReader(os.Stdin)
23+
fmt.Print("Enter proof data (or press Enter to use default): ")
24+
input, _ := reader.ReadString('\n')
25+
input = strings.TrimSpace(input)
26+
27+
// Let the socket connect
28+
time.Sleep(5 * time.Second)
29+
30+
// Prepare the proof data
31+
var proof [][]byte
32+
if input == "" {
33+
// Use default value if no input is provided
34+
proof = [][]byte{[]byte("proofblock"), []byte("timestamp :" + time.Now().String()), []byte("0x0000000000000000000")}
35+
} else {
36+
// Use user-provided input
37+
proof = [][]byte{[]byte("proofblock"), []byte(input), []byte("!!!!!")}
38+
}
39+
40+
// Send the proof
41+
sample.SendChan <- proof
42+
fmt.Printf("Proof sent: %s\n", proof)
43+
44+
// Receive the response
45+
resp := <-sample.RecvChan
46+
fmt.Printf("Response received: %s\n", resp)
47+
}

0 commit comments

Comments
 (0)