mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-30 08:27:23 +00:00
Optimize offchain worker api by re-using http-client (#6454)
* Fix typo in offchain's docs * Use Self keyword in AsyncApi::new() * Move httpclient to be part of OffchainWorkers to optimize block import * Fix compilation errors for tests * Add wrapper struct for HyperClient * Use lazy_static share SharedClient amongst OffchainWorkers. Remove the need to raise the fd limit * Revert "Use lazy_static share SharedClient amongst OffchainWorkers. Remove the need to raise the fd limit" This reverts commit 7af97498a2383b5d7405e27823db8fd97245da41. * Add lazy_static for tests
This commit is contained in:
@@ -19,8 +19,18 @@
|
||||
use sp_core::offchain::{HttpRequestId, Timestamp, HttpRequestStatus, HttpError};
|
||||
use std::{future::Future, pin::Pin, task::Context, task::Poll};
|
||||
|
||||
/// Wrapper struct (wrapping nothing in case of http_dummy) used for keeping the hyper_rustls client running.
|
||||
#[derive(Clone)]
|
||||
pub struct SharedClient;
|
||||
|
||||
impl SharedClient {
|
||||
pub fn new() -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a pair of [`HttpApi`] and [`HttpWorker`].
|
||||
pub fn http() -> (HttpApi, HttpWorker) {
|
||||
pub fn http(_: SharedClient) -> (HttpApi, HttpWorker) {
|
||||
(HttpApi, HttpWorker)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user