Skip to main content

block_on_async

Function block_on_async 

Source
pub fn block_on_async<F, T>(f: F) -> T
where F: Future<Output = T> + Send + 'static, T: Send + 'static,
Expand description

Run an async block synchronously from sync code.

Used for testnet-only initialization (funding test accounts in engine builder). Handles both multi-threaded and single-threaded tokio runtimes:

  • Multi-threaded: uses block_in_place (efficient, does not block other tasks)
  • Single-threaded: spawns a thread with new runtime (avoids deadlock)
  • No runtime: creates a temporary runtime

NOTE: This is only called when modes.testnet_mode=true. In production, the code path that uses this is skipped entirely.