From 2ea0ef66eab56a794d4bd045a517661dc046b8ef Mon Sep 17 00:00:00 2001 From: Javed Khan Date: Wed, 15 Oct 2014 15:33:58 +0530 Subject: [PATCH] revert cafile error handling, continue with nil This reverts commit 2a5e8587f65cac4780647d80b9e48e9695044b58. --- btcwallet.go | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/btcwallet.go b/btcwallet.go index f5ff669..6ea6e32 100644 --- a/btcwallet.go +++ b/btcwallet.go @@ -82,10 +82,6 @@ func walletMain() error { // Shutdown the server if an interrupt signal is received. addInterruptHandler(server.Stop) - // Create a channel to report unrecoverable errors during chain - // server connection - chainSvrErrors := make(chan error) - // Create channel so that the goroutine which opens the chain server // connection can pass the conn to the goroutine which opens the wallet. // Buffer the channel so sends are not blocked, since if the wallet is @@ -93,22 +89,18 @@ func walletMain() error { chainSvrChan := make(chan *chain.Client, 1) go func() { - defer close(chainSvrErrors) - // Read CA certs and create the RPC client. certs, err := ioutil.ReadFile(cfg.CAFile) if err != nil { - log.Errorf("Cannot open CA file: %v", err) - close(chainSvrChan) - chainSvrErrors <- err - return + log.Warnf("Cannot open CA file: %v", err) + // If there's an error reading the CA file, continue + // with nil certs and without the client connection + certs = nil } rpcc, err := chain.NewClient(activeNet.Params, cfg.RPCConnect, cfg.BtcdUsername, cfg.BtcdPassword, certs) if err != nil { log.Errorf("Cannot create chain server RPC client: %v", err) - close(chainSvrChan) - chainSvrErrors <- err return } err = rpcc.Start() @@ -154,29 +146,16 @@ func walletMain() error { // Start wallet goroutines and handle RPC client notifications // if the chain server connection was opened. - // If the chain server connection failed due to an unrecoverable error, - // doesn't matter that the wallet goroutines are not started since the - // entire program will exit on receiving chainSvrErrors select { - case chainSvr, ok := <-chainSvrChan: - if ok { - // Start wallet goroutines only when the chain rpc client was created - w.Start(chainSvr) - } + case chainSvr := <-chainSvrChan: + w.Start(chainSvr) case <-server.quit: } }() - // Check for unrecoverable errors during chain server connection, and return - // the error, if any. - err, ok := <-chainSvrErrors - if ok { - return err - } - // Check for unrecoverable errors during the wallet startup, and return // the error, if any. - err, ok = <-walletOpenErrors + err, ok := <-walletOpenErrors if ok { return err }