Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: fix error checks in core and dcr wallet #3039

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions client/asset/dcr/dcr.go
Original file line number Diff line number Diff line change
Expand Up @@ -6611,7 +6611,7 @@ func (dcr *ExchangeWallet) monitorBlocks(ctx context.Context) {
}

if walletBlock == nil {
dcr.handleTipChange(ctx, newTip.hash, newTip.height, nil)
dcr.handleTipChange(ctx, newTip.hash, newTip.height)
return
}

Expand Down Expand Up @@ -6639,7 +6639,7 @@ func (dcr *ExchangeWallet) monitorBlocks(ctx context.Context) {
"never reported: %s (%d). If you see this message repeatedly, it may indicate "+
"an issue with the wallet.", newTip.hash, newTip.height)
}
dcr.handleTipChange(ctx, newTip.hash, newTip.height, nil)
dcr.handleTipChange(ctx, newTip.hash, newTip.height)
}),
}
}
Expand All @@ -6666,7 +6666,7 @@ func (dcr *ExchangeWallet) monitorBlocks(ctx context.Context) {
}
queuedBlock = nil
}
dcr.handleTipChange(ctx, walletTip.hash, walletTip.height, nil)
dcr.handleTipChange(ctx, walletTip.hash, walletTip.height)
case <-ctx.Done():
return
}
Expand All @@ -6678,9 +6678,8 @@ func (dcr *ExchangeWallet) monitorBlocks(ctx context.Context) {
}
}

func (dcr *ExchangeWallet) handleTipChange(ctx context.Context, newTipHash *chainhash.Hash, newTipHeight int64, err error) {
if err != nil {
dcr.log.Error(err)
func (dcr *ExchangeWallet) handleTipChange(ctx context.Context, newTipHash *chainhash.Hash, newTipHeight int64) {
if dcr.ctx.Err() != nil {
return
}

Expand Down
14 changes: 7 additions & 7 deletions client/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -9385,10 +9385,10 @@ func handleRedemptionRoute(c *Core, dc *dexConnection, msg *msgjson.Message) err
// zero, a resync monitor goroutine is launched to poll SyncStatus until the
// wallet has caught up with its network. The monitor goroutine will regularly
// emit wallet state notes, and once sync has been restored, a wallet balance
// note will be emitted. If err is non-nil, numPeers should be zero.
func (c *Core) peerChange(w *xcWallet, numPeers uint32, err error) {
if err != nil {
c.log.Warnf("%s wallet communication issue: %q", unbip(w.AssetID), err.Error())
// note will be emitted. If peerChangeErr is non-nil, numPeers should be zero.
func (c *Core) peerChange(w *xcWallet, numPeers uint32, peerChangeErr error) {
if peerChangeErr != nil {
c.log.Warnf("%s wallet communication issue: %q", unbip(w.AssetID), peerChangeErr.Error())
} else if numPeers == 0 {
c.log.Warnf("Wallet for asset %s has zero network peers!", unbip(w.AssetID))
} else {
Expand Down Expand Up @@ -9423,10 +9423,10 @@ func (c *Core) peerChange(w *xcWallet, numPeers uint32, err error) {

// Send a WalletStateNote in case Synced or anything else has changed.
if atomic.LoadUint32(w.broadcasting) == 1 {
if (numPeers == 0 || err != nil) && !wasDisconnected { // was connected or initial report
if err != nil {
if (numPeers == 0 || peerChangeErr != nil) && !wasDisconnected { // was connected or initial report
if peerChangeErr != nil {
subject, details := c.formatDetails(TopicWalletCommsWarning,
w.Info().Name, err.Error())
w.Info().Name, peerChangeErr.Error())
c.notify(newWalletConfigNote(TopicWalletCommsWarning, subject, details,
db.ErrorLevel, w.state()))
} else {
Expand Down
Loading