async fn orchestrate_bulk_replace(
order_sender: &Sender<UnifiedEngineRequest>,
validated: Vec<Result<ValidatedReplace, BulkOrderResult>>,
cancel_phase_deadline: Duration,
create_phase_deadline: Duration,
trading_halt: Option<&Arc<RwLock<TradingHaltState>>>,
) -> Vec<BulkOrderResult>Expand description
Drive the cancel-all-then-create-all dispatch against a provided engine request sender.
-
cancel_phase_deadline/create_phase_deadline: single budget for all legs in each phase, measured from when that phase starts reading responses. A 50-leg bulk with one hung cancel is bounded by at mostcancel_phase_deadline + create_phase_deadline, notN × per_leg_timeout. -
trading_halt: optional reference to the global halt state. When provided, a fresh snapshot is read after phase 1 completes (not before it starts) so halts that fire while cancels are in flight are caught before any create is dispatched. Tests that don’t exercise halts can passNone. -
Phase 2 dispatches a create only after observing a
Canceledresponse for that leg. The phase-1 cancel carries the signed nonce and the phase-2 create is engine-internal, so a timeout/closed response channel is treated as an unknown nonce-consumption outcome and does not get a create.