Refactor price_info (#6003)
* refactor PriceInfo to use Fetch and reuse the client * forget Fetch future to keep it running in the background * update Debug message for price_info::Client * wrap underlying errors in price_info client * use debug_struct in price_info client debug implementation * use global fetch service in price_info client * rename gas_pricer parameter in RunCmd * move price_info to its own crate * fix price_info tests * replace rustc_serialize with serde_json in price_info * add documentation for price_info * remove unused rustc-serialize dependency from ethcore * fix price_info formatting * re-export fetch crate in price_info * remove unused cfg attributes in price_info * add tests for price_info
This commit is contained in:
@@ -61,6 +61,14 @@ pub trait Fetch: Clone + Send + Sync + 'static {
|
||||
f.boxed()
|
||||
}
|
||||
|
||||
/// Spawn the future in context of this `Fetch` thread pool as "fire and forget", i.e. dropping this future without
|
||||
/// canceling the underlying future.
|
||||
/// Implementation is optional.
|
||||
fn forget<F, I, E>(&self, _: F) where
|
||||
F: Future<Item=I, Error=E> + Send + 'static,
|
||||
I: Send + 'static,
|
||||
E: Send + 'static {}
|
||||
|
||||
/// Fetch URL and get a future for the result.
|
||||
/// Supports aborting the request in the middle of execution.
|
||||
fn fetch_with_abort(&self, url: &str, abort: Abort) -> Self::Result;
|
||||
@@ -149,6 +157,14 @@ impl Fetch for Client {
|
||||
self.pool.spawn(f).boxed()
|
||||
}
|
||||
|
||||
fn forget<F, I, E>(&self, f: F) where
|
||||
F: Future<Item=I, Error=E> + Send + 'static,
|
||||
I: Send + 'static,
|
||||
E: Send + 'static,
|
||||
{
|
||||
self.pool.spawn(f).forget()
|
||||
}
|
||||
|
||||
fn fetch_with_abort(&self, url: &str, abort: Abort) -> Self::Result {
|
||||
debug!(target: "fetch", "Fetching from: {:?}", url);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user