mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-10-06 08:19:07 +00:00
Use default peers during local development
The change keeps default peers in local dev mode instead of clearing them, while adding a global pubsub logger and updating bootstrap peer config.
This commit is contained in:
parent
d08626856f
commit
dfd1862cfd
@ -136,22 +136,22 @@ type ClientConfig struct {
|
||||
// DefaultClientConfig returns a default client configuration
|
||||
func DefaultClientConfig(appName string) *ClientConfig {
|
||||
// Base defaults
|
||||
peers := []string{}
|
||||
peers := DefaultBootstrapPeers()
|
||||
endpoints := DefaultDatabaseEndpoints()
|
||||
|
||||
// Development local-only override via env
|
||||
if isTruthyEnv("NETWORK_DEV_LOCAL") {
|
||||
port := 5001
|
||||
if v := os.Getenv("RQLITE_PORT"); v != "" {
|
||||
if n, err := strconv.Atoi(v); err == nil && n > 0 { port = n }
|
||||
if n, err := strconv.Atoi(v); err == nil && n > 0 {
|
||||
port = n
|
||||
}
|
||||
}
|
||||
endpoints = []string{fmt.Sprintf("http://127.0.0.1:%d", port)}
|
||||
if ma := os.Getenv("LOCAL_BOOTSTRAP_MULTIADDR"); ma != "" {
|
||||
peers = []string{ma}
|
||||
} else {
|
||||
// Leave peers empty if no local bootstrap multiaddr provided
|
||||
peers = []string{}
|
||||
}
|
||||
// else: keep the peers from DefaultBootstrapPeers() which handles NETWORK_DEV_LOCAL appropriately
|
||||
}
|
||||
|
||||
return &ClientConfig{
|
||||
|
@ -33,12 +33,14 @@ func init() {
|
||||
func setDefaultBootstrapConfig() {
|
||||
// Check if we're in production environment
|
||||
BootstrapPeerIDs = []string{
|
||||
"12D3KooWNxt9bNvqftdqXg98JcUHreGxedWSZRUbyqXJ6CW7GaD4",
|
||||
"12D3KooWGbdnA22bN24X2gyY1o9jozwTBq9wbfvwtJ7G4XQ9JgFm",
|
||||
// "12D3KooWNxt9bNvqftdqXg98JcUHreGxedWSZRUbyqXJ6CW7GaD4",
|
||||
// "12D3KooWGbdnA22bN24X2gyY1o9jozwTBq9wbfvwtJ7G4XQ9JgFm",
|
||||
"12D3KooWDL6LSjwwP5FwboV9JaTZzuxr8EhjbcZGFfnyFMDt1UDx",
|
||||
}
|
||||
BootstrapAddresses = []string{
|
||||
"/ip4/57.129.81.31/tcp/4001/p2p/12D3KooWNxt9bNvqftdqXg98JcUHreGxedWSZRUbyqXJ6CW7GaD4",
|
||||
"/ip4/38.242.250.186/tcp/4001/p2p/12D3KooWGbdnA22bN24X2gyY1o9jozwTBq9wbfvwtJ7G4XQ9JgFm",
|
||||
// "/ip4/57.129.81.31/tcp/4001/p2p/12D3KooWNxt9bNvqftdqXg98JcUHreGxedWSZRUbyqXJ6CW7GaD4",
|
||||
// "/ip4/38.242.250.186/tcp/4001/p2p/12D3KooWGbdnA22bN24X2gyY1o9jozwTBq9wbfvwtJ7G4XQ9JgFm",
|
||||
"/ip4/127.0.0.1/tcp/4001/p2p/12D3KooWDL6LSjwwP5FwboV9JaTZzuxr8EhjbcZGFfnyFMDt1UDx",
|
||||
}
|
||||
|
||||
BootstrapPort = 4001
|
||||
|
@ -1,6 +1,17 @@
|
||||
package pubsub
|
||||
|
||||
import "go.uber.org/zap"
|
||||
import (
|
||||
"fmt"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// Logf is a package-level logger function used by pubsub internals.
|
||||
// By default it is a no-op to avoid polluting stdout; applications can
|
||||
// assign it (e.g., to a UI-backed logger) to surface logs as needed.
|
||||
var Logf = func(format string, args ...interface{}) { _ = fmt.Sprintf(format, args...) }
|
||||
|
||||
// SetLogFunc allows applications to provide a custom logger sink.
|
||||
func SetLogFunc(f func(string, ...interface{})) { if f != nil { Logf = f } }
|
||||
|
||||
// newPubSubLogger creates a zap.Logger for pubsub components.
|
||||
// Quiet mode can be handled by callers by using production config externally;
|
||||
|
Loading…
x
Reference in New Issue
Block a user