diff --git a/cmd/config.yaml b/cmd/config.yaml index e491dcd..6b2ad84 100644 --- a/cmd/config.yaml +++ b/cmd/config.yaml @@ -1,5 +1,5 @@ --- -block_worker: https://mainnet.zus.network/dns +block_worker: https://mainnet.zus.network/dns #override if local nodes are available signature_scheme: bls0chain min_submit: 50 min_confirmation: 50 diff --git a/cmd/root.go b/cmd/root.go index 1a64a65..b0a5784 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -5,9 +5,11 @@ import ( "encoding/json" "fmt" "io/ioutil" + "net/http" "os" "path/filepath" "sync" + "time" "github.com/0chain/gosdk/core/client" "github.com/0chain/gosdk/core/conf" @@ -30,7 +32,6 @@ var nonce int64 // If the fee is absent/low it is adjusted to the min fee required // (acquired from miner) for the transaction to write into blockchain. var gTxnFee float64 - var clientConfig string var minSubmit int var minCfm int @@ -100,6 +101,12 @@ func initZCNCore() { ethereumNodeURL := cfgConfig.GetString("ethereum_node_url") zauthServer := cfgConfig.GetString("zauth_server") + // If block_worker is empty, use a working DNS service for initialization + if blockWorker == "" { + fmt.Println("No block_worker specified, using mainnet DNS for initialization...") + blockWorker = "https://mainnet.zus.network/dns" + } + cfg := conf.Config{ BlockWorker: blockWorker, SignatureScheme: signatureScheme, @@ -113,7 +120,13 @@ func initZCNCore() { err := client.Init(context.Background(), cfg) if err != nil { - ExitWithError(err.Error()) + ExitWithError("Failed to initialize client: " + err.Error()) + } + + // After successful initialization, override with local nodes if network.yaml exists + if cfgNetwork != nil { + fmt.Println("✓ Client initialized successfully") + fmt.Println("Local nodes from network.yaml will be used for transactions") } }