/root/bitcoin/src/txrequest.cpp
Line | Count | Source |
1 | | // Copyright (c) 2020-present The Bitcoin Core developers |
2 | | // Distributed under the MIT software license, see the accompanying |
3 | | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
4 | | |
5 | | #include <txrequest.h> |
6 | | |
7 | | #include <crypto/siphash.h> |
8 | | #include <net.h> |
9 | | #include <primitives/transaction.h> |
10 | | #include <random.h> |
11 | | #include <uint256.h> |
12 | | |
13 | | #include <boost/multi_index/indexed_by.hpp> |
14 | | #include <boost/multi_index/ordered_index.hpp> |
15 | | #include <boost/multi_index/sequenced_index.hpp> |
16 | | #include <boost/multi_index/tag.hpp> |
17 | | #include <boost/multi_index_container.hpp> |
18 | | #include <boost/tuple/tuple.hpp> |
19 | | |
20 | | #include <chrono> |
21 | | #include <unordered_map> |
22 | | #include <utility> |
23 | | |
24 | | #include <cassert> |
25 | | |
26 | | namespace { |
27 | | |
28 | | /** The various states a (txhash,peer) pair can be in. |
29 | | * |
30 | | * Note that CANDIDATE is split up into 3 substates (DELAYED, BEST, READY), allowing more efficient implementation. |
31 | | * Also note that the sorting order of ByTxHashView relies on the specific order of values in this enum. |
32 | | * |
33 | | * Expected behaviour is: |
34 | | * - When first announced by a peer, the state is CANDIDATE_DELAYED until reqtime is reached. |
35 | | * - Announcements that have reached their reqtime but not been requested will be either CANDIDATE_READY or |
36 | | * CANDIDATE_BEST. Neither of those has an expiration time; they remain in that state until they're requested or |
37 | | * no longer needed. CANDIDATE_READY announcements are promoted to CANDIDATE_BEST when they're the best one left. |
38 | | * - When requested, an announcement will be in state REQUESTED until expiry is reached. |
39 | | * - If expiry is reached, or the peer replies to the request (either with NOTFOUND or the tx), the state becomes |
40 | | * COMPLETED. |
41 | | */ |
42 | | enum class State : uint8_t { |
43 | | /** A CANDIDATE announcement whose reqtime is in the future. */ |
44 | | CANDIDATE_DELAYED, |
45 | | /** A CANDIDATE announcement that's not CANDIDATE_DELAYED or CANDIDATE_BEST. */ |
46 | | CANDIDATE_READY, |
47 | | /** The best CANDIDATE for a given txhash; only if there is no REQUESTED announcement already for that txhash. |
48 | | * The CANDIDATE_BEST is the highest-priority announcement among all CANDIDATE_READY (and _BEST) ones for that |
49 | | * txhash. */ |
50 | | CANDIDATE_BEST, |
51 | | /** A REQUESTED announcement. */ |
52 | | REQUESTED, |
53 | | /** A COMPLETED announcement. */ |
54 | | COMPLETED, |
55 | | }; |
56 | | |
57 | | //! Type alias for sequence numbers. |
58 | | using SequenceNumber = uint64_t; |
59 | | |
60 | | /** An announcement. This is the data we track for each txid or wtxid that is announced to us by each peer. */ |
61 | | struct Announcement { |
62 | | /** Txid or wtxid that was announced. */ |
63 | | const GenTxid m_gtxid; |
64 | | /** For CANDIDATE_{DELAYED,BEST,READY} the reqtime; for REQUESTED the expiry. */ |
65 | | std::chrono::microseconds m_time; |
66 | | /** What peer the request was from. */ |
67 | | const NodeId m_peer; |
68 | | /** What sequence number this announcement has. */ |
69 | | const SequenceNumber m_sequence : 59; |
70 | | /** Whether the request is preferred. */ |
71 | | const bool m_preferred : 1; |
72 | | /** What state this announcement is in. */ |
73 | | State m_state : 3 {State::CANDIDATE_DELAYED}; |
74 | 332M | State GetState() const { return m_state; } |
75 | 3.13M | void SetState(State state) { m_state = state; } |
76 | | |
77 | | /** Whether this announcement is selected. There can be at most 1 selected peer per txhash. */ |
78 | | bool IsSelected() const |
79 | 847k | { |
80 | 847k | return GetState() == State::CANDIDATE_BEST || GetState() == State::REQUESTED; Branch (80:16): [True: 235k, False: 612k]
Branch (80:55): [True: 75.9k, False: 536k]
|
81 | 847k | } |
82 | | |
83 | | /** Whether this announcement is waiting for a certain time to pass. */ |
84 | | bool IsWaiting() const |
85 | 47.5M | { |
86 | 47.5M | return GetState() == State::REQUESTED || GetState() == State::CANDIDATE_DELAYED; Branch (86:16): [True: 1.82M, False: 45.7M]
Branch (86:50): [True: 14.5M, False: 31.1M]
|
87 | 47.5M | } |
88 | | |
89 | | /** Whether this announcement can feasibly be selected if the current IsSelected() one disappears. */ |
90 | | bool IsSelectable() const |
91 | 32.0M | { |
92 | 32.0M | return GetState() == State::CANDIDATE_READY || GetState() == State::CANDIDATE_BEST; Branch (92:16): [True: 13.3M, False: 18.7M]
Branch (92:56): [True: 13.0M, False: 5.65M]
|
93 | 32.0M | } |
94 | | |
95 | | /** Construct a new announcement from scratch, initially in CANDIDATE_DELAYED state. */ |
96 | | Announcement(const GenTxid& gtxid, NodeId peer, bool preferred, std::chrono::microseconds reqtime, |
97 | | SequenceNumber sequence) |
98 | 2.79M | : m_gtxid(gtxid), m_time(reqtime), m_peer(peer), m_sequence(sequence), m_preferred(preferred) {} |
99 | | }; |
100 | | |
101 | | //! Type alias for priorities. |
102 | | using Priority = uint64_t; |
103 | | |
104 | | /** A functor with embedded salt that computes priority of an announcement. |
105 | | * |
106 | | * Higher priorities are selected first. |
107 | | */ |
108 | | class PriorityComputer { |
109 | | const uint64_t m_k0, m_k1; |
110 | | public: |
111 | | explicit PriorityComputer(bool deterministic) : |
112 | 26.1k | m_k0{deterministic ? 0 : FastRandomContext().rand64()}, Branch (112:14): [True: 26.1k, False: 0]
|
113 | 26.1k | m_k1{deterministic ? 0 : FastRandomContext().rand64()} {} Branch (113:14): [True: 26.1k, False: 0]
|
114 | | |
115 | | Priority operator()(const uint256& txhash, NodeId peer, bool preferred) const |
116 | 11.8M | { |
117 | 11.8M | uint64_t low_bits = CSipHasher(m_k0, m_k1).Write(txhash).Write(peer).Finalize() >> 1; |
118 | 11.8M | return low_bits | uint64_t{preferred} << 63; |
119 | 11.8M | } |
120 | | |
121 | | Priority operator()(const Announcement& ann) const |
122 | 10.2M | { |
123 | 10.2M | return operator()(ann.m_gtxid.ToUint256(), ann.m_peer, ann.m_preferred); |
124 | 10.2M | } |
125 | | }; |
126 | | |
127 | | // Definitions for the 3 indexes used in the main data structure. |
128 | | // |
129 | | // Each index has a By* type to identify it, a By*View data type to represent the view of announcement it is sorted |
130 | | // by, and an By*ViewExtractor type to convert an announcement into the By*View type. |
131 | | // See https://www.boost.org/doc/libs/1_58_0/libs/multi_index/doc/reference/key_extraction.html#key_extractors |
132 | | // for more information about the key extraction concept. |
133 | | |
134 | | // The ByPeer index is sorted by (peer, state == CANDIDATE_BEST, txhash) |
135 | | // |
136 | | // Uses: |
137 | | // * Looking up existing announcements by peer/txhash, by checking both (peer, false, txhash) and |
138 | | // (peer, true, txhash). |
139 | | // * Finding all CANDIDATE_BEST announcements for a given peer in GetRequestable. |
140 | | struct ByPeer {}; |
141 | | using ByPeerView = std::tuple<NodeId, bool, const uint256&>; |
142 | | struct ByPeerViewExtractor |
143 | | { |
144 | | using result_type = ByPeerView; |
145 | | result_type operator()(const Announcement& ann) const |
146 | 86.8M | { |
147 | 86.8M | return ByPeerView{ann.m_peer, ann.GetState() == State::CANDIDATE_BEST, ann.m_gtxid.ToUint256()}; |
148 | 86.8M | } |
149 | | }; |
150 | | |
151 | | // The ByTxHash index is sorted by (txhash, state, priority). |
152 | | // |
153 | | // Note: priority == 0 whenever state != CANDIDATE_READY. |
154 | | // |
155 | | // Uses: |
156 | | // * Deleting all announcements with a given txhash in ForgetTxHash. |
157 | | // * Finding the best CANDIDATE_READY to convert to CANDIDATE_BEST, when no other CANDIDATE_READY or REQUESTED |
158 | | // announcement exists for that txhash. |
159 | | // * Determining when no more non-COMPLETED announcements for a given txhash exist, so the COMPLETED ones can be |
160 | | // deleted. |
161 | | struct ByTxHash {}; |
162 | | using ByTxHashView = std::tuple<const uint256&, State, Priority>; |
163 | | class ByTxHashViewExtractor { |
164 | | const PriorityComputer& m_computer; |
165 | | public: |
166 | 26.1k | explicit ByTxHashViewExtractor(const PriorityComputer& computer) : m_computer(computer) {} |
167 | | using result_type = ByTxHashView; |
168 | | result_type operator()(const Announcement& ann) const |
169 | 36.8M | { |
170 | 36.8M | const Priority prio = (ann.GetState() == State::CANDIDATE_READY) ? m_computer(ann) : 0; Branch (170:31): [True: 9.46M, False: 27.4M]
|
171 | 36.8M | return ByTxHashView{ann.m_gtxid.ToUint256(), ann.GetState(), prio}; |
172 | 36.8M | } |
173 | | }; |
174 | | |
175 | | enum class WaitState { |
176 | | //! Used for announcements that need efficient testing of "is their timestamp in the future?". |
177 | | FUTURE_EVENT, |
178 | | //! Used for announcements whose timestamp is not relevant. |
179 | | NO_EVENT, |
180 | | //! Used for announcements that need efficient testing of "is their timestamp in the past?". |
181 | | PAST_EVENT, |
182 | | }; |
183 | | |
184 | | WaitState GetWaitState(const Announcement& ann) |
185 | 32.4M | { |
186 | 32.4M | if (ann.IsWaiting()) return WaitState::FUTURE_EVENT; Branch (186:9): [True: 13.3M, False: 19.1M]
|
187 | 19.1M | if (ann.IsSelectable()) return WaitState::PAST_EVENT; Branch (187:9): [True: 15.2M, False: 3.91M]
|
188 | 3.91M | return WaitState::NO_EVENT; |
189 | 19.1M | } |
190 | | |
191 | | // The ByTime index is sorted by (wait_state, time). |
192 | | // |
193 | | // All announcements with a timestamp in the future can be found by iterating the index forward from the beginning. |
194 | | // All announcements with a timestamp in the past can be found by iterating the index backwards from the end. |
195 | | // |
196 | | // Uses: |
197 | | // * Finding CANDIDATE_DELAYED announcements whose reqtime has passed, and REQUESTED announcements whose expiry has |
198 | | // passed. |
199 | | // * Finding CANDIDATE_READY/BEST announcements whose reqtime is in the future (when the clock time went backwards). |
200 | | struct ByTime {}; |
201 | | using ByTimeView = std::pair<WaitState, std::chrono::microseconds>; |
202 | | struct ByTimeViewExtractor |
203 | | { |
204 | | using result_type = ByTimeView; |
205 | | result_type operator()(const Announcement& ann) const |
206 | 32.4M | { |
207 | 32.4M | return ByTimeView{GetWaitState(ann), ann.m_time}; |
208 | 32.4M | } |
209 | | }; |
210 | | |
211 | | |
212 | | /** Data type for the main data structure (Announcement objects with ByPeer/ByTxHash/ByTime indexes). */ |
213 | | using Index = boost::multi_index_container< |
214 | | Announcement, |
215 | | boost::multi_index::indexed_by< |
216 | | boost::multi_index::ordered_unique<boost::multi_index::tag<ByPeer>, ByPeerViewExtractor>, |
217 | | boost::multi_index::ordered_non_unique<boost::multi_index::tag<ByTxHash>, ByTxHashViewExtractor>, |
218 | | boost::multi_index::ordered_non_unique<boost::multi_index::tag<ByTime>, ByTimeViewExtractor> |
219 | | > |
220 | | >; |
221 | | |
222 | | /** Helper type to simplify syntax of iterator types. */ |
223 | | template<typename Tag> |
224 | | using Iter = typename Index::index<Tag>::type::iterator; |
225 | | |
226 | | /** Per-peer statistics object. */ |
227 | | struct PeerInfo { |
228 | | size_t m_total = 0; //!< Total number of announcements for this peer. |
229 | | size_t m_completed = 0; //!< Number of COMPLETED announcements for this peer. |
230 | | size_t m_requested = 0; //!< Number of REQUESTED announcements for this peer. |
231 | | }; |
232 | | |
233 | | /** Per-txhash statistics object. Only used for sanity checking. */ |
234 | | struct TxHashInfo |
235 | | { |
236 | | //! Number of CANDIDATE_DELAYED announcements for this txhash. |
237 | | size_t m_candidate_delayed = 0; |
238 | | //! Number of CANDIDATE_READY announcements for this txhash. |
239 | | size_t m_candidate_ready = 0; |
240 | | //! Number of CANDIDATE_BEST announcements for this txhash (at most one). |
241 | | size_t m_candidate_best = 0; |
242 | | //! Number of REQUESTED announcements for this txhash (at most one; mutually exclusive with CANDIDATE_BEST). |
243 | | size_t m_requested = 0; |
244 | | //! The priority of the CANDIDATE_BEST announcement if one exists, or max() otherwise. |
245 | | Priority m_priority_candidate_best = std::numeric_limits<Priority>::max(); |
246 | | //! The highest priority of all CANDIDATE_READY announcements (or min() if none exist). |
247 | | Priority m_priority_best_candidate_ready = std::numeric_limits<Priority>::min(); |
248 | | //! All peers we have an announcement for this txhash for. |
249 | | std::vector<NodeId> m_peers; |
250 | | }; |
251 | | |
252 | | /** Compare two PeerInfo objects. Only used for sanity checking. */ |
253 | | bool operator==(const PeerInfo& a, const PeerInfo& b) |
254 | 10.8k | { |
255 | 10.8k | return std::tie(a.m_total, a.m_completed, a.m_requested) == |
256 | 10.8k | std::tie(b.m_total, b.m_completed, b.m_requested); |
257 | 10.8k | }; |
258 | | |
259 | | /** (Re)compute the PeerInfo map from the index. Only used for sanity checking. */ |
260 | | std::unordered_map<NodeId, PeerInfo> RecomputePeerInfo(const Index& index) |
261 | 2.64k | { |
262 | 2.64k | std::unordered_map<NodeId, PeerInfo> ret; |
263 | 67.2k | for (const Announcement& ann : index) { Branch (263:34): [True: 67.2k, False: 2.64k]
|
264 | 67.2k | PeerInfo& info = ret[ann.m_peer]; |
265 | 67.2k | ++info.m_total; |
266 | 67.2k | info.m_requested += (ann.GetState() == State::REQUESTED); |
267 | 67.2k | info.m_completed += (ann.GetState() == State::COMPLETED); |
268 | 67.2k | } |
269 | 2.64k | return ret; |
270 | 2.64k | } |
271 | | |
272 | | /** Compute the TxHashInfo map. Only used for sanity checking. */ |
273 | | std::map<uint256, TxHashInfo> ComputeTxHashInfo(const Index& index, const PriorityComputer& computer) |
274 | 2.64k | { |
275 | 2.64k | std::map<uint256, TxHashInfo> ret; |
276 | 67.2k | for (const Announcement& ann : index) { Branch (276:34): [True: 67.2k, False: 2.64k]
|
277 | 67.2k | TxHashInfo& info = ret[ann.m_gtxid.ToUint256()]; |
278 | | // Classify how many announcements of each state we have for this txhash. |
279 | 67.2k | info.m_candidate_delayed += (ann.GetState() == State::CANDIDATE_DELAYED); |
280 | 67.2k | info.m_candidate_ready += (ann.GetState() == State::CANDIDATE_READY); |
281 | 67.2k | info.m_candidate_best += (ann.GetState() == State::CANDIDATE_BEST); |
282 | 67.2k | info.m_requested += (ann.GetState() == State::REQUESTED); |
283 | | // And track the priority of the best CANDIDATE_READY/CANDIDATE_BEST announcements. |
284 | 67.2k | if (ann.GetState() == State::CANDIDATE_BEST) { Branch (284:13): [True: 6.54k, False: 60.6k]
|
285 | 6.54k | info.m_priority_candidate_best = computer(ann); |
286 | 6.54k | } |
287 | 67.2k | if (ann.GetState() == State::CANDIDATE_READY) { Branch (287:13): [True: 7.68k, False: 59.5k]
|
288 | 7.68k | info.m_priority_best_candidate_ready = std::max(info.m_priority_best_candidate_ready, computer(ann)); |
289 | 7.68k | } |
290 | | // Also keep track of which peers this txhash has an announcement for (so we can detect duplicates). |
291 | 67.2k | info.m_peers.push_back(ann.m_peer); |
292 | 67.2k | } |
293 | 2.64k | return ret; |
294 | 2.64k | } |
295 | | |
296 | | } // namespace |
297 | | |
298 | | /** Actual implementation for TxRequestTracker's data structure. */ |
299 | | class TxRequestTracker::Impl { |
300 | | //! The current sequence number. Increases for every announcement. This is used to sort txhashes returned by |
301 | | //! GetRequestable in announcement order. |
302 | | SequenceNumber m_current_sequence{0}; |
303 | | |
304 | | //! This tracker's priority computer. |
305 | | const PriorityComputer m_computer; |
306 | | |
307 | | //! This tracker's main data structure. See SanityCheck() for the invariants that apply to it. |
308 | | Index m_index; |
309 | | |
310 | | //! Map with this tracker's per-peer statistics. |
311 | | std::unordered_map<NodeId, PeerInfo> m_peerinfo; |
312 | | |
313 | | public: |
314 | | void SanityCheck() const |
315 | 2.64k | { |
316 | | // Recompute m_peerdata from m_index. This verifies the data in it as it should just be caching statistics |
317 | | // on m_index. It also verifies the invariant that no PeerInfo announcements with m_total==0 exist. |
318 | 2.64k | assert(m_peerinfo == RecomputePeerInfo(m_index)); Branch (318:9): [True: 2.64k, False: 0]
|
319 | | |
320 | | // Calculate per-txhash statistics from m_index, and validate invariants. |
321 | 40.0k | for (auto& item : ComputeTxHashInfo(m_index, m_computer)) { Branch (321:25): [True: 40.0k, False: 2.64k]
|
322 | 40.0k | TxHashInfo& info = item.second; |
323 | | |
324 | | // Cannot have only COMPLETED peer (txhash should have been forgotten already) |
325 | 40.0k | assert(info.m_candidate_delayed + info.m_candidate_ready + info.m_candidate_best + info.m_requested > 0); Branch (325:13): [True: 40.0k, False: 0]
|
326 | | |
327 | | // Can have at most 1 CANDIDATE_BEST/REQUESTED peer |
328 | 40.0k | assert(info.m_candidate_best + info.m_requested <= 1); Branch (328:13): [True: 40.0k, False: 0]
|
329 | | |
330 | | // If there are any CANDIDATE_READY announcements, there must be exactly one CANDIDATE_BEST or REQUESTED |
331 | | // announcement. |
332 | 40.0k | if (info.m_candidate_ready > 0) { Branch (332:17): [True: 2.57k, False: 37.5k]
|
333 | 2.57k | assert(info.m_candidate_best + info.m_requested == 1); Branch (333:17): [True: 2.57k, False: 0]
|
334 | 2.57k | } |
335 | | |
336 | | // If there is both a CANDIDATE_READY and a CANDIDATE_BEST announcement, the CANDIDATE_BEST one must be |
337 | | // at least as good (equal or higher priority) as the best CANDIDATE_READY. |
338 | 40.0k | if (info.m_candidate_ready && info.m_candidate_best) { Branch (338:17): [True: 2.57k, False: 37.5k]
Branch (338:43): [True: 2.23k, False: 333]
|
339 | 2.23k | assert(info.m_priority_candidate_best >= info.m_priority_best_candidate_ready); Branch (339:17): [True: 2.23k, False: 0]
|
340 | 2.23k | } |
341 | | |
342 | | // No txhash can have been announced by the same peer twice. |
343 | 40.0k | std::sort(info.m_peers.begin(), info.m_peers.end()); |
344 | 40.0k | assert(std::adjacent_find(info.m_peers.begin(), info.m_peers.end()) == info.m_peers.end()); Branch (344:13): [True: 40.0k, False: 0]
|
345 | 40.0k | } |
346 | 2.64k | } |
347 | | |
348 | | void PostGetRequestableSanityCheck(std::chrono::microseconds now) const |
349 | 576k | { |
350 | 15.0M | for (const Announcement& ann : m_index) { Branch (350:38): [True: 15.0M, False: 576k]
|
351 | 15.0M | if (ann.IsWaiting()) { Branch (351:17): [True: 3.07M, False: 11.9M]
|
352 | | // REQUESTED and CANDIDATE_DELAYED must have a time in the future (they should have been converted |
353 | | // to COMPLETED/CANDIDATE_READY respectively). |
354 | 3.07M | assert(ann.m_time > now); Branch (354:17): [True: 3.07M, False: 0]
|
355 | 11.9M | } else if (ann.IsSelectable()) { Branch (355:24): [True: 10.3M, False: 1.57M]
|
356 | | // CANDIDATE_READY and CANDIDATE_BEST cannot have a time in the future (they should have remained |
357 | | // CANDIDATE_DELAYED, or should have been converted back to it if time went backwards). |
358 | 10.3M | assert(ann.m_time <= now); Branch (358:17): [True: 10.3M, False: 0]
|
359 | 10.3M | } |
360 | 15.0M | } |
361 | 576k | } |
362 | | |
363 | | private: |
364 | | //! Wrapper around Index::...::erase that keeps m_peerinfo up to date. |
365 | | template<typename Tag> |
366 | | Iter<Tag> Erase(Iter<Tag> it) |
367 | 1.89M | { |
368 | 1.89M | auto peerit = m_peerinfo.find(it->m_peer); |
369 | 1.89M | peerit->second.m_completed -= it->GetState() == State::COMPLETED; |
370 | 1.89M | peerit->second.m_requested -= it->GetState() == State::REQUESTED; |
371 | 1.89M | if (--peerit->second.m_total == 0) m_peerinfo.erase(peerit); Branch (371:13): [True: 326k, False: 918k]
Branch (371:13): [True: 243k, False: 410k]
|
372 | 1.89M | return m_index.get<Tag>().erase(it); |
373 | 1.89M | } txrequest.cpp:_ZN16TxRequestTracker4Impl5EraseIN12_GLOBAL__N_18ByTxHashEEEN5boost11multi_index21multi_index_containerINS2_12AnnouncementENS5_10indexed_byINS5_14ordered_uniqueINS5_3tagINS2_6ByPeerEN4mpl_2naESD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_EENS2_19ByPeerViewExtractorESD_EENS5_18ordered_non_uniqueINSA_IS3_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_EENS2_21ByTxHashViewExtractorESD_EENSH_INSA_INS2_6ByTimeESD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_EENS2_19ByTimeViewExtractorESD_EESD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_SD_EESaIS7_EE5indexIT_E4type8iteratorESW_ Line | Count | Source | 367 | 1.24M | { | 368 | 1.24M | auto peerit = m_peerinfo.find(it->m_peer); | 369 | 1.24M | peerit->second.m_completed -= it->GetState() == State::COMPLETED; | 370 | 1.24M | peerit->second.m_requested -= it->GetState() == State::REQUESTED; | 371 | 1.24M | if (--peerit->second.m_total == 0) m_peerinfo.erase(peerit); Branch (371:13): [True: 326k, False: 918k]
| 372 | 1.24M | return m_index.get<Tag>().erase(it); | 373 | 1.24M | } |
txrequest.cpp:_ZN16TxRequestTracker4Impl5EraseIN12_GLOBAL__N_16ByPeerEEEN5boost11multi_index21multi_index_containerINS2_12AnnouncementENS5_10indexed_byINS5_14ordered_uniqueINS5_3tagIS3_N4mpl_2naESC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_EENS2_19ByPeerViewExtractorESC_EENS5_18ordered_non_uniqueINSA_INS2_8ByTxHashESC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_EENS2_21ByTxHashViewExtractorESC_EENSG_INSA_INS2_6ByTimeESC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_EENS2_19ByTimeViewExtractorESC_EESC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_SC_EESaIS7_EE5indexIT_E4type8iteratorESW_ Line | Count | Source | 367 | 653k | { | 368 | 653k | auto peerit = m_peerinfo.find(it->m_peer); | 369 | 653k | peerit->second.m_completed -= it->GetState() == State::COMPLETED; | 370 | 653k | peerit->second.m_requested -= it->GetState() == State::REQUESTED; | 371 | 653k | if (--peerit->second.m_total == 0) m_peerinfo.erase(peerit); Branch (371:13): [True: 243k, False: 410k]
| 372 | 653k | return m_index.get<Tag>().erase(it); | 373 | 653k | } |
|
374 | | |
375 | | //! Wrapper around Index::...::modify that keeps m_peerinfo up to date. |
376 | | template<typename Tag, typename Modifier> |
377 | | void Modify(Iter<Tag> it, Modifier modifier) |
378 | 3.13M | { |
379 | 3.13M | auto peerit = m_peerinfo.find(it->m_peer); |
380 | 3.13M | peerit->second.m_completed -= it->GetState() == State::COMPLETED; |
381 | 3.13M | peerit->second.m_requested -= it->GetState() == State::REQUESTED; |
382 | 3.13M | m_index.get<Tag>().modify(it, std::move(modifier)); |
383 | 3.13M | peerit->second.m_completed += it->GetState() == State::COMPLETED; |
384 | 3.13M | peerit->second.m_requested += it->GetState() == State::REQUESTED; |
385 | 3.13M | } txrequest.cpp:_ZN16TxRequestTracker4Impl6ModifyIN12_GLOBAL__N_18ByTxHashEZNS0_17ChangeAndReselectEN5boost11multi_index6detail19bidir_node_iteratorINS6_18ordered_index_nodeINS6_19null_augment_policyENS8_IS9_NS6_15index_node_baseINS2_12AnnouncementESaISB_EEEEEEEEENS2_5StateEEUlRSB_E_EEvNS5_21multi_index_containerISB_NS5_10indexed_byINS5_14ordered_uniqueINS5_3tagINS2_6ByPeerEN4mpl_2naESQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_EENS2_19ByPeerViewExtractorESQ_EENS5_18ordered_non_uniqueINSN_IS3_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_EENS2_21ByTxHashViewExtractorESQ_EENSU_INSN_INS2_6ByTimeESQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_EENS2_19ByTimeViewExtractorESQ_EESQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_EESC_E5indexIT_E4type8iteratorET0_ Line | Count | Source | 378 | 198k | { | 379 | 198k | auto peerit = m_peerinfo.find(it->m_peer); | 380 | 198k | peerit->second.m_completed -= it->GetState() == State::COMPLETED; | 381 | 198k | peerit->second.m_requested -= it->GetState() == State::REQUESTED; | 382 | 198k | m_index.get<Tag>().modify(it, std::move(modifier)); | 383 | 198k | peerit->second.m_completed += it->GetState() == State::COMPLETED; | 384 | 198k | peerit->second.m_requested += it->GetState() == State::REQUESTED; | 385 | 198k | } |
txrequest.cpp:_ZN16TxRequestTracker4Impl6ModifyIN12_GLOBAL__N_18ByTxHashEZNS0_17ChangeAndReselectEN5boost11multi_index6detail19bidir_node_iteratorINS6_18ordered_index_nodeINS6_19null_augment_policyENS8_IS9_NS6_15index_node_baseINS2_12AnnouncementESaISB_EEEEEEEEENS2_5StateEEUlRSB_E0_EEvNS5_21multi_index_containerISB_NS5_10indexed_byINS5_14ordered_uniqueINS5_3tagINS2_6ByPeerEN4mpl_2naESQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_EENS2_19ByPeerViewExtractorESQ_EENS5_18ordered_non_uniqueINSN_IS3_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_EENS2_21ByTxHashViewExtractorESQ_EENSU_INSN_INS2_6ByTimeESQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_EENS2_19ByTimeViewExtractorESQ_EESQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_SQ_EESC_E5indexIT_E4type8iteratorET0_ Line | Count | Source | 378 | 847k | { | 379 | 847k | auto peerit = m_peerinfo.find(it->m_peer); | 380 | 847k | peerit->second.m_completed -= it->GetState() == State::COMPLETED; | 381 | 847k | peerit->second.m_requested -= it->GetState() == State::REQUESTED; | 382 | 847k | m_index.get<Tag>().modify(it, std::move(modifier)); | 383 | 847k | peerit->second.m_completed += it->GetState() == State::COMPLETED; | 384 | 847k | peerit->second.m_requested += it->GetState() == State::REQUESTED; | 385 | 847k | } |
txrequest.cpp:_ZN16TxRequestTracker4Impl6ModifyIN12_GLOBAL__N_18ByTxHashEZNS0_11RequestedTxElRK7uint256NSt6chrono8durationIlSt5ratioILl1ELl1000000EEEEEUlRNS2_12AnnouncementEE_EEvN5boost11multi_index21multi_index_containerISC_NSG_10indexed_byINSG_14ordered_uniqueINSG_3tagINS2_6ByPeerEN4mpl_2naESN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_EENS2_19ByPeerViewExtractorESN_EENSG_18ordered_non_uniqueINSK_IS3_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_EENS2_21ByTxHashViewExtractorESN_EENSR_INSK_INS2_6ByTimeESN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_EENS2_19ByTimeViewExtractorESN_EESN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_EESaISC_EE5indexIT_E4type8iteratorET0_ Line | Count | Source | 378 | 51.9k | { | 379 | 51.9k | auto peerit = m_peerinfo.find(it->m_peer); | 380 | 51.9k | peerit->second.m_completed -= it->GetState() == State::COMPLETED; | 381 | 51.9k | peerit->second.m_requested -= it->GetState() == State::REQUESTED; | 382 | 51.9k | m_index.get<Tag>().modify(it, std::move(modifier)); | 383 | 51.9k | peerit->second.m_completed += it->GetState() == State::COMPLETED; | 384 | 51.9k | peerit->second.m_requested += it->GetState() == State::REQUESTED; | 385 | 51.9k | } |
txrequest.cpp:_ZN16TxRequestTracker4Impl6ModifyIN12_GLOBAL__N_18ByTxHashEZNS0_11RequestedTxElRK7uint256NSt6chrono8durationIlSt5ratioILl1ELl1000000EEEEEUlRNS2_12AnnouncementEE0_EEvN5boost11multi_index21multi_index_containerISC_NSG_10indexed_byINSG_14ordered_uniqueINSG_3tagINS2_6ByPeerEN4mpl_2naESN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_EENS2_19ByPeerViewExtractorESN_EENSG_18ordered_non_uniqueINSK_IS3_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_EENS2_21ByTxHashViewExtractorESN_EENSR_INSK_INS2_6ByTimeESN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_EENS2_19ByTimeViewExtractorESN_EESN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_SN_EESaISC_EE5indexIT_E4type8iteratorET0_ Line | Count | Source | 378 | 21.6k | { | 379 | 21.6k | auto peerit = m_peerinfo.find(it->m_peer); | 380 | 21.6k | peerit->second.m_completed -= it->GetState() == State::COMPLETED; | 381 | 21.6k | peerit->second.m_requested -= it->GetState() == State::REQUESTED; | 382 | 21.6k | m_index.get<Tag>().modify(it, std::move(modifier)); | 383 | 21.6k | peerit->second.m_completed += it->GetState() == State::COMPLETED; | 384 | 21.6k | peerit->second.m_requested += it->GetState() == State::REQUESTED; | 385 | 21.6k | } |
txrequest.cpp:_ZN16TxRequestTracker4Impl6ModifyIN12_GLOBAL__N_16ByPeerEZNS0_11RequestedTxElRK7uint256NSt6chrono8durationIlSt5ratioILl1ELl1000000EEEEEUlRNS2_12AnnouncementEE1_EEvN5boost11multi_index21multi_index_containerISC_NSG_10indexed_byINSG_14ordered_uniqueINSG_3tagIS3_N4mpl_2naESM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_EENS2_19ByPeerViewExtractorESM_EENSG_18ordered_non_uniqueINSK_INS2_8ByTxHashESM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_EENS2_21ByTxHashViewExtractorESM_EENSQ_INSK_INS2_6ByTimeESM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_EENS2_19ByTimeViewExtractorESM_EESM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_SM_EESaISC_EE5indexIT_E4type8iteratorET0_ Line | Count | Source | 378 | 220k | { | 379 | 220k | auto peerit = m_peerinfo.find(it->m_peer); | 380 | 220k | peerit->second.m_completed -= it->GetState() == State::COMPLETED; | 381 | 220k | peerit->second.m_requested -= it->GetState() == State::REQUESTED; | 382 | 220k | m_index.get<Tag>().modify(it, std::move(modifier)); | 383 | 220k | peerit->second.m_completed += it->GetState() == State::COMPLETED; | 384 | 220k | peerit->second.m_requested += it->GetState() == State::REQUESTED; | 385 | 220k | } |
txrequest.cpp:_ZN16TxRequestTracker4Impl6ModifyIN12_GLOBAL__N_18ByTxHashEZNS0_21PromoteCandidateReadyEN5boost11multi_index6detail19bidir_node_iteratorINS6_18ordered_index_nodeINS6_19null_augment_policyENS8_IS9_NS6_15index_node_baseINS2_12AnnouncementESaISB_EEEEEEEEEEUlRSB_E_EEvNS5_21multi_index_containerISB_NS5_10indexed_byINS5_14ordered_uniqueINS5_3tagINS2_6ByPeerEN4mpl_2naESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_19ByPeerViewExtractorESP_EENS5_18ordered_non_uniqueINSM_IS3_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_21ByTxHashViewExtractorESP_EENST_INSM_INS2_6ByTimeESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_19ByTimeViewExtractorESP_EESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EESC_E5indexIT_E4type8iteratorET0_ Line | Count | Source | 378 | 971k | { | 379 | 971k | auto peerit = m_peerinfo.find(it->m_peer); | 380 | 971k | peerit->second.m_completed -= it->GetState() == State::COMPLETED; | 381 | 971k | peerit->second.m_requested -= it->GetState() == State::REQUESTED; | 382 | 971k | m_index.get<Tag>().modify(it, std::move(modifier)); | 383 | 971k | peerit->second.m_completed += it->GetState() == State::COMPLETED; | 384 | 971k | peerit->second.m_requested += it->GetState() == State::REQUESTED; | 385 | 971k | } |
txrequest.cpp:_ZN16TxRequestTracker4Impl6ModifyIN12_GLOBAL__N_18ByTxHashEZNS0_21PromoteCandidateReadyEN5boost11multi_index6detail19bidir_node_iteratorINS6_18ordered_index_nodeINS6_19null_augment_policyENS8_IS9_NS6_15index_node_baseINS2_12AnnouncementESaISB_EEEEEEEEEEUlRSB_E0_EEvNS5_21multi_index_containerISB_NS5_10indexed_byINS5_14ordered_uniqueINS5_3tagINS2_6ByPeerEN4mpl_2naESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_19ByPeerViewExtractorESP_EENS5_18ordered_non_uniqueINSM_IS3_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_21ByTxHashViewExtractorESP_EENST_INSM_INS2_6ByTimeESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_19ByTimeViewExtractorESP_EESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EESC_E5indexIT_E4type8iteratorET0_ Line | Count | Source | 378 | 417k | { | 379 | 417k | auto peerit = m_peerinfo.find(it->m_peer); | 380 | 417k | peerit->second.m_completed -= it->GetState() == State::COMPLETED; | 381 | 417k | peerit->second.m_requested -= it->GetState() == State::REQUESTED; | 382 | 417k | m_index.get<Tag>().modify(it, std::move(modifier)); | 383 | 417k | peerit->second.m_completed += it->GetState() == State::COMPLETED; | 384 | 417k | peerit->second.m_requested += it->GetState() == State::REQUESTED; | 385 | 417k | } |
txrequest.cpp:_ZN16TxRequestTracker4Impl6ModifyIN12_GLOBAL__N_18ByTxHashEZNS0_21PromoteCandidateReadyEN5boost11multi_index6detail19bidir_node_iteratorINS6_18ordered_index_nodeINS6_19null_augment_policyENS8_IS9_NS6_15index_node_baseINS2_12AnnouncementESaISB_EEEEEEEEEEUlRSB_E1_EEvNS5_21multi_index_containerISB_NS5_10indexed_byINS5_14ordered_uniqueINS5_3tagINS2_6ByPeerEN4mpl_2naESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_19ByPeerViewExtractorESP_EENS5_18ordered_non_uniqueINSM_IS3_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_21ByTxHashViewExtractorESP_EENST_INSM_INS2_6ByTimeESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_19ByTimeViewExtractorESP_EESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EESC_E5indexIT_E4type8iteratorET0_ Line | Count | Source | 378 | 202k | { | 379 | 202k | auto peerit = m_peerinfo.find(it->m_peer); | 380 | 202k | peerit->second.m_completed -= it->GetState() == State::COMPLETED; | 381 | 202k | peerit->second.m_requested -= it->GetState() == State::REQUESTED; | 382 | 202k | m_index.get<Tag>().modify(it, std::move(modifier)); | 383 | 202k | peerit->second.m_completed += it->GetState() == State::COMPLETED; | 384 | 202k | peerit->second.m_requested += it->GetState() == State::REQUESTED; | 385 | 202k | } |
txrequest.cpp:_ZN16TxRequestTracker4Impl6ModifyIN12_GLOBAL__N_18ByTxHashEZNS0_21PromoteCandidateReadyEN5boost11multi_index6detail19bidir_node_iteratorINS6_18ordered_index_nodeINS6_19null_augment_policyENS8_IS9_NS6_15index_node_baseINS2_12AnnouncementESaISB_EEEEEEEEEEUlRSB_E2_EEvNS5_21multi_index_containerISB_NS5_10indexed_byINS5_14ordered_uniqueINS5_3tagINS2_6ByPeerEN4mpl_2naESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_19ByPeerViewExtractorESP_EENS5_18ordered_non_uniqueINSM_IS3_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_21ByTxHashViewExtractorESP_EENST_INSM_INS2_6ByTimeESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EENS2_19ByTimeViewExtractorESP_EESP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_SP_EESC_E5indexIT_E4type8iteratorET0_ Line | Count | Source | 378 | 202k | { | 379 | 202k | auto peerit = m_peerinfo.find(it->m_peer); | 380 | 202k | peerit->second.m_completed -= it->GetState() == State::COMPLETED; | 381 | 202k | peerit->second.m_requested -= it->GetState() == State::REQUESTED; | 382 | 202k | m_index.get<Tag>().modify(it, std::move(modifier)); | 383 | 202k | peerit->second.m_completed += it->GetState() == State::COMPLETED; | 384 | 202k | peerit->second.m_requested += it->GetState() == State::REQUESTED; | 385 | 202k | } |
|
386 | | |
387 | | //! Convert a CANDIDATE_DELAYED announcement into a CANDIDATE_READY. If this makes it the new best |
388 | | //! CANDIDATE_READY (and no REQUESTED exists) and better than the CANDIDATE_BEST (if any), it becomes the new |
389 | | //! CANDIDATE_BEST. |
390 | | void PromoteCandidateReady(Iter<ByTxHash> it) |
391 | 971k | { |
392 | 971k | assert(it != m_index.get<ByTxHash>().end()); Branch (392:9): [True: 971k, False: 0]
|
393 | 971k | assert(it->GetState() == State::CANDIDATE_DELAYED); Branch (393:9): [True: 971k, False: 0]
|
394 | | // Convert CANDIDATE_DELAYED to CANDIDATE_READY first. |
395 | 971k | Modify<ByTxHash>(it, [](Announcement& ann){ ann.SetState(State::CANDIDATE_READY); }); |
396 | | // The following code relies on the fact that the ByTxHash is sorted by txhash, and then by state (first |
397 | | // _DELAYED, then _READY, then _BEST/REQUESTED). Within the _READY announcements, the best one (highest |
398 | | // priority) comes last. Thus, if an existing _BEST exists for the same txhash that this announcement may |
399 | | // be preferred over, it must immediately follow the newly created _READY. |
400 | 971k | auto it_next = std::next(it); |
401 | 971k | if (it_next == m_index.get<ByTxHash>().end() || it_next->m_gtxid.ToUint256() != it->m_gtxid.ToUint256() || Branch (401:13): [True: 42.7k, False: 929k]
Branch (401:13): [True: 417k, False: 554k]
Branch (401:57): [True: 363k, False: 565k]
|
402 | 971k | it_next->GetState() == State::COMPLETED) { Branch (402:13): [True: 11.0k, False: 554k]
|
403 | | // This is the new best CANDIDATE_READY, and there is no IsSelected() announcement for this txhash |
404 | | // already. |
405 | 417k | Modify<ByTxHash>(it, [](Announcement& ann){ ann.SetState(State::CANDIDATE_BEST); }); |
406 | 554k | } else if (it_next->GetState() == State::CANDIDATE_BEST) { Branch (406:20): [True: 396k, False: 158k]
|
407 | 396k | Priority priority_old = m_computer(*it_next); |
408 | 396k | Priority priority_new = m_computer(*it); |
409 | 396k | if (priority_new > priority_old) { Branch (409:17): [True: 202k, False: 193k]
|
410 | | // There is a CANDIDATE_BEST announcement already, but this one is better. |
411 | 202k | Modify<ByTxHash>(it_next, [](Announcement& ann){ ann.SetState(State::CANDIDATE_READY); }); |
412 | 202k | Modify<ByTxHash>(it, [](Announcement& ann){ ann.SetState(State::CANDIDATE_BEST); }); |
413 | 202k | } |
414 | 396k | } |
415 | 971k | } |
416 | | |
417 | | //! Change the state of an announcement to something non-IsSelected(). If it was IsSelected(), the next best |
418 | | //! announcement will be marked CANDIDATE_BEST. |
419 | | void ChangeAndReselect(Iter<ByTxHash> it, State new_state) |
420 | 847k | { |
421 | 847k | assert(new_state == State::COMPLETED || new_state == State::CANDIDATE_DELAYED); Branch (421:9): [True: 692k, False: 155k]
Branch (421:9): [True: 155k, False: 0]
Branch (421:9): [True: 847k, False: 0]
|
422 | 847k | assert(it != m_index.get<ByTxHash>().end()); Branch (422:9): [True: 847k, False: 0]
|
423 | 847k | if (it->IsSelected() && it != m_index.get<ByTxHash>().begin()) { Branch (423:13): [True: 311k, False: 536k]
Branch (423:13): [True: 305k, False: 542k]
Branch (423:33): [True: 305k, False: 5.54k]
|
424 | 305k | auto it_prev = std::prev(it); |
425 | | // The next best CANDIDATE_READY, if any, immediately precedes the REQUESTED or CANDIDATE_BEST |
426 | | // announcement in the ByTxHash index. |
427 | 305k | if (it_prev->m_gtxid.ToUint256() == it->m_gtxid.ToUint256() && it_prev->GetState() == State::CANDIDATE_READY) { Branch (427:17): [True: 245k, False: 59.8k]
Branch (427:76): [True: 198k, False: 47.3k]
|
428 | | // If one such CANDIDATE_READY exists (for this txhash), convert it to CANDIDATE_BEST. |
429 | 198k | Modify<ByTxHash>(it_prev, [](Announcement& ann){ ann.SetState(State::CANDIDATE_BEST); }); |
430 | 198k | } |
431 | 305k | } |
432 | 847k | Modify<ByTxHash>(it, [new_state](Announcement& ann){ ann.SetState(new_state); }); |
433 | 847k | } |
434 | | |
435 | | //! Check if 'it' is the only announcement for a given txhash that isn't COMPLETED. |
436 | | bool IsOnlyNonCompleted(Iter<ByTxHash> it) |
437 | 1.19M | { |
438 | 1.19M | assert(it != m_index.get<ByTxHash>().end()); Branch (438:9): [True: 1.19M, False: 0]
|
439 | 1.19M | assert(it->GetState() != State::COMPLETED); // Not allowed to call this on COMPLETED announcements. Branch (439:9): [True: 1.19M, False: 0]
|
440 | | |
441 | | // This announcement has a predecessor that belongs to the same txhash. Due to ordering, and the |
442 | | // fact that 'it' is not COMPLETED, its predecessor cannot be COMPLETED here. |
443 | 1.19M | if (it != m_index.get<ByTxHash>().begin() && std::prev(it)->m_gtxid.ToUint256() == it->m_gtxid.ToUint256()) return false; Branch (443:13): [True: 1.01M, False: 183k]
Branch (443:13): [True: 453k, False: 740k]
Branch (443:54): [True: 453k, False: 556k]
|
444 | | |
445 | | // This announcement has a successor that belongs to the same txhash, and is not COMPLETED. |
446 | 740k | if (std::next(it) != m_index.get<ByTxHash>().end() && std::next(it)->m_gtxid.ToUint256() == it->m_gtxid.ToUint256() && Branch (446:13): [True: 693k, False: 46.8k]
Branch (446:13): [True: 238k, False: 501k]
Branch (446:63): [True: 254k, False: 438k]
|
447 | 740k | std::next(it)->GetState() != State::COMPLETED) return false; Branch (447:13): [True: 238k, False: 16.1k]
|
448 | | |
449 | 501k | return true; |
450 | 740k | } |
451 | | |
452 | | /** Convert any announcement to a COMPLETED one. If there are no non-COMPLETED announcements left for this |
453 | | * txhash, they are deleted. If this was a REQUESTED announcement, and there are other CANDIDATEs left, the |
454 | | * best one is made CANDIDATE_BEST. Returns whether the announcement still exists. */ |
455 | | bool MakeCompleted(Iter<ByTxHash> it) |
456 | 1.30M | { |
457 | 1.30M | assert(it != m_index.get<ByTxHash>().end()); Branch (457:9): [True: 1.30M, False: 0]
|
458 | | |
459 | | // Nothing to be done if it's already COMPLETED. |
460 | 1.30M | if (it->GetState() == State::COMPLETED) return true; Branch (460:13): [True: 107k, False: 1.19M]
|
461 | | |
462 | 1.19M | if (IsOnlyNonCompleted(it)) { Branch (462:13): [True: 501k, False: 692k]
|
463 | | // This is the last non-COMPLETED announcement for this txhash. Delete all. |
464 | 501k | uint256 txhash = it->m_gtxid.ToUint256(); |
465 | 524k | do { |
466 | 524k | it = Erase<ByTxHash>(it); |
467 | 524k | } while (it != m_index.get<ByTxHash>().end() && it->m_gtxid.ToUint256() == txhash); Branch (467:22): [True: 474k, False: 49.4k]
Branch (467:22): [True: 22.6k, False: 501k]
Branch (467:61): [True: 22.6k, False: 452k]
|
468 | 501k | return false; |
469 | 501k | } |
470 | | |
471 | | // Mark the announcement COMPLETED, and select the next best announcement (the first CANDIDATE_READY) if |
472 | | // needed. |
473 | 692k | ChangeAndReselect(it, State::COMPLETED); |
474 | | |
475 | 692k | return true; |
476 | 1.19M | } |
477 | | |
478 | | //! Make the data structure consistent with a given point in time: |
479 | | //! - REQUESTED announcements with expiry <= now are turned into COMPLETED. |
480 | | //! - CANDIDATE_DELAYED announcements with reqtime <= now are turned into CANDIDATE_{READY,BEST}. |
481 | | //! - CANDIDATE_{READY,BEST} announcements with reqtime > now are turned into CANDIDATE_DELAYED. |
482 | | void SetTimePoint(std::chrono::microseconds now, std::vector<std::pair<NodeId, GenTxid>>* expired) |
483 | 2.17M | { |
484 | 2.17M | if (expired) expired->clear(); Branch (484:13): [True: 2.17M, False: 0]
|
485 | | |
486 | | // Iterate over all CANDIDATE_DELAYED and REQUESTED from old to new, as long as they're in the past, |
487 | | // and convert them to CANDIDATE_READY and COMPLETED respectively. |
488 | 3.29M | while (!m_index.empty()) { Branch (488:16): [True: 1.90M, False: 1.39M]
|
489 | 1.90M | auto it = m_index.get<ByTime>().begin(); |
490 | 1.90M | if (it->GetState() == State::CANDIDATE_DELAYED && it->m_time <= now) { Branch (490:17): [True: 1.40M, False: 503k]
Branch (490:63): [True: 971k, False: 431k]
|
491 | 971k | PromoteCandidateReady(m_index.project<ByTxHash>(it)); |
492 | 971k | } else if (it->GetState() == State::REQUESTED && it->m_time <= now) { Branch (492:24): [True: 299k, False: 635k]
Branch (492:62): [True: 155k, False: 144k]
|
493 | 155k | if (expired) expired->emplace_back(it->m_peer, it->m_gtxid); Branch (493:21): [True: 155k, False: 0]
|
494 | 155k | MakeCompleted(m_index.project<ByTxHash>(it)); |
495 | 779k | } else { |
496 | 779k | break; |
497 | 779k | } |
498 | 1.90M | } |
499 | | |
500 | 2.32M | while (!m_index.empty()) { Branch (500:16): [True: 934k, False: 1.39M]
|
501 | | // If time went backwards, we may need to demote CANDIDATE_BEST and CANDIDATE_READY announcements back |
502 | | // to CANDIDATE_DELAYED. This is an unusual edge case, and unlikely to matter in production. However, |
503 | | // it makes it much easier to specify and test TxRequestTracker::Impl's behaviour. |
504 | 934k | auto it = std::prev(m_index.get<ByTime>().end()); |
505 | 934k | if (it->IsSelectable() && it->m_time > now) { Branch (505:17): [True: 765k, False: 168k]
Branch (505:39): [True: 155k, False: 610k]
|
506 | 155k | ChangeAndReselect(m_index.project<ByTxHash>(it), State::CANDIDATE_DELAYED); |
507 | 779k | } else { |
508 | 779k | break; |
509 | 779k | } |
510 | 934k | } |
511 | 2.17M | } |
512 | | |
513 | | public: |
514 | | explicit Impl(bool deterministic) : |
515 | 26.1k | m_computer(deterministic), |
516 | | // Explicitly initialize m_index as we need to pass a reference to m_computer to ByTxHashViewExtractor. |
517 | 26.1k | m_index(boost::make_tuple( |
518 | 26.1k | boost::make_tuple(ByPeerViewExtractor(), std::less<ByPeerView>()), |
519 | 26.1k | boost::make_tuple(ByTxHashViewExtractor(m_computer), std::less<ByTxHashView>()), |
520 | 26.1k | boost::make_tuple(ByTimeViewExtractor(), std::less<ByTimeView>()) |
521 | 26.1k | )) {} |
522 | | |
523 | | // Disable copying and assigning (a default copy won't work due the stateful ByTxHashViewExtractor). |
524 | | Impl(const Impl&) = delete; |
525 | | Impl& operator=(const Impl&) = delete; |
526 | | |
527 | | void DisconnectedPeer(NodeId peer) |
528 | 731k | { |
529 | 731k | auto& index = m_index.get<ByPeer>(); |
530 | 731k | auto it = index.lower_bound(ByPeerView{peer, false, uint256::ZERO}); |
531 | 1.75M | while (it != index.end() && it->m_peer == peer) { Branch (531:16): [True: 1.26M, False: 490k]
Branch (531:16): [True: 1.02M, False: 731k]
Branch (531:37): [True: 1.02M, False: 240k]
|
532 | | // Check what to continue with after this iteration. 'it' will be deleted in what follows, so we need to |
533 | | // decide what to continue with afterwards. There are a number of cases to consider: |
534 | | // - std::next(it) is end() or belongs to a different peer. In that case, this is the last iteration |
535 | | // of the loop (denote this by setting it_next to end()). |
536 | | // - 'it' is not the only non-COMPLETED announcement for its txhash. This means it will be deleted, but |
537 | | // no other Announcement objects will be modified. Continue with std::next(it) if it belongs to the |
538 | | // same peer, but decide this ahead of time (as 'it' may change position in what follows). |
539 | | // - 'it' is the only non-COMPLETED announcement for its txhash. This means it will be deleted along |
540 | | // with all other announcements for the same txhash - which may include std::next(it). However, other |
541 | | // than 'it', no announcements for the same peer can be affected (due to (peer, txhash) uniqueness). |
542 | | // In other words, the situation where std::next(it) is deleted can only occur if std::next(it) |
543 | | // belongs to a different peer but the same txhash as 'it'. This is covered by the first bulletpoint |
544 | | // already, and we'll have set it_next to end(). |
545 | 1.02M | auto it_next = (std::next(it) == index.end() || std::next(it)->m_peer != peer) ? index.end() : Branch (545:29): [True: 32.4k, False: 992k]
Branch (545:61): [True: 355k, False: 636k]
|
546 | 1.02M | std::next(it); |
547 | | // If the announcement isn't already COMPLETED, first make it COMPLETED (which will mark other |
548 | | // CANDIDATEs as CANDIDATE_BEST, or delete all of a txhash's announcements if no non-COMPLETED ones are |
549 | | // left). |
550 | 1.02M | if (MakeCompleted(m_index.project<ByTxHash>(it))) { Branch (550:17): [True: 653k, False: 371k]
|
551 | | // Then actually delete the announcement (unless it was already deleted by MakeCompleted). |
552 | 653k | Erase<ByPeer>(it); |
553 | 653k | } |
554 | 1.02M | it = it_next; |
555 | 1.02M | } |
556 | 731k | } |
557 | | |
558 | | void ForgetTxHash(const uint256& txhash) |
559 | 1.36M | { |
560 | 1.36M | auto it = m_index.get<ByTxHash>().lower_bound(ByTxHashView{txhash, State::CANDIDATE_DELAYED, 0}); |
561 | 2.08M | while (it != m_index.get<ByTxHash>().end() && it->m_gtxid.ToUint256() == txhash) { Branch (561:16): [True: 1.71M, False: 366k]
Branch (561:16): [True: 720k, False: 1.36M]
Branch (561:55): [True: 720k, False: 997k]
|
562 | 720k | it = Erase<ByTxHash>(it); |
563 | 720k | } |
564 | 1.36M | } |
565 | | |
566 | | void GetCandidatePeers(const uint256& txhash, std::vector<NodeId>& result_peers) const |
567 | 498k | { |
568 | 498k | auto it = m_index.get<ByTxHash>().lower_bound(ByTxHashView{txhash, State::CANDIDATE_DELAYED, 0}); |
569 | 757k | while (it != m_index.get<ByTxHash>().end() && it->m_gtxid.ToUint256() == txhash && it->GetState() != State::COMPLETED) { Branch (569:16): [True: 664k, False: 93.2k]
Branch (569:16): [True: 259k, False: 498k]
Branch (569:55): [True: 279k, False: 384k]
Branch (569:92): [True: 259k, False: 20.1k]
|
570 | 259k | result_peers.push_back(it->m_peer); |
571 | 259k | ++it; |
572 | 259k | } |
573 | 498k | } |
574 | | |
575 | | void ReceivedInv(NodeId peer, const GenTxid& gtxid, bool preferred, |
576 | | std::chrono::microseconds reqtime) |
577 | 2.99M | { |
578 | | // Bail out if we already have a CANDIDATE_BEST announcement for this (txhash, peer) combination. The case |
579 | | // where there is a non-CANDIDATE_BEST announcement already will be caught by the uniqueness property of the |
580 | | // ByPeer index when we try to emplace the new object below. |
581 | 2.99M | if (m_index.get<ByPeer>().count(ByPeerView{peer, true, gtxid.ToUint256()})) return; Branch (581:13): [True: 196k, False: 2.79M]
|
582 | | |
583 | | // Try creating the announcement with CANDIDATE_DELAYED state (which will fail due to the uniqueness |
584 | | // of the ByPeer index if a non-CANDIDATE_BEST announcement already exists with the same txhash and peer). |
585 | | // Bail out in that case. |
586 | 2.79M | auto ret = m_index.get<ByPeer>().emplace(gtxid, peer, preferred, reqtime, m_current_sequence); |
587 | 2.79M | if (!ret.second) return; Branch (587:13): [True: 882k, False: 1.91M]
|
588 | | |
589 | | // Update accounting metadata. |
590 | 1.91M | ++m_peerinfo[peer].m_total; |
591 | 1.91M | ++m_current_sequence; |
592 | 1.91M | } |
593 | | |
594 | | //! Find the GenTxids to request now from peer. |
595 | | std::vector<GenTxid> GetRequestable(NodeId peer, std::chrono::microseconds now, |
596 | | std::vector<std::pair<NodeId, GenTxid>>* expired) |
597 | 2.17M | { |
598 | | // Move time. |
599 | 2.17M | SetTimePoint(now, expired); |
600 | | |
601 | | // Find all CANDIDATE_BEST announcements for this peer. |
602 | 2.17M | std::vector<const Announcement*> selected; |
603 | 2.17M | auto it_peer = m_index.get<ByPeer>().lower_bound(ByPeerView{peer, true, uint256::ZERO}); |
604 | 2.58M | while (it_peer != m_index.get<ByPeer>().end() && it_peer->m_peer == peer && Branch (604:16): [True: 888k, False: 1.70M]
Branch (604:16): [True: 419k, False: 2.17M]
Branch (604:58): [True: 419k, False: 468k]
|
605 | 2.58M | it_peer->GetState() == State::CANDIDATE_BEST) { Branch (605:13): [True: 419k, False: 0]
|
606 | 419k | selected.emplace_back(&*it_peer); |
607 | 419k | ++it_peer; |
608 | 419k | } |
609 | | |
610 | | // Sort by sequence number. |
611 | 2.17M | std::sort(selected.begin(), selected.end(), [](const Announcement* a, const Announcement* b) { |
612 | 465k | return a->m_sequence < b->m_sequence; |
613 | 465k | }); |
614 | | |
615 | | // Convert to GenTxid and return. |
616 | 2.17M | std::vector<GenTxid> ret; |
617 | 2.17M | ret.reserve(selected.size()); |
618 | 2.17M | std::transform(selected.begin(), selected.end(), std::back_inserter(ret), [](const Announcement* ann) { |
619 | 419k | return ann->m_gtxid; |
620 | 419k | }); |
621 | 2.17M | return ret; |
622 | 2.17M | } |
623 | | |
624 | | void RequestedTx(NodeId peer, const uint256& txhash, std::chrono::microseconds expiry) |
625 | 1.48M | { |
626 | 1.48M | auto it = m_index.get<ByPeer>().find(ByPeerView{peer, true, txhash}); |
627 | 1.48M | if (it == m_index.get<ByPeer>().end()) { Branch (627:13): [True: 1.40M, False: 87.2k]
|
628 | | // There is no CANDIDATE_BEST announcement, look for a _READY or _DELAYED instead. If the caller only |
629 | | // ever invokes RequestedTx with the values returned by GetRequestable, and no other non-const functions |
630 | | // other than ForgetTxHash and GetRequestable in between, this branch will never execute (as txhashes |
631 | | // returned by GetRequestable always correspond to CANDIDATE_BEST announcements). |
632 | | |
633 | 1.40M | it = m_index.get<ByPeer>().find(ByPeerView{peer, false, txhash}); |
634 | 1.40M | if (it == m_index.get<ByPeer>().end() || (it->GetState() != State::CANDIDATE_DELAYED && Branch (634:17): [True: 856k, False: 545k]
Branch (634:17): [True: 1.26M, False: 133k]
Branch (634:55): [True: 435k, False: 110k]
|
635 | 1.26M | it->GetState() != State::CANDIDATE_READY)) { Branch (635:55): [True: 412k, False: 22.6k]
|
636 | | // There is no CANDIDATE announcement tracked for this peer, so we have nothing to do. Either this |
637 | | // txhash wasn't tracked at all (and the caller should have called ReceivedInv), or it was already |
638 | | // requested and/or completed for other reasons and this is just a superfluous RequestedTx call. |
639 | 1.26M | return; |
640 | 1.26M | } |
641 | | |
642 | | // Look for an existing CANDIDATE_BEST or REQUESTED with the same txhash. We only need to do this if the |
643 | | // found announcement had a different state than CANDIDATE_BEST. If it did, invariants guarantee that no |
644 | | // other CANDIDATE_BEST or REQUESTED can exist. |
645 | 133k | auto it_old = m_index.get<ByTxHash>().lower_bound(ByTxHashView{txhash, State::CANDIDATE_BEST, 0}); |
646 | 133k | if (it_old != m_index.get<ByTxHash>().end() && it_old->m_gtxid.ToUint256() == txhash) { Branch (646:17): [True: 123k, False: 9.75k]
Branch (646:17): [True: 75.3k, False: 57.8k]
Branch (646:60): [True: 75.3k, False: 48.0k]
|
647 | 75.3k | if (it_old->GetState() == State::CANDIDATE_BEST) { Branch (647:21): [True: 51.9k, False: 23.3k]
|
648 | | // The data structure's invariants require that there can be at most one CANDIDATE_BEST or one |
649 | | // REQUESTED announcement per txhash (but not both simultaneously), so we have to convert any |
650 | | // existing CANDIDATE_BEST to another CANDIDATE_* when constructing another REQUESTED. |
651 | | // It doesn't matter whether we pick CANDIDATE_READY or _DELAYED here, as SetTimePoint() |
652 | | // will correct it at GetRequestable() time. If time only goes forward, it will always be |
653 | | // _READY, so pick that to avoid extra work in SetTimePoint(). |
654 | 51.9k | Modify<ByTxHash>(it_old, [](Announcement& ann) { ann.SetState(State::CANDIDATE_READY); }); |
655 | 51.9k | } else if (it_old->GetState() == State::REQUESTED) { Branch (655:28): [True: 21.6k, False: 1.71k]
|
656 | | // As we're no longer waiting for a response to the previous REQUESTED announcement, convert it |
657 | | // to COMPLETED. This also helps guaranteeing progress. |
658 | 21.6k | Modify<ByTxHash>(it_old, [](Announcement& ann) { ann.SetState(State::COMPLETED); }); |
659 | 21.6k | } |
660 | 75.3k | } |
661 | 133k | } |
662 | | |
663 | 220k | Modify<ByPeer>(it, [expiry](Announcement& ann) { |
664 | 220k | ann.SetState(State::REQUESTED); |
665 | 220k | ann.m_time = expiry; |
666 | 220k | }); |
667 | 220k | } |
668 | | |
669 | | void ReceivedResponse(NodeId peer, const uint256& txhash) |
670 | 1.00M | { |
671 | | // We need to search the ByPeer index for both (peer, false, txhash) and (peer, true, txhash). |
672 | 1.00M | auto it = m_index.get<ByPeer>().find(ByPeerView{peer, false, txhash}); |
673 | 1.00M | if (it == m_index.get<ByPeer>().end()) { Branch (673:13): [True: 896k, False: 105k]
|
674 | 896k | it = m_index.get<ByPeer>().find(ByPeerView{peer, true, txhash}); |
675 | 896k | } |
676 | 1.00M | if (it != m_index.get<ByPeer>().end()) MakeCompleted(m_index.project<ByTxHash>(it)); Branch (676:13): [True: 121k, False: 880k]
|
677 | 1.00M | } |
678 | | |
679 | | size_t CountInFlight(NodeId peer) const |
680 | 198k | { |
681 | 198k | auto it = m_peerinfo.find(peer); |
682 | 198k | if (it != m_peerinfo.end()) return it->second.m_requested; Branch (682:13): [True: 165k, False: 32.9k]
|
683 | 32.9k | return 0; |
684 | 198k | } |
685 | | |
686 | | size_t CountCandidates(NodeId peer) const |
687 | 10.1k | { |
688 | 10.1k | auto it = m_peerinfo.find(peer); |
689 | 10.1k | if (it != m_peerinfo.end()) return it->second.m_total - it->second.m_requested - it->second.m_completed; Branch (689:13): [True: 5.02k, False: 5.13k]
|
690 | 5.13k | return 0; |
691 | 10.1k | } |
692 | | |
693 | | size_t Count(NodeId peer) const |
694 | 388k | { |
695 | 388k | auto it = m_peerinfo.find(peer); |
696 | 388k | if (it != m_peerinfo.end()) return it->second.m_total; Branch (696:13): [True: 170k, False: 217k]
|
697 | 217k | return 0; |
698 | 388k | } |
699 | | |
700 | | //! Count how many announcements are being tracked in total across all peers and transactions. |
701 | 27.1k | size_t Size() const { return m_index.size(); } |
702 | | |
703 | | uint64_t ComputePriority(const uint256& txhash, NodeId peer, bool preferred) const |
704 | 1.62M | { |
705 | | // Return Priority as a uint64_t as Priority is internal. |
706 | 1.62M | return uint64_t{m_computer(txhash, peer, preferred)}; |
707 | 1.62M | } |
708 | | |
709 | | }; |
710 | | |
711 | | TxRequestTracker::TxRequestTracker(bool deterministic) : |
712 | 26.1k | m_impl{std::make_unique<TxRequestTracker::Impl>(deterministic)} {} |
713 | | |
714 | 26.1k | TxRequestTracker::~TxRequestTracker() = default; |
715 | | |
716 | 1.36M | void TxRequestTracker::ForgetTxHash(const uint256& txhash) { m_impl->ForgetTxHash(txhash); } |
717 | 731k | void TxRequestTracker::DisconnectedPeer(NodeId peer) { m_impl->DisconnectedPeer(peer); } |
718 | 198k | size_t TxRequestTracker::CountInFlight(NodeId peer) const { return m_impl->CountInFlight(peer); } |
719 | 10.1k | size_t TxRequestTracker::CountCandidates(NodeId peer) const { return m_impl->CountCandidates(peer); } |
720 | 388k | size_t TxRequestTracker::Count(NodeId peer) const { return m_impl->Count(peer); } |
721 | 27.1k | size_t TxRequestTracker::Size() const { return m_impl->Size(); } |
722 | 498k | void TxRequestTracker::GetCandidatePeers(const uint256& txhash, std::vector<NodeId>& result_peers) const { return m_impl->GetCandidatePeers(txhash, result_peers); } |
723 | 2.64k | void TxRequestTracker::SanityCheck() const { m_impl->SanityCheck(); } |
724 | | |
725 | | void TxRequestTracker::PostGetRequestableSanityCheck(std::chrono::microseconds now) const |
726 | 576k | { |
727 | 576k | m_impl->PostGetRequestableSanityCheck(now); |
728 | 576k | } |
729 | | |
730 | | void TxRequestTracker::ReceivedInv(NodeId peer, const GenTxid& gtxid, bool preferred, |
731 | | std::chrono::microseconds reqtime) |
732 | 2.99M | { |
733 | 2.99M | m_impl->ReceivedInv(peer, gtxid, preferred, reqtime); |
734 | 2.99M | } |
735 | | |
736 | | void TxRequestTracker::RequestedTx(NodeId peer, const uint256& txhash, std::chrono::microseconds expiry) |
737 | 1.48M | { |
738 | 1.48M | m_impl->RequestedTx(peer, txhash, expiry); |
739 | 1.48M | } |
740 | | |
741 | | void TxRequestTracker::ReceivedResponse(NodeId peer, const uint256& txhash) |
742 | 1.00M | { |
743 | 1.00M | m_impl->ReceivedResponse(peer, txhash); |
744 | 1.00M | } |
745 | | |
746 | | std::vector<GenTxid> TxRequestTracker::GetRequestable(NodeId peer, std::chrono::microseconds now, |
747 | | std::vector<std::pair<NodeId, GenTxid>>* expired) |
748 | 2.17M | { |
749 | 2.17M | return m_impl->GetRequestable(peer, now, expired); |
750 | 2.17M | } |
751 | | |
752 | | uint64_t TxRequestTracker::ComputePriority(const uint256& txhash, NodeId peer, bool preferred) const |
753 | 1.62M | { |
754 | 1.62M | return m_impl->ComputePriority(txhash, peer, preferred); |
755 | 1.62M | } |