rippled
Loading...
Searching...
No Matches
CanonicalTXSet.cpp
1#include <xrpld/app/misc/CanonicalTXSet.h>
2
3namespace ripple {
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)),
37 txn->getSeqProxy(),
38 txn->getTransactionID()),
39 txn));
40}
41
44{
45 // Determining the next viable transaction for an account with Tickets:
46 //
47 // 1. Prioritize transactions with Sequences over transactions with
48 // Tickets.
49 //
50 // 2. For transactions not using Tickets, look for consecutive Sequence
51 // numbers. For transactions using Tickets, don't worry about
52 // consecutive Sequence numbers. Tickets can process out of order.
53 //
54 // 3. After handling all transactions with Sequences, return Tickets
55 // with the lowest Ticket ID first.
57 uint256 const effectiveAccount{accountKey(tx->getAccountID(sfAccount))};
58
59 auto const seqProxy = tx->getSeqProxy();
60 Key const after(effectiveAccount, seqProxy, beast::zero);
61 auto const itrNext{map_.lower_bound(after)};
62 if (itrNext != map_.end() &&
63 itrNext->first.getAccount() == effectiveAccount &&
64 (!itrNext->second->getSeqProxy().isSeq() ||
65 itrNext->second->getSeqProxy().value() == seqProxy.value() + 1))
66 {
67 result = std::move(itrNext->second);
68 map_.erase(itrNext);
69 }
70
71 return result;
72}
73
74} // namespace ripple
void insert(std::shared_ptr< STTx const > const &txn)
std::shared_ptr< STTx const > popAcctTransaction(std::shared_ptr< STTx const > const &tx)
uint256 accountKey(AccountID const &account)
std::map< Key, std::shared_ptr< STTx const > > map_
iterator begin()
Definition base_uint.h:117
T make_pair(T... args)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
bool operator<(Slice const &lhs, Slice const &rhs) noexcept
Definition Slice.h:204
bool after(NetClock::time_point now, std::uint32_t mark)
Has the specified time passed?
Definition View.cpp:3247