68 std::vector<CTransactionRef> tiny_txs;
69 tiny_txs.reserve(NUM_TINY_TRANSACTIONS);
70 for (
unsigned int i{0}; i < NUM_TINY_TRANSACTIONS; ++i) {
82 int64_t total_weight_to_add{0};
84 const auto& tx{tiny_txs.at(
txindex)};
86 total_weight_to_add += GetTransactionWeight(*tx);
87 if (total_weight_to_add > orphanage->MaxGlobalUsage())
break;
89 assert(orphanage->AddTx(tx, peer));
97 assert(orphanage->TotalOrphanUsage() <= orphanage->MaxGlobalUsage());
98 assert(orphanage->TotalLatencyScore() <= orphanage->MaxGlobalLatencyScore());
103 const auto num_announcements_before_trim{orphanage->CountAnnouncements()};
104 assert(orphanage->AddTx(large_tx, peer));
107 const auto num_announcements_after_trim{orphanage->CountAnnouncements()};
108 const auto num_evicted{num_announcements_before_trim - num_announcements_after_trim};
118 static constexpr unsigned int NUM_PEERS{39};
124 static_assert(LARGE_TX_WEIGHT >=
TINY_TX_WEIGHT * 2,
"Tx is too small, increase NUM_PEERS");
130 std::vector<CTransactionRef> shared_txs;
131 shared_txs.reserve(NUM_UNIQUE_TXNS);
132 for (
unsigned int i{0}; i < NUM_UNIQUE_TXNS; ++i) {
135 std::vector<size_t> indexes;
136 indexes.resize(NUM_UNIQUE_TXNS);
137 std::iota(indexes.begin(), indexes.end(), 0);
143 static_assert(NUM_UNIQUE_TXNS <= NUM_PEERS * 2);
146 for (
unsigned int i{0}; i < NUM_UNIQUE_TXNS; ++i) {
147 for (
NodeId peer{0}; peer < NUM_PEERS; ++peer) {
149 CTransactionRef reserved_second_to_last_tx{peer < NUM_UNIQUE_TXNS - NUM_PEERS ? shared_txs.at(peer + NUM_PEERS) :
nullptr};
151 const auto& tx{shared_txs.at(indexes.at(i))};
152 if (tx == reserved_last_tx) {
154 }
else if (reserved_second_to_last_tx && tx == reserved_second_to_last_tx) {
157 orphanage->AddTx(tx, peer);
163 for (
NodeId peer{0}; peer < NUM_PEERS; ++peer) {
165 CTransactionRef reserved_second_to_last_tx{peer < NUM_UNIQUE_TXNS - NUM_PEERS ? shared_txs.at(peer + NUM_PEERS) :
nullptr};
167 if (reserved_second_to_last_tx) {
168 orphanage->AddTx(reserved_second_to_last_tx, peer);
170 orphanage->AddTx(reserved_last_tx, peer);
173 assert(orphanage->CountAnnouncements() == NUM_PEERS * NUM_UNIQUE_TXNS);
174 const auto total_usage{orphanage->TotalOrphanUsage()};
175 const auto max_usage{orphanage->MaxGlobalUsage()};
176 assert(max_usage - total_usage <= LARGE_TX_WEIGHT);
177 assert(orphanage->TotalLatencyScore() <= orphanage->MaxGlobalLatencyScore());
182 const auto num_announcements_before_trim{orphanage->CountAnnouncements()};
184 assert(orphanage->AddTx(last_tx, 0));
187 const auto num_evicted{num_announcements_before_trim - orphanage->CountAnnouncements() + 1};
190 assert(num_evicted >= (NUM_UNIQUE_TXNS - 2) * NUM_PEERS);
203 block.
vtx.push_back(block_tx);
206 constexpr unsigned int INPUTS_PER_TX{9};
207 constexpr unsigned int NUM_PEERS{125};
211 constexpr unsigned int INPUTS_PER_PEER = NUM_BLOCK_INPUTS / NUM_PEERS;
212 static_assert(INPUTS_PER_PEER > 0);
215 static_assert(7 * NUM_TXNS_PER_PEER + INPUTS_PER_TX - 1 >= INPUTS_PER_PEER);
217 for (
NodeId peer{0}; peer < NUM_PEERS; ++peer) {
221 const unsigned int start_input = peer * INPUTS_PER_PEER + txnum * 7;
228 assert(!orphanage->HaveTx(ptx->GetWitnessHash()));
229 assert(orphanage->AddTx(ptx, peer));
231 weight_left_for_peer -= GetTransactionWeight(*ptx);
237 assert(orphanage->TotalLatencyScore() <= orphanage->MaxGlobalLatencyScore());
238 assert(orphanage->TotalOrphanUsage() <= orphanage->MaxGlobalUsage());
242 assert(orphanage->CountAnnouncements() == NUM_PEERS * NUM_TXNS_PER_PEER);
243 assert(orphanage->TotalLatencyScore() == orphanage->CountAnnouncements());
246 if (block_or_disconnect) {
249 orphanage->EraseForBlock(block);
250 assert(orphanage->CountAnnouncements() == 0);
253 for (
NodeId peer{0}; peer < NUM_PEERS; ++peer) {
254 orphanage->EraseForPeer(peer);
256 assert(orphanage->CountAnnouncements() == 0);