chore(wallet) minor improvement to matching transactions

Made while hunting for the hash used for matching ID madness.

Updates: #14071
This commit is contained in:
Stefan 2024-04-04 23:06:39 +03:00 committed by Stefan Dunca
parent 62405b4def
commit 9986125982
1 changed files with 15 additions and 7 deletions

View File

@ -322,6 +322,20 @@ func (c *transfersCommand) saveAndConfirmPending(allTransfers []Transfer, blockN
return resErr return resErr
} }
func externalTransactionOrError(err error, mTID int64) bool {
if err == sql.ErrNoRows {
// External transaction downloaded, ignore it
return true
} else if err != nil {
log.Warn("GetOwnedMultiTransactionID", "error", err)
return true
} else if mTID <= 0 {
// Existing external transaction, ignore it
return true
}
return false
}
func (c *transfersCommand) confirmPendingTransactions(tx *sql.Tx, allTransfers []Transfer) (notifyFunctions []func()) { func (c *transfersCommand) confirmPendingTransactions(tx *sql.Tx, allTransfers []Transfer) (notifyFunctions []func()) {
notifyFunctions = make([]func(), 0) notifyFunctions = make([]func(), 0)
@ -335,17 +349,11 @@ func (c *transfersCommand) confirmPendingTransactions(tx *sql.Tx, allTransfers [
continue continue
} else { } else {
// Outside transaction, already confirmed by another duplicate or not yet downloaded // Outside transaction, already confirmed by another duplicate or not yet downloaded
existingMTID, err := GetOwnedMultiTransactionID(tx, chainID, tr.ID, tr.Address)
if err == sql.ErrNoRows || existingMTID == 0 {
// Outside transaction, ignore it
continue
} else if err != nil {
log.Warn("GetOwnedMultiTransactionID", "error", err)
existingMTID, err := GetOwnedMultiTransactionID(tx, chainID, txHash, tr.Address) existingMTID, err := GetOwnedMultiTransactionID(tx, chainID, txHash, tr.Address)
if externalTransactionOrError(err, existingMTID) {
continue continue
} }
mTID = w_common.NewAndSet(existingMTID) mTID = w_common.NewAndSet(existingMTID)
} }
} else if err != nil { } else if err != nil {
log.Warn("GetOwnedPendingStatus", "error", err) log.Warn("GetOwnedPendingStatus", "error", err)