From 9e67f25957faef0a434dc8aafb9a2921eb532672 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Mon, 8 Apr 2019 12:46:50 +0200 Subject: [PATCH] chainregistry: only stop ChainService after successful start --- chainregistry.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/chainregistry.go b/chainregistry.go index 55fba4f3..cc3b05ea 100644 --- a/chainregistry.go +++ b/chainregistry.go @@ -730,14 +730,15 @@ func initNeutrinoBackend(chainDir string) (*neutrino.ChainService, func(), error "client: %v", err) } + if err := neutrinoCS.Start(); err != nil { + db.Close() + return nil, nil, err + } + cleanUp := func() { db.Close() neutrinoCS.Stop() } - if err := neutrinoCS.Start(); err != nil { - cleanUp() - return nil, nil, err - } return neutrinoCS, cleanUp, nil }