Skip to content

Instantly share code, notes, and snippets.

@jkilpatr
Created August 29, 2018 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkilpatr/2e6b33b810b852f8714c7765cff79440 to your computer and use it in GitHub Desktop.
Save jkilpatr/2e6b33b810b852f8714c7765cff79440 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) => 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(());
}
},
),
Err(e) => {
warn!("Got error from full node {:?}", e);
future::ok.into()
}
}
})
});
Arbiter::spawn(res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment