From cad45efb71c3fd1f845f84b37050f2ed579dacff Mon Sep 17 00:00:00 2001 From: anonpenguin Date: Mon, 4 Aug 2025 18:51:11 +0300 Subject: [PATCH] Refactor go.mod to remove indirect dependency on godotenv and update RQLite node configuration --- cmd/node/main.go | 10 +++++++--- configs/bootstrap.yaml | 2 ++ configs/node.yaml | 2 ++ go.mod | 2 +- pkg/client/implementations.go | 3 +-- pkg/config/config.go | 4 ++-- scripts/install-debros-network.sh | 2 +- 7 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cmd/node/main.go b/cmd/node/main.go index ac9e5a0..c7d14f2 100644 --- a/cmd/node/main.go +++ b/cmd/node/main.go @@ -36,9 +36,13 @@ func main() { fmt.Sprintf("/ip4/0.0.0.0/udp/%d/quic", *port), } - // Configure RQLite ports based on node port - cfg.Database.RQLitePort = *port + 1000 // e.g., 5002 for node port 4002 - cfg.Database.RQLiteRaftPort = *port + 3000 // e.g., 7002 for node port 4002 (changed to avoid conflicts) + // Configure RQLite ports based on node port (only if not already set in config) + if cfg.Database.RQLitePort == 0 { + cfg.Database.RQLitePort = *port + 1000 // e.g., 5002 for node port 4002 + } + if cfg.Database.RQLiteRaftPort == 0 { + cfg.Database.RQLiteRaftPort = *port + 3000 // e.g., 7002 for node port 4002 (changed to avoid conflicts) + } // Configure bootstrap peers if *bootstrap != "" { diff --git a/configs/bootstrap.yaml b/configs/bootstrap.yaml index 00cbe61..5c4b982 100644 --- a/configs/bootstrap.yaml +++ b/configs/bootstrap.yaml @@ -14,6 +14,8 @@ database: shard_count: 16 max_database_size: 1073741824 # 1GB backup_interval: "24h" + rqlite_port: 5001 + rqlite_raft_port: 5002 discovery: bootstrap_peers: [] # Bootstrap nodes don't need peers diff --git a/configs/node.yaml b/configs/node.yaml index 213f62b..2ddd8ee 100644 --- a/configs/node.yaml +++ b/configs/node.yaml @@ -14,6 +14,8 @@ database: shard_count: 16 max_database_size: 1073741824 # 1GB backup_interval: "24h" + rqlite_port: 5001 + rqlite_raft_port: 5002 discovery: bootstrap_peers: diff --git a/go.mod b/go.mod index acf9bd1..a4d054b 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.23.8 toolchain go1.24.1 require ( + github.com/joho/godotenv v1.5.1 github.com/libp2p/go-libp2p v0.41.1 github.com/libp2p/go-libp2p-kad-dht v0.33.1 github.com/libp2p/go-libp2p-pubsub v0.14.2 @@ -44,7 +45,6 @@ require ( github.com/ipld/go-ipld-prime v0.21.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect - github.com/joho/godotenv v1.5.1 // indirect github.com/klauspost/compress v1.18.0 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/koron/go-ssdp v0.0.5 // indirect diff --git a/pkg/client/implementations.go b/pkg/client/implementations.go index e8a2402..8bdd414 100644 --- a/pkg/client/implementations.go +++ b/pkg/client/implementations.go @@ -215,10 +215,9 @@ func (d *DatabaseClientImpl) getRQLiteNodes() []string { // Fallback to localhost for development return []string{ "http://localhost:5001", // bootstrap - "http://localhost:5002", // node1 + "http://localhost:5002", // node1 "http://localhost:5003", // node2 "http://localhost:5004", // node3 (if exists) - "http://localhost:5005", // node4 (if exists) } } diff --git a/pkg/config/config.go b/pkg/config/config.go index 5abcbe7..182b75a 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -121,8 +121,8 @@ func DefaultConfig() *Config { BackupInterval: time.Hour * 24, // Daily backups // RQLite-specific configuration - RQLitePort: 4001, - RQLiteRaftPort: 4002, + RQLitePort: 5001, + RQLiteRaftPort: 5002, RQLiteJoinAddress: "", // Empty for bootstrap node }, Discovery: DiscoveryConfig{ diff --git a/scripts/install-debros-network.sh b/scripts/install-debros-network.sh index 0da33b1..b76e1b6 100755 --- a/scripts/install-debros-network.sh +++ b/scripts/install-debros-network.sh @@ -17,7 +17,7 @@ REPO_URL="https://git.debros.io/DeBros/network.git" MIN_GO_VERSION="1.19" NODE_PORT="4001" RQLITE_NODE_PORT="5001" -RAFT_NODE_PORT="7001" +RAFT_NODE_PORT="5002" UPDATE_MODE=false NON_INTERACTIVE=false