diff --git a/beacon_node/execution_layer/src/lib.rs b/beacon_node/execution_layer/src/lib.rs index 4a1a834525..5168fce211 100644 --- a/beacon_node/execution_layer/src/lib.rs +++ b/beacon_node/execution_layer/src/lib.rs @@ -2,9 +2,10 @@ use engine_api::{Error as ApiError, *}; use engines::{Engine, EngineError, Engines}; use sensitive_url::SensitiveUrl; use slog::{crit, Logger}; +use std::future::Future; use task_executor::TaskExecutor; -pub use engine_api::http::HttpJsonRpc; +pub use engine_api::{http::HttpJsonRpc, ConsensusStatus, ExecutePayloadResponse}; mod engine_api; mod engines; @@ -15,6 +16,7 @@ pub enum Error { ApiError(ApiError), EngineErrors(Vec), NotSynced, + ShuttingDown, } impl From for Error { @@ -57,6 +59,20 @@ impl ExecutionLayer { } impl ExecutionLayer { + /// Convenience function to allow calling async functions in a non-async context. + pub fn block_on<'a, T, U, V>(&'a self, future: T) -> Result + where + T: Fn(&'a Self) -> U, + U: Future>, + { + let runtime = self + .executor + .runtime() + .upgrade() + .ok_or(Error::ShuttingDown)?; + runtime.block_on(future(self)) + } + pub async fn prepare_payload( &self, parent_hash: Hash256,