Skip to content

Commit

Permalink
allow 0 amount when posting confirmation and a bit optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Oct 2, 2023
1 parent d26b447 commit b41ca4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 3 additions & 6 deletions zetaclient/bitcoin_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion zetaclient/zetacore_observer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit b41ca4d

Please sign in to comment.