Skip to content

Instantly share code, notes, and snippets.

@jkilpatr
Created August 29, 2018 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jkilpatr/7851905d615e10b6401d8c2b9c12ccab to your computer and use it in GitHub Desktop.
Save jkilpatr/7851905d615e10b6401d8c2b9c12ccab to your computer and use it in GitHub Desktop.
let res = stream.then(move |stream| {
let stream = stream.expect("Error attaching to full node socket");
client::post(&endpoint)
.timeout(Duration::from_secs(8))
.with_connection(Connection::from_stream(stream))
.json(func_call)
.unwrap()
.send()
.then(move |response| {
trace!("Got response {:?}", response);
match response {
Ok(res) => Box::new(res.json().then(
move |val: Result<Web3Response, JsonPayloadError>| match val {
Ok(val) => {
DAOManager::from_registry().do_send(CacheCallback {
id: target,
dao_address: dao_address.clone(),
response: val,
});
Ok(())
}
Err(e) => {
trace!("Got bad Web3Response {:?}", e);
return Ok(());
}
},
))
as Box<Future<Item = (), Error = JsonPayloadError>>,
Err(e) => {
warn!("Got error from full node {:?}", e);
Box::new(ok(()))
}
}
})
});
Arbiter::spawn(res);
info: component 'rust-std' for target 'armv7-unknown-linux-musleabihf' is up to date
Compiling rita v0.1.5 (file:///home/justin/repos/althea_rs/rita)
error[E0271]: type mismatch resolving `<futures::Then<tokio::net::ConnectFuture, futures::Then<actix_web::client::SendRequest, std::boxed::Box<futures::Future<Error=actix_web::error::JsonPayloadError, Item=()>>, [closure@rita/src/rita_common/dao_manager/mod.rs:263:19: 288:14 target:_, dao_address:_]>, [closure@rita/src/rita_common/dao_manager/mod.rs:255:27: 289:6 endpoint:_, func_call:_, target:_, dao_address:_]> as futures::Future>::Error == ()`
--> rita/src/rita_common/dao_manager/mod.rs:290:5
|
290 | Arbiter::spawn(res);
| ^^^^^^^^^^^^^^ expected enum `actix_web::error::JsonPayloadError`, found ()
|
= note: expected type `actix_web::error::JsonPayloadError`
found type `()`
= note: required by `actix::Arbiter::spawn`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment