The has_attachable_staging_blocks function, which appears to be unused, claims to choose from possible candidates randomly, but the implementation does not.
In comparison, several other functions in the same file have similar comments and do choose randomly, such as process_next_orphaned_staging_block, which uses SQL to make the random selection:
The
has_attachable_staging_blocks
function, which appears to be unused, claims to choose from possible candidates randomly, but the implementation does not.https://github.com/trailofbits/x-audit-blockstack-core/blob/0c6c1d9dd8e47e79643c1edea6dc95de404ed262/src/chainstate/stacks/db/blocks.rs#L2546-L2553
In comparison, several other functions in the same file have similar comments and do choose randomly, such as
process_next_orphaned_staging_block
, which uses SQL to make the random selection:https://github.com/trailofbits/x-audit-blockstack-core/blob/0c6c1d9dd8e47e79643c1edea6dc95de404ed262/src/chainstate/stacks/db/blocks.rs#L2521-L2544