Skip to content

Commit bbd9b10

Browse files
authored
Refactor nonLockedTxsByInputs (#3178)
1 parent 64a913d commit bbd9b10

File tree

2 files changed

+6
-18
lines changed

2 files changed

+6
-18
lines changed

src/llmq/quorums_instantsend.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@ void CInstantSendManager::AddNonLockedTx(const CTransactionRef& tx, const CBlock
10521052

10531053
if (res.second) {
10541054
for (auto& in : tx->vin) {
1055-
nonLockedTxsByInputs.emplace(in.prevout.hash, std::make_pair(in.prevout.n, tx->GetHash()));
1055+
nonLockedTxsByOutpoints.emplace(in.prevout, tx->GetHash());
10561056
}
10571057
}
10581058

@@ -1088,16 +1088,7 @@ void CInstantSendManager::RemoveNonLockedTx(const uint256& txid, bool retryChild
10881088
nonLockedTxs.erase(jt);
10891089
}
10901090
}
1091-
1092-
auto its = nonLockedTxsByInputs.equal_range(in.prevout.hash);
1093-
for (auto kt = its.first; kt != its.second; ) {
1094-
if (kt->second.first != in.prevout.n) {
1095-
++kt;
1096-
continue;
1097-
} else {
1098-
kt = nonLockedTxsByInputs.erase(kt);
1099-
}
1100-
}
1091+
nonLockedTxsByOutpoints.erase(in.prevout);
11011092
}
11021093
}
11031094

@@ -1237,12 +1228,9 @@ void CInstantSendManager::ResolveBlockConflicts(const uint256& islockHash, const
12371228
{
12381229
LOCK(cs);
12391230
for (auto& in : islock.inputs) {
1240-
auto its = nonLockedTxsByInputs.equal_range(in.hash);
1241-
for (auto it = its.first; it != its.second; ++it) {
1242-
if (it->second.first != in.n) {
1243-
continue;
1244-
}
1245-
auto& conflictTxid = it->second.second;
1231+
auto it = nonLockedTxsByOutpoints.find(in);
1232+
if (it != nonLockedTxsByOutpoints.end()) {
1233+
auto& conflictTxid = it->second;
12461234
if (conflictTxid == islock.txid) {
12471235
continue;
12481236
}

src/llmq/quorums_instantsend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class CInstantSendManager : public CRecoveredSigsListener
107107
std::unordered_set<uint256, StaticSaltedHasher> children;
108108
};
109109
std::unordered_map<uint256, NonLockedTxInfo, StaticSaltedHasher> nonLockedTxs;
110-
std::unordered_multimap<uint256, std::pair<uint32_t, uint256>> nonLockedTxsByInputs;
110+
std::unordered_map<COutPoint, uint256, SaltedOutpointHasher> nonLockedTxsByOutpoints;
111111

112112
std::unordered_set<uint256, StaticSaltedHasher> pendingRetryTxs;
113113

0 commit comments

Comments
 (0)