diff --git a/README.md b/README.md index 5abdb52..09cd42d 100644 --- a/README.md +++ b/README.md @@ -520,6 +520,7 @@ Notes: - With `NETWORK_DEV_LOCAL`, `client.DefaultDatabaseEndpoints()` returns `http://127.0.0.1:$RQLITE_PORT`. - `client.DefaultBootstrapPeers()` returns `LOCAL_BOOTSTRAP_MULTIADDR` if set, otherwise `/ip4/127.0.0.1/tcp/4001`. - If you construct config via `client.DefaultClientConfig(...)`, DB endpoints are pinned to localhost and will override `RQLITE_NODES` automatically. +- When `NETWORK_DEV_LOCAL` is set and `LOCAL_BOOTSTRAP_MULTIADDR` is NOT set, the client attempts to auto-load the local bootstrap multiaddr (with peer ID) from `./data/bootstrap/peer.info` (or `LOCAL_BOOTSTRAP_INFO` path if provided). Only if no file is found does it fall back to `/ip4/127.0.0.1/tcp/4001`. ### Migration Guide for Apps (e.g., anchat) diff --git a/cmd/node/configmap.go b/cmd/node/configmap.go index dab9e5f..0da90cd 100644 --- a/cmd/node/configmap.go +++ b/cmd/node/configmap.go @@ -75,9 +75,9 @@ func MapFlagsAndEnvToConfig(cfg *config.Config, fv NodeFlagValues, isBootstrap b if devLocal { // In dev-local, run a primary bootstrap locally cfg.Database.RQLiteJoinAddress = "" - // Also prefer localhost bootstrap peers for any consumers reading cfg - cfg.Discovery.BootstrapPeers = client.DefaultBootstrapPeers() - logger.Printf("Dev-local: Primary bootstrap node - localhost defaults enabled") + // Do not set bootstrap peers to avoid including self; clients can still + // derive DB endpoints via DefaultDatabaseEndpoints in dev-local. + logger.Printf("Dev-local: Primary bootstrap node - localhost defaults enabled (no bootstrap peers set to avoid self)") return "" } bootstrapPeers := constants.GetBootstrapPeers() diff --git a/cmd/node/main.go b/cmd/node/main.go index 5b0466b..82a418e 100644 --- a/cmd/node/main.go +++ b/cmd/node/main.go @@ -17,6 +17,7 @@ import ( "git.debros.io/DeBros/network/pkg/constants" "git.debros.io/DeBros/network/pkg/logging" "git.debros.io/DeBros/network/pkg/node" + "git.debros.io/DeBros/network/pkg/client" ) func main() { @@ -112,6 +113,19 @@ func main() { logger.Printf("RQLite HTTP port: %d", cfg.Database.RQLitePort) logger.Printf("RQLite Raft port: %d", cfg.Database.RQLiteRaftPort) + // For development visibility, print what the CLIENT library will return by default + clientBootstrap := client.DefaultBootstrapPeers() + clientDB := client.DefaultDatabaseEndpoints() + logger.Printf("[Client Defaults] Bootstrap peers: %v", clientBootstrap) + logger.Printf("[Client Defaults] Database endpoints: %v", clientDB) + // Also show node-configured values + logger.Printf("[Node Config] Bootstrap peers: %v", cfg.Discovery.BootstrapPeers) + if cfg.Database.RQLiteJoinAddress != "" { + logger.Printf("[Node Config] RQLite Raft join: %s", cfg.Database.RQLiteJoinAddress) + } else if isBootstrap { + logger.Printf("[Node Config] Bootstrap node: starting new RQLite cluster (no join)") + } + // Create context for graceful shutdown ctx, cancel := context.WithCancel(context.Background()) defer cancel()