mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Refactor nonLockedTxsByInputs (#3178)
This commit is contained in:
parent
64a913d6f9
commit
bbd9b10d47
@ -1052,7 +1052,7 @@ void CInstantSendManager::AddNonLockedTx(const CTransactionRef& tx, const CBlock
|
|||||||
|
|
||||||
if (res.second) {
|
if (res.second) {
|
||||||
for (auto& in : tx->vin) {
|
for (auto& in : tx->vin) {
|
||||||
nonLockedTxsByInputs.emplace(in.prevout.hash, std::make_pair(in.prevout.n, tx->GetHash()));
|
nonLockedTxsByOutpoints.emplace(in.prevout, tx->GetHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1088,16 +1088,7 @@ void CInstantSendManager::RemoveNonLockedTx(const uint256& txid, bool retryChild
|
|||||||
nonLockedTxs.erase(jt);
|
nonLockedTxs.erase(jt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
nonLockedTxsByOutpoints.erase(in.prevout);
|
||||||
auto its = nonLockedTxsByInputs.equal_range(in.prevout.hash);
|
|
||||||
for (auto kt = its.first; kt != its.second; ) {
|
|
||||||
if (kt->second.first != in.prevout.n) {
|
|
||||||
++kt;
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
kt = nonLockedTxsByInputs.erase(kt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1237,12 +1228,9 @@ void CInstantSendManager::ResolveBlockConflicts(const uint256& islockHash, const
|
|||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
for (auto& in : islock.inputs) {
|
for (auto& in : islock.inputs) {
|
||||||
auto its = nonLockedTxsByInputs.equal_range(in.hash);
|
auto it = nonLockedTxsByOutpoints.find(in);
|
||||||
for (auto it = its.first; it != its.second; ++it) {
|
if (it != nonLockedTxsByOutpoints.end()) {
|
||||||
if (it->second.first != in.n) {
|
auto& conflictTxid = it->second;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
auto& conflictTxid = it->second.second;
|
|
||||||
if (conflictTxid == islock.txid) {
|
if (conflictTxid == islock.txid) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ private:
|
|||||||
std::unordered_set<uint256, StaticSaltedHasher> children;
|
std::unordered_set<uint256, StaticSaltedHasher> children;
|
||||||
};
|
};
|
||||||
std::unordered_map<uint256, NonLockedTxInfo, StaticSaltedHasher> nonLockedTxs;
|
std::unordered_map<uint256, NonLockedTxInfo, StaticSaltedHasher> nonLockedTxs;
|
||||||
std::unordered_multimap<uint256, std::pair<uint32_t, uint256>> nonLockedTxsByInputs;
|
std::unordered_map<COutPoint, uint256, SaltedOutpointHasher> nonLockedTxsByOutpoints;
|
||||||
|
|
||||||
std::unordered_set<uint256, StaticSaltedHasher> pendingRetryTxs;
|
std::unordered_set<uint256, StaticSaltedHasher> pendingRetryTxs;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user