Skip to content

Commit

Permalink
[fold] use unordered_set
Browse files Browse the repository at this point in the history
  • Loading branch information
dangell7 committed Nov 7, 2024
1 parent 6ed4ac8 commit 52f1ba9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/test/app/Batch_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1641,6 +1641,7 @@ class Batch_test : public beast::unit_test::suite
// TODO: test with `tfPartialPayment`
// TODO: add a test case to exercise the behavior where the last signer
// signature is correct, but previous ones are bad.
// TODO: tfUntilFailure verify it's possible that none of the inner txns succeeds and yet the batch txn is "successful"?
}

public:
Expand Down
8 changes: 4 additions & 4 deletions src/xrpld/app/tx/detail/Batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ Batch::preflight(PreflightContext const& ctx)
}
}

std::set<AccountID> uniqueSigners;
std::set<uint256> uniqueHashes;
std::unordered_set<AccountID> uniqueSigners;
std::unordered_set<uint256, beast::uhash<>> uniqueHashes;
for (int i = 0; i < txns.size(); ++i)
{
if (!uniqueHashes.insert(hashes[i]).second)
if (!uniqueHashes.emplace(hashes[i]).second)
{
JLOG(ctx.j.trace()) << "Batch: duplicate TxID found.";
return temMALFORMED;
Expand Down Expand Up @@ -193,7 +193,7 @@ Batch::preflight(PreflightContext const& ctx)
continue;

// Add the inner account to the unique signers set.
uniqueSigners.insert(innerAccount);
uniqueSigners.emplace(innerAccount);

// Validate that the account for this (inner) txn has a signature in the
// batch signers array.
Expand Down

0 comments on commit 52f1ba9

Please sign in to comment.