rippled
Loading...
Searching...
No Matches
CanonicalTXSet.cpp
1#include <xrpld/app/misc/CanonicalTXSet.h>
2
3namespace xrpl {
4
5bool
7{
8 if (lhs.account_ < rhs.account_)
9 return true;
10
11 if (lhs.account_ > rhs.account_)
12 return false;
13
14 if (lhs.seqProxy_ < rhs.seqProxy_)
15 return true;
16
17 if (lhs.seqProxy_ > rhs.seqProxy_)
18 return false;
19
20 return lhs.txId_ < rhs.txId_;
21}
22
25{
26 uint256 ret = beast::zero;
27 memcpy(ret.begin(), account.begin(), account.size());
28 ret ^= salt_;
29 return ret;
30}
31
32void
34{
35 map_.insert(
37 Key(accountKey(txn->getAccountID(sfAccount)), txn->getSeqProxy(), txn->getTransactionID()), txn));
38}
39
42{
43 // Determining the next viable transaction for an account with Tickets:
44 //
45 // 1. Prioritize transactions with Sequences over transactions with
46 // Tickets.
47 //
48 // 2. For transactions not using Tickets, look for consecutive Sequence
49 // numbers. For transactions using Tickets, don't worry about
50 // consecutive Sequence numbers. Tickets can process out of order.
51 //
52 // 3. After handling all transactions with Sequences, return Tickets
53 // with the lowest Ticket ID first.
55 uint256 const effectiveAccount{accountKey(tx->getAccountID(sfAccount))};
56
57 auto const seqProxy = tx->getSeqProxy();
58 Key const after(effectiveAccount, seqProxy, beast::zero);
59 auto const itrNext{map_.lower_bound(after)};
60 if (itrNext != map_.end() && itrNext->first.getAccount() == effectiveAccount &&
61 (!itrNext->second->getSeqProxy().isSeq() || itrNext->second->getSeqProxy().value() == seqProxy.value() + 1))
62 {
63 result = std::move(itrNext->second);
64 map_.erase(itrNext);
65 }
66
67 return result;
68}
69
70} // namespace xrpl
void insert(std::shared_ptr< STTx const > const &txn)
std::map< Key, std::shared_ptr< STTx const > > map_
std::shared_ptr< STTx const > popAcctTransaction(std::shared_ptr< STTx const > const &tx)
uint256 accountKey(AccountID const &account)
iterator begin()
Definition base_uint.h:112
T make_pair(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool operator<(Slice const &lhs, Slice const &rhs) noexcept
Definition Slice.h:198
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:3436