Skip to content

Commit 351e15d

Browse files
Temp
1 parent 06de857 commit 351e15d

File tree

7 files changed

+143
-6
lines changed

7 files changed

+143
-6
lines changed

.vscode/launch.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
22
"version": "0.2.0",
33
"configurations": [
4+
45
{
56
"name": "Debug main.go",
67
"type": "go",
78
"request": "launch",
89
"mode": "debug",
9-
"program": "${workspaceFolder}/supernode/main.go",
10-
"env": {},
11-
"args": ["start"],
10+
"program": "${workspaceFolder}/sdk/example/main.go",
1211
"showLog": true
1312
}
1413
]

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ module github.com/LumeraProtocol/supernode
33
go 1.24.0
44

55
require (
6-
cosmossdk.io/x/circuit v0.1.1
76
github.com/LumeraProtocol/lumera v0.4.3
87
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
98
github.com/cenkalti/backoff/v4 v4.3.0

sdk/example/Excalidraw.zip

3.95 KB
Binary file not shown.

sdk/example/config.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Supernode Configuration
2+
supernode:
3+
key_name: "mukey" # Account name for the supernode in keyring
4+
identity: "lumera1uarju67x0hzetfzhgktay3h25pgxdy7yxap2xk" # Identity of the supernode, lumera address
5+
ip_address: "0.0.0.0"
6+
port: 4444
7+
data_dir: "~/.supernode" # Base directory in home folder
8+
9+
# Keyring Configuration
10+
keyring:
11+
backend: "test" # Options: test, file, os
12+
dir: "~/.supernode/keys" # Keyring directory in home folder
13+
password: "keyring-password" # Only used for 'file' backend
14+
15+
# P2P Network Configuration
16+
p2p:
17+
listen_address: "0.0.0.0"
18+
port: 4445
19+
data_dir: "~/.supernode/data/p2p" # P2P data directory in home folder
20+
bootstrap_nodes: "" # Comma-separated list of bootstrap peer addresses
21+
external_ip: "" # External IP address for this node (if behind NAT)
22+
23+
# Lumera Chain Configuration
24+
lumera:
25+
grpc_addr: "localhost:9090"
26+
chain_id: "lumera"
27+
timeout: 10 # Connection timeout in seconds
28+
29+
# RaptorQ Configuration
30+
raptorq:
31+
service_address: "localhost:50051"
32+
files_dir: "~/.supernode/raptorq_files"

sdk/example/main.go

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package main
2+
3+
import (
4+
"context"
5+
"fmt"
6+
"log"
7+
"os"
8+
"path/filepath"
9+
"time"
10+
11+
lumera "github.com/LumeraProtocol/supernode/pkg/lumera"
12+
"github.com/LumeraProtocol/supernode/pkg/raptorq"
13+
"github.com/LumeraProtocol/supernode/pkg/storage/rqstore"
14+
"github.com/LumeraProtocol/supernode/supernode/config"
15+
)
16+
17+
func main() {
18+
// 1- ctx
19+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
20+
defer cancel()
21+
22+
// 2- Load the configuration
23+
cfgFile := "config.yml"
24+
appConfig, err := config.LoadConfig(cfgFile)
25+
if err != nil {
26+
log.Fatalf("Failed to load configuration file %s: %v", cfgFile, err)
27+
}
28+
29+
// 3- RaptorQ configuration
30+
31+
config := raptorq.NewConfig()
32+
33+
config.RqFilesDir = appConfig.RaptorQConfig.FilesDir
34+
client := raptorq.NewClient()
35+
36+
// Server address using the config
37+
address := fmt.Sprintf("%s:%d", config.Host, config.Port)
38+
39+
// Connect to the server
40+
connection, err := client.Connect(ctx, address)
41+
if err != nil {
42+
log.Fatalf("Failed to connect to RaptorQ server at %s: %v", address, err)
43+
}
44+
defer connection.Close()
45+
46+
// 4- Initialize the Lumera client
47+
lumeraClient, err := lumera.NewClient(
48+
ctx,
49+
lumera.WithGRPCAddr(appConfig.LumeraClientConfig.GRPCAddr),
50+
lumera.WithChainID(appConfig.LumeraClientConfig.ChainID),
51+
lumera.WithTimeout(appConfig.LumeraClientConfig.Timeout),
52+
)
53+
if err != nil {
54+
log.Fatalf("Failed to initialize Lumera client: %v", err)
55+
}
56+
57+
store, err := initRQStore()
58+
if err != nil {
59+
log.Fatalf("Failed to initialize RaptorQ store: %v", err)
60+
}
61+
rq := connection.RaptorQ(config, lumeraClient, store)
62+
63+
// File path to process
64+
filePath := "/home/enxsys/Documents/Github/supernode/sdk/example/Excalidraw.zip"
65+
66+
// 1. Call EncodeMetaData
67+
fmt.Println("Calling EncodeMetaData...")
68+
encodeMetaResp, err := rq.EncodeMetaData(ctx, raptorq.EncodeMetadataRequest{
69+
Path: filePath,
70+
FilesNumber: 5,
71+
BlockHash: "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
72+
PastelId: "jXYWiR42BRvhu3Ts9SYzrXj2D4m7y3qYJL35R4buTd4TdmPZWwF9",
73+
})
74+
if err != nil {
75+
log.Fatalf("EncodeMetaData failed: %v", err)
76+
}
77+
78+
fmt.Println("EncodeMetaData response:", encodeMetaResp)
79+
80+
}
81+
82+
func initRQStore() (rqstore.Store, error) {
83+
84+
home, _ := os.UserHomeDir()
85+
86+
rqDir := filepath.Join(home, filepath.Join("supernode", "raptorq_files"))
87+
88+
if err := os.MkdirAll(rqDir, 0700); err != nil {
89+
return nil, fmt.Errorf("failed to create RQ store directory: %w", err)
90+
}
91+
92+
rqStoreFile := rqDir + "/rqstore.db"
93+
94+
return rqstore.NewSQLiteRQStore(rqStoreFile)
95+
}

sdk/go.mod

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,21 @@ require (
9797
github.com/improbable-eng/grpc-web v0.15.0 // indirect
9898
github.com/inconshreveable/mousetrap v1.1.0 // indirect
9999
github.com/jmhodges/levigo v1.0.0 // indirect
100+
github.com/jmoiron/sqlx v1.4.0 // indirect
101+
github.com/json-iterator/go v1.1.12 // indirect
100102
github.com/klauspost/compress v1.17.11 // indirect
101103
github.com/kr/pretty v0.3.1 // indirect
102104
github.com/kr/text v0.2.0 // indirect
103105
github.com/linxGnu/grocksdb v1.8.14 // indirect
104106
github.com/magiconair/properties v1.8.7 // indirect
105107
github.com/mattn/go-colorable v0.1.13 // indirect
106108
github.com/mattn/go-isatty v0.0.20 // indirect
109+
github.com/mattn/go-sqlite3 v1.14.24 // indirect
107110
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
108111
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
109112
github.com/mitchellh/mapstructure v1.5.0 // indirect
113+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
114+
github.com/modern-go/reflect2 v1.0.2 // indirect
110115
github.com/mtibben/percent v0.2.1 // indirect
111116
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
112117
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect

sdk/go.sum

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GO
296296
github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
297297
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
298298
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
299+
github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y=
300+
github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg=
299301
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
300302
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
301303
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
@@ -476,6 +478,8 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y
476478
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
477479
github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U=
478480
github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ=
481+
github.com/jmoiron/sqlx v1.4.0 h1:1PLqN7S1UYp5t4SrVVnt4nUVNemrDAtxlulVe+Qgm3o=
482+
github.com/jmoiron/sqlx v1.4.0/go.mod h1:ZrZ7UsYB/weZdl2Bxg6jCRO9c3YHl8r3ahlKmRT4JLY=
479483
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
480484
github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4=
481485
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
@@ -510,8 +514,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
510514
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
511515
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
512516
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
513-
github.com/lib/pq v1.10.7 h1:p7ZhMD+KsSRozJr34udlUrhboJwWAgCg34+/ZZNvZZw=
514-
github.com/lib/pq v1.10.7/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
517+
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
518+
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
515519
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
516520
github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4=
517521
github.com/linxGnu/grocksdb v1.8.14 h1:HTgyYalNwBSG/1qCQUIott44wU5b2Y9Kr3z7SK5OfGQ=
@@ -536,6 +540,9 @@ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D
536540
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
537541
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
538542
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
543+
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
544+
github.com/mattn/go-sqlite3 v1.14.24 h1:tpSp2G2KyMnnQu99ngJ47EIkWVmliIizyZBfPrBWDRM=
545+
github.com/mattn/go-sqlite3 v1.14.24/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
539546
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
540547
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d h1:5PJl274Y63IEHC+7izoQE9x6ikvDFZS2mDVS3drnohI=
541548
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=

0 commit comments

Comments
 (0)