Skip to content

Commit

Permalink
adusted error handling and code comments according to PR review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Oct 4, 2023
1 parent 0d38643 commit e0cf329
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,15 @@ func (ob *BitcoinChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64
// Get original cctx parameters
params, err := ob.GetPendingCctxParams(nonce)
if err != nil {
ob.logger.ObserveOutTx.Info().Msgf("IsSendOutTxProcessed: can't find pending cctx for nonce %d", nonce)
return false, false, nil
ob.logger.ObserveOutTx.Warn().Msgf("IsSendOutTxProcessed: can't find pending cctx for nonce %d", nonce)
return false, false, err
}

// Try including this outTx broadcasted by myself
inMempool, err := ob.checkNSaveIncludedTx(txnHash, params)
if err != nil {
ob.logger.ObserveOutTx.Error().Err(err).Msg("IsSendOutTxProcessed: checkNSaveIncludedTx failed")
return false, false, nil
return false, false, err
}
if inMempool { // to avoid unnecessary Tss keysign
ob.logger.ObserveOutTx.Info().Msgf("IsSendOutTxProcessed: outTx %s is still in mempool", outTxID)
Expand All @@ -391,8 +391,8 @@ func (ob *BitcoinChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64

sats, err := getSatoshis(amount)
if err != nil {
ob.logger.ObserveOutTx.Warn().Msgf("IsSendOutTxProcessed: getSatoshis error: %s", err)
return false, false, nil
ob.logger.ObserveOutTx.Error().Msgf("IsSendOutTxProcessed: getSatoshis error: %s", err)
return false, false, err
}
amountInSat := big.NewInt(sats)
if res.Confirmations < ob.ConfirmationsThreshold(amountInSat) {
Expand Down
4 changes: 3 additions & 1 deletion zetaclient/zetacore_observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ func (co *CoreObserver) startSendScheduler() {
// Process Bitcoin OutTx
if common.IsBitcoinChain(c.ChainId) {
if outTxMan.IsOutTxActive(outTxID) {
break // there is no need to process cctx with future nonces
// bitcoun outTx is processed sequencially by nonce
// if the current outTx is being processed, there is no need to process outTx with future nonces
break
}
// #nosec G701 positive
if stop := co.processBitcoinOutTx(outTxMan, uint64(idx), cctx, signer, ob, currentHeight); stop {
Expand Down

0 comments on commit e0cf329

Please sign in to comment.