63 std::vector<CTransactionRef> tiny_txs;
64 tiny_txs.reserve(NUM_TINY_TRANSACTIONS);
65 for (
unsigned int i{0}; i < NUM_TINY_TRANSACTIONS; ++i) {
77 int64_t total_weight_to_add{0};
78 for (
unsigned int txindex{0}; txindex < NUM_TINY_TRANSACTIONS; ++txindex) {
79 const auto& tx{tiny_txs.at(txindex)};
82 if (total_weight_to_add > orphanage->MaxGlobalUsage())
break;
84 assert(orphanage->AddTx(tx, peer));
87 assert(txindex < NUM_TINY_TRANSACTIONS - 1);
92 assert(orphanage->TotalOrphanUsage() <= orphanage->MaxGlobalUsage());
93 assert(orphanage->TotalLatencyScore() <= orphanage->MaxGlobalLatencyScore());
98 const auto num_announcements_before_trim{orphanage->CountAnnouncements()};
99 assert(orphanage->AddTx(large_tx, peer));
102 const auto num_announcements_after_trim{orphanage->CountAnnouncements()};
103 const auto num_evicted{num_announcements_before_trim - num_announcements_after_trim};
113 static constexpr unsigned int NUM_PEERS{39};
119 static_assert(LARGE_TX_WEIGHT >=
TINY_TX_WEIGHT * 2,
"Tx is too small, increase NUM_PEERS");
125 std::vector<CTransactionRef> shared_txs;
126 shared_txs.reserve(NUM_UNIQUE_TXNS);
127 for (
unsigned int i{0}; i < NUM_UNIQUE_TXNS; ++i) {
130 std::vector<size_t> indexes;
131 indexes.resize(NUM_UNIQUE_TXNS);
132 std::iota(indexes.begin(), indexes.end(), 0);
138 static_assert(NUM_UNIQUE_TXNS <= NUM_PEERS * 2);
141 for (
unsigned int i{0}; i < NUM_UNIQUE_TXNS; ++i) {
142 for (
NodeId peer{0}; peer < NUM_PEERS; ++peer) {
144 CTransactionRef reserved_second_to_last_tx{peer < NUM_UNIQUE_TXNS - NUM_PEERS ? shared_txs.at(peer + NUM_PEERS) :
nullptr};
146 const auto& tx{shared_txs.at(indexes.at(i))};
147 if (tx == reserved_last_tx) {
149 }
else if (reserved_second_to_last_tx && tx == reserved_second_to_last_tx) {
152 orphanage->AddTx(tx, peer);
158 for (
NodeId peer{0}; peer < NUM_PEERS; ++peer) {
160 CTransactionRef reserved_second_to_last_tx{peer < NUM_UNIQUE_TXNS - NUM_PEERS ? shared_txs.at(peer + NUM_PEERS) :
nullptr};
162 if (reserved_second_to_last_tx) {
163 orphanage->AddTx(reserved_second_to_last_tx, peer);
165 orphanage->AddTx(reserved_last_tx, peer);
168 assert(orphanage->CountAnnouncements() == NUM_PEERS * NUM_UNIQUE_TXNS);
169 const auto total_usage{orphanage->TotalOrphanUsage()};
170 const auto max_usage{orphanage->MaxGlobalUsage()};
171 assert(max_usage - total_usage <= LARGE_TX_WEIGHT);
172 assert(orphanage->TotalLatencyScore() <= orphanage->MaxGlobalLatencyScore());
177 const auto num_announcements_before_trim{orphanage->CountAnnouncements()};
179 assert(orphanage->AddTx(last_tx, 0));
182 const auto num_evicted{num_announcements_before_trim - orphanage->CountAnnouncements() + 1};
185 assert(num_evicted >= (NUM_UNIQUE_TXNS - 2) * NUM_PEERS);
198 block.
vtx.push_back(block_tx);
201 constexpr unsigned int INPUTS_PER_TX{9};
202 constexpr unsigned int NUM_PEERS{125};
206 constexpr unsigned int INPUTS_PER_PEER = NUM_BLOCK_INPUTS / NUM_PEERS;
207 static_assert(INPUTS_PER_PEER > 0);
210 static_assert(7 * NUM_TXNS_PER_PEER + INPUTS_PER_TX - 1 >= INPUTS_PER_PEER);
212 for (
NodeId peer{0}; peer < NUM_PEERS; ++peer) {
216 const unsigned int start_input = peer * INPUTS_PER_PEER + txnum * 7;
223 assert(!orphanage->HaveTx(ptx->GetWitnessHash()));
224 assert(orphanage->AddTx(ptx, peer));
232 assert(orphanage->TotalLatencyScore() <= orphanage->MaxGlobalLatencyScore());
233 assert(orphanage->TotalOrphanUsage() <= orphanage->MaxGlobalUsage());
237 assert(orphanage->CountAnnouncements() == NUM_PEERS * NUM_TXNS_PER_PEER);
238 assert(orphanage->TotalLatencyScore() == orphanage->CountAnnouncements());
241 if (block_or_disconnect) {
244 orphanage->EraseForBlock(block);
245 assert(orphanage->CountAnnouncements() == 0);
248 for (
NodeId peer{0}; peer < NUM_PEERS; ++peer) {
249 orphanage->EraseForPeer(peer);
251 assert(orphanage->CountAnnouncements() == 0);