Skip to content

Commit

Permalink
multi: fix error checks (#3039)
Browse files Browse the repository at this point in the history
Signed-off-by: Philemon Ukane <ukanephilemon@gmail.com>
  • Loading branch information
ukane-philemon authored and buck54321 committed Oct 30, 2024
1 parent 74b7816 commit 5c6601f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
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 @@ -9389,10 +9389,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 @@ -9427,10 +9427,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

0 comments on commit 5c6601f

Please sign in to comment.