PickTxForSend() prioritizes transactions with fewer send attempts. A
transaction that has been waiting 1 hour with 5 attempts loses to a fresh
transaction with 1 attempt. This can result in long-waiting transactions
being perpetually deprioritized.
Solution
Add an urgency factor to the priority function based on elapsed time
since the first send attempt. Urgency is placed last in the comparison
tuple so it only breaks ties between transactions with equal send history.
Changes
src/private_broadcast.h: add urgency field to Priority struct
src/private_broadcast.cpp: update DerivePriority() to track oldest
pick time and calculate urgency
src/test/private_broadcast_tests.cpp: add urgency_tie_break and
urgency_secondary_to_send_count test cases
Behavior
Scenario
Result
TxA: 5 picks, 60min waiting vs TxB: 1 pick, 0min
TxB wins
TxA: 3 picks, 30min waiting vs TxB: 3 picks, 20min
TxA wins (urgency)
TxA: 0 picks, 10min waiting vs TxB: 0 picks, 0min
TxA wins (urgency)
No behavior change for transactions with different send attempt counts.
net: deduplicate private broadcast state and snapshot
Remove the snapshot-only wrapper types and let TxBroadcastInfo serve
as both the stored private broadcast state and the snapshot returned
by GetBroadcastInfo().
This keeps the cleanup narrow, preserves the getprivatebroadcastinfo
JSON output, and does not change behavior.
As a narrow tradeoff, the m_transactions value now stores
TxBroadcastInfo, which includes tx, so CTransactionRef is present in
both the map key and value. Keeping that duplication removes the extra
wrapper type without pulling a broader structural change into this
cleanup.
232f1c1970
test: use NodeClockContext in private_broadcast_tests
Move the private_broadcast_tests mock-time handling to
NodeClockContext.
Keeping this test-only time-handling cleanup separate makes the
private broadcast state/snapshot cleanup easier to review.
9bb2e40f95
PrivateBroadcast: Factor urgency into transaction selection priority
Previously, PickTxForSend() would always prioritize transactions with
fewer send attempts, even if those transactions had been waiting much
longer than newer alternatives. This could result in long-waiting
transactions being perpetually deprioritized.
The priority function now includes an urgency factor based on elapsed
time since the first send attempt. Urgency is placed after the
existing fairness metrics (num_picked, num_confirmed) so that it only
breaks ties between transactions with equal send history. This ensures
that transactions which have been waiting significantly longer will
eventually be selected over fresh alternatives.
No behavior change for transactions with different send attempt counts.
83db560cb4
DrahtBot added the label P2P on Apr 18, 2026
DrahtBot
commented at 5:52 PM on April 18, 2026:
contributor
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--021abf342d371248e50ceaed478a90ca-->
Reviews
See the guideline for information on the review process.
A summary of reviews will appear here.
<!--5faf32d7da4f0f540f40219e4f7537a3-->
takeshikurosawaa closed this on Apr 18, 2026
takeshikurosawaa reopened this on Apr 18, 2026
takeshikurosawaa closed this on Apr 18, 2026
takeshikurosawaa deleted the branch on Apr 18, 2026
takeshikurosawaa restored the branch on Apr 18, 2026
takeshikurosawaa reopened this on Apr 18, 2026
takeshikurosawaa closed this on Apr 18, 2026
takeshikurosawaa deleted the branch on Apr 18, 2026
takeshikurosawaa restored the branch on Apr 18, 2026
takeshikurosawaa deleted the branch on Apr 18, 2026
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-04-21 09:12 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me