Converted the Beacon API service to Futures

- Added SSZ encode for HeadResponse
 - Converted all of the /beacon/ endpoints to return BoxFut instead of ApiResult
 - Wrapped all of the '?'s in a new macro try_future!()
 - Copied the try macro to try_future, so that a boxed future can easily be returned.
 - Replaced all of the response serializations to use the new success_response
This commit is contained in:
Luke Anderson
2019-09-11 01:43:49 +10:00
parent b8667217f0
commit ebd97730d5
4 changed files with 94 additions and 89 deletions

View File

@@ -0,0 +1,13 @@
macro_rules! try_future {
($expr:expr) => {
match $expr {
core::result::Result::Ok(val) => val,
core::result::Result::Err(err) => {
return Box::new(futures::future::err(std::convert::From::from(err)))
}
}
};
($expr:expr,) => {
$crate::try_future!($expr)
};
}