multi: wait for rpcclients shutdown to complete

We need to call `WaitForShutdown` after stopping the rpc clients of the
chain backends.
This commit is contained in:
yyforyongyu 2024-11-03 20:19:38 +08:00
parent 304c8df7b9
commit 523ecc0653
No known key found for this signature in database
GPG Key ID: 9BCD95C4FF296868
7 changed files with 8 additions and 4 deletions

View File

@ -139,6 +139,7 @@ func (b *BitcoindNotifier) Stop() error {
// Shutdown the rpc client, this gracefully disconnects from bitcoind,
// and cleans up all related resources.
b.chainConn.Stop()
b.chainConn.WaitForShutdown()
close(b.quit)
b.wg.Wait()

View File

@ -180,7 +180,7 @@ func (b *BtcdNotifier) Stop() error {
// Shutdown the rpc client, this gracefully disconnects from btcd, and
// cleans up all related resources.
b.chainConn.Shutdown()
b.chainConn.Stop()
close(b.quit)
b.wg.Wait()

2
go.mod
View File

@ -11,7 +11,7 @@ require (
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7
github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5
github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5
github.com/btcsuite/btcwallet/wallet/txrules v1.2.2
github.com/btcsuite/btcwallet/walletdb v1.4.4

4
go.sum
View File

@ -95,8 +95,8 @@ github.com/btcsuite/btclog v0.0.0-20241003133417-09c4e92e319c/go.mod h1:w7xnGOhw
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7 h1:3Ct3zN3VCEKVm5nceWBBEKczc+jvTfVyOEG71ob2Yuc=
github.com/btcsuite/btclog/v2 v2.0.0-20241017175713-3428138b75c7/go.mod h1:XItGUfVOxotJL8kkuk2Hj3EVow5KCugXl3wWfQ6K0AE=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5 h1:zYy233eUBvkF3lq2MUkybEhxhDsrRDSgiToIKN57mtk=
github.com/btcsuite/btcwallet v0.16.10-0.20240912233857-ffb143c77cc5/go.mod h1:1HJXYbjJzgumlnxOC2+ViR1U+gnHWoOn7WeK5OfY1eU=
github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa h1:x7vYpwkPL5zeJEWPPaRunybH9ERRMGWeNf7x/0aU/38=
github.com/btcsuite/btcwallet v0.16.10-0.20241113134707-b4ff60753aaa/go.mod h1:1HJXYbjJzgumlnxOC2+ViR1U+gnHWoOn7WeK5OfY1eU=
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5 h1:Rr0njWI3r341nhSPesKQ2JF+ugDSzdPoeckS75SeDZk=
github.com/btcsuite/btcwallet/wallet/txauthor v1.3.5/go.mod h1:+tXJ3Ym0nlQc/iHSwW1qzjmPs3ev+UVWMbGgfV1OZqU=
github.com/btcsuite/btcwallet/wallet/txrules v1.2.2 h1:YEO+Lx1ZJJAtdRrjuhXjWrYsmAk26wLTlNzxt2q0lhk=

View File

@ -238,6 +238,7 @@ func (b *BtcdEstimator) Stop() error {
b.filterManager.Stop()
b.btcdConn.Shutdown()
b.btcdConn.WaitForShutdown()
return nil
}

View File

@ -136,6 +136,7 @@ func (b *BitcoindFilteredChainView) Stop() error {
// Shutdown the rpc client, this gracefully disconnects from bitcoind's
// zmq socket, and cleans up all related resources.
b.chainClient.Stop()
b.chainClient.WaitForShutdown()
b.blockQueue.Stop()

View File

@ -146,6 +146,7 @@ func (b *BtcdFilteredChainView) Stop() error {
// Shutdown the rpc client, this gracefully disconnects from btcd, and
// cleans up all related resources.
b.btcdConn.Shutdown()
b.btcdConn.WaitForShutdown()
b.blockQueue.Stop()