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(std::make_pair(
36 Key(accountKey(txn->getAccountID(sfAccount)), txn->getSeqProxy(), txn->getTransactionID()), txn));
37}
38
41{
42 // Determining the next viable transaction for an account with Tickets:
43 //
44 // 1. Prioritize transactions with Sequences over transactions with
45 // Tickets.
46 //
47 // 2. For transactions not using Tickets, look for consecutive Sequence
48 // numbers. For transactions using Tickets, don't worry about
49 // consecutive Sequence numbers. Tickets can process out of order.
50 //
51 // 3. After handling all transactions with Sequences, return Tickets
52 // with the lowest Ticket ID first.
54 uint256 const effectiveAccount{accountKey(tx->getAccountID(sfAccount))};
55
56 auto const seqProxy = tx->getSeqProxy();
57 Key const after(effectiveAccount, seqProxy, beast::zero);
58 auto const itrNext{map_.lower_bound(after)};
59 if (itrNext != map_.end() && itrNext->first.getAccount() == effectiveAccount &&
60 (!itrNext->second->getSeqProxy().isSeq() || itrNext->second->getSeqProxy().value() == seqProxy.value() + 1))
61 {
62 result = std::move(itrNext->second);
63 map_.erase(itrNext);
64 }
65
66 return result;
67}
68
69} // 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