From b41ca4de1108c489902187ad6629e426a5ab4b62 Mon Sep 17 00:00:00 2001 From: charliec Date: Mon, 2 Oct 2023 15:46:25 -0500 Subject: [PATCH] allow 0 amount when posting confirmation and a bit optimization --- zetaclient/bitcoin_client.go | 9 +++------ zetaclient/zetacore_observer.go | 5 ++++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/zetaclient/bitcoin_client.go b/zetaclient/bitcoin_client.go index c2a306ff32..b4d2af9b4f 100644 --- a/zetaclient/bitcoin_client.go +++ b/zetaclient/bitcoin_client.go @@ -377,12 +377,9 @@ func (ob *BitcoinChainClient) IsSendOutTxProcessed(sendHash string, nonce uint64 } var amount float64 - if res.Amount > 0 { - ob.logger.ObserveOutTx.Warn().Msg("IsSendOutTxProcessed: res.Amount > 0") + if res.Amount >= 0 { + ob.logger.ObserveOutTx.Warn().Msgf("IsSendOutTxProcessed: res.Amount >= 0") amount = res.Amount - } else if res.Amount == 0 { - ob.logger.ObserveOutTx.Error().Msg("IsSendOutTxProcessed: res.Amount == 0") - return false, false, nil } else { amount = -res.Amount } @@ -657,7 +654,7 @@ func (ob *BitcoinChainClient) refreshPendingNonce() { pendingNonce := ob.pendingNonce ob.mu.Unlock() - if p.NonceLow > 0 && uint64(p.NonceLow) >= pendingNonce { + if p.NonceLow > 0 && uint64(p.NonceLow) > pendingNonce { // get the last included outTx hash txid, err := ob.getOutTxidByNonce(uint64(p.NonceLow)-1, false) if err != nil { diff --git a/zetaclient/zetacore_observer.go b/zetaclient/zetacore_observer.go index 060c641cf8..770d0d3461 100644 --- a/zetaclient/zetacore_observer.go +++ b/zetaclient/zetacore_observer.go @@ -172,7 +172,10 @@ func (co *CoreObserver) startSendScheduler() { outTxID := fmt.Sprintf("%s-%d-%d", cctx.Index, params.ReceiverChainId, nonce) // would outTxID a better ID? // Process Bitcoin OutTx - if common.IsBitcoinChain(c.ChainId) && !outTxMan.IsOutTxActive(outTxID) { + if common.IsBitcoinChain(c.ChainId) { + if outTxMan.IsOutTxActive(outTxID) { + break // there is no need to process cctx with future nonces + } if stop := co.processBitcoinOutTx(outTxMan, idx, cctx, signer, ob, currentHeight); stop { break }