mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
Also consider txindex for transactions in AlreadyHave() (#3126)
This avoids many false negatives where TXs are announced to us which are already mined and then were spent later.
This commit is contained in:
parent
d9e98e31ea
commit
b4aefb513d
@ -25,6 +25,7 @@
|
||||
#include "reverse_iterator.h"
|
||||
#include "scheduler.h"
|
||||
#include "tinyformat.h"
|
||||
#include "txdb.h"
|
||||
#include "txmempool.h"
|
||||
#include "ui_interface.h"
|
||||
#include "util.h"
|
||||
@ -1019,7 +1020,8 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
return (recentRejects->contains(inv.hash) && !llmq::quorumInstantSendManager->IsLocked(inv.hash)) ||
|
||||
mempool.exists(inv.hash) ||
|
||||
pcoinsTip->HaveCoinInCache(COutPoint(inv.hash, 0)) || // Best effort: only try output 0 and 1
|
||||
pcoinsTip->HaveCoinInCache(COutPoint(inv.hash, 1));
|
||||
pcoinsTip->HaveCoinInCache(COutPoint(inv.hash, 1)) ||
|
||||
(fTxIndex && pblocktree->HasTxIndex(inv.hash));
|
||||
}
|
||||
|
||||
case MSG_BLOCK:
|
||||
|
@ -240,6 +240,10 @@ bool CBlockTreeDB::WriteBatchSync(const std::vector<std::pair<int, const CBlockF
|
||||
return WriteBatch(batch, true);
|
||||
}
|
||||
|
||||
bool CBlockTreeDB::HasTxIndex(const uint256& txid) {
|
||||
return Exists(std::make_pair(DB_TXINDEX, txid));
|
||||
}
|
||||
|
||||
bool CBlockTreeDB::ReadTxIndex(const uint256 &txid, CDiskTxPos &pos) {
|
||||
return Read(std::make_pair(DB_TXINDEX, txid), pos);
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ public:
|
||||
bool ReadLastBlockFile(int &nFile);
|
||||
bool WriteReindexing(bool fReindex);
|
||||
bool ReadReindexing(bool &fReindex);
|
||||
bool HasTxIndex(const uint256 &txid);
|
||||
bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos);
|
||||
bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list);
|
||||
bool ReadSpentIndex(CSpentIndexKey &key, CSpentIndexValue &value);
|
||||
|
Loading…
Reference in New Issue
Block a user