mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 15:11:02 +00:00
Make substrate-offchain compile for WASM again (#3965)
* Make substrate-offchain compile for WASM again * Minor adjustments
This commit is contained in:
committed by
Tomasz Drwięga
parent
678ec6899c
commit
5de3393297
@@ -204,6 +204,7 @@ check-web-wasm:
|
|||||||
- time cargo web build -p substrate-keystore
|
- time cargo web build -p substrate-keystore
|
||||||
- time cargo web build -p substrate-executor
|
- time cargo web build -p substrate-executor
|
||||||
- time cargo web build -p substrate-network
|
- time cargo web build -p substrate-network
|
||||||
|
- time cargo web build -p substrate-offchain
|
||||||
- time cargo web build -p substrate-panic-handler
|
- time cargo web build -p substrate-panic-handler
|
||||||
- time cargo web build -p substrate-peerset
|
- time cargo web build -p substrate-peerset
|
||||||
- time cargo web build -p substrate-primitives
|
- time cargo web build -p substrate-primitives
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ fnv = "1.0.6"
|
|||||||
futures01 = { package = "futures", version = "0.1" }
|
futures01 = { package = "futures", version = "0.1" }
|
||||||
futures-preview = "0.3.0-alpha.19"
|
futures-preview = "0.3.0-alpha.19"
|
||||||
futures-timer = "0.4.0"
|
futures-timer = "0.4.0"
|
||||||
hyper = "0.12.35"
|
|
||||||
hyper-tls = "0.3.2"
|
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
threadpool = "1.7"
|
threadpool = "1.7"
|
||||||
num_cpus = "1.10"
|
num_cpus = "1.10"
|
||||||
@@ -28,6 +26,10 @@ transaction_pool = { package = "substrate-transaction-pool", path = "../../core/
|
|||||||
network = { package = "substrate-network", path = "../../core/network" }
|
network = { package = "substrate-network", path = "../../core/network" }
|
||||||
keystore = { package = "substrate-keystore", path = "../keystore" }
|
keystore = { package = "substrate-keystore", path = "../keystore" }
|
||||||
|
|
||||||
|
[target.'cfg(not(target_os = "unknown"))'.dependencies]
|
||||||
|
hyper = "0.12.35"
|
||||||
|
hyper-tls = "0.3.2"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
env_logger = "0.7.0"
|
env_logger = "0.7.0"
|
||||||
client-db = { package = "substrate-client-db", path = "../../core/client/db/", default-features = true }
|
client-db = { package = "substrate-client-db", path = "../../core/client/db/", default-features = true }
|
||||||
|
|||||||
@@ -33,7 +33,14 @@ use primitives::offchain::{
|
|||||||
use sr_primitives::{generic::BlockId, traits::{self, Extrinsic}};
|
use sr_primitives::{generic::BlockId, traits::{self, Extrinsic}};
|
||||||
use transaction_pool::txpool::{Pool, ChainApi};
|
use transaction_pool::txpool::{Pool, ChainApi};
|
||||||
|
|
||||||
|
#[cfg(not(target_os = "unknown"))]
|
||||||
mod http;
|
mod http;
|
||||||
|
|
||||||
|
#[cfg(target_os = "unknown")]
|
||||||
|
use http_dummy as http;
|
||||||
|
#[cfg(target_os = "unknown")]
|
||||||
|
mod http_dummy;
|
||||||
|
|
||||||
mod timestamp;
|
mod timestamp;
|
||||||
|
|
||||||
/// A message between the offchain extension and the processing thread.
|
/// A message between the offchain extension and the processing thread.
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
// Copyright 2019 Parity Technologies (UK) Ltd.
|
||||||
|
// This file is part of Substrate.
|
||||||
|
|
||||||
|
// Substrate is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
|
||||||
|
// Substrate is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
//! Contains the same API as the `http` module, except that everything returns an error.
|
||||||
|
|
||||||
|
use primitives::offchain::{HttpRequestId, Timestamp, HttpRequestStatus, HttpError};
|
||||||
|
use std::{future::Future, pin::Pin, task::Context, task::Poll};
|
||||||
|
|
||||||
|
/// Creates a pair of [`HttpApi`] and [`HttpWorker`].
|
||||||
|
pub fn http() -> (HttpApi, HttpWorker) {
|
||||||
|
(HttpApi, HttpWorker)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Dummy implementation of HTTP capabilities.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct HttpApi;
|
||||||
|
|
||||||
|
/// Dummy implementation of HTTP capabilities.
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct HttpWorker;
|
||||||
|
|
||||||
|
impl HttpApi {
|
||||||
|
/// Mimicks the corresponding method in the offchain API.
|
||||||
|
pub fn request_start(
|
||||||
|
&mut self,
|
||||||
|
_: &str,
|
||||||
|
_: &str
|
||||||
|
) -> Result<HttpRequestId, ()> {
|
||||||
|
/// Because this always returns an error, none of the other methods should ever be called.
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Mimicks the corresponding method in the offchain API.
|
||||||
|
pub fn request_add_header(
|
||||||
|
&mut self,
|
||||||
|
_: HttpRequestId,
|
||||||
|
_: &str,
|
||||||
|
_: &str
|
||||||
|
) -> Result<(), ()> {
|
||||||
|
unreachable!("Creating a request always fails, thus this function will \
|
||||||
|
never be called; qed")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Mimicks the corresponding method in the offchain API.
|
||||||
|
pub fn request_write_body(
|
||||||
|
&mut self,
|
||||||
|
_: HttpRequestId,
|
||||||
|
_: &[u8],
|
||||||
|
_: Option<Timestamp>
|
||||||
|
) -> Result<(), HttpError> {
|
||||||
|
unreachable!("Creating a request always fails, thus this function will \
|
||||||
|
never be called; qed")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Mimicks the corresponding method in the offchain API.
|
||||||
|
pub fn response_wait(
|
||||||
|
&mut self,
|
||||||
|
requests: &[HttpRequestId],
|
||||||
|
_: Option<Timestamp>
|
||||||
|
) -> Vec<HttpRequestStatus> {
|
||||||
|
if requests.is_empty() {
|
||||||
|
Vec::new()
|
||||||
|
} else {
|
||||||
|
unreachable!("Creating a request always fails, thus the list of requests should \
|
||||||
|
always be empty; qed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Mimicks the corresponding method in the offchain API.
|
||||||
|
pub fn response_headers(
|
||||||
|
&mut self,
|
||||||
|
_: HttpRequestId
|
||||||
|
) -> Vec<(Vec<u8>, Vec<u8>)> {
|
||||||
|
unreachable!("Creating a request always fails, thus this function will \
|
||||||
|
never be called; qed")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Mimicks the corresponding method in the offchain API.
|
||||||
|
pub fn response_read_body(
|
||||||
|
&mut self,
|
||||||
|
_: HttpRequestId,
|
||||||
|
_: &mut [u8],
|
||||||
|
_: Option<Timestamp>
|
||||||
|
) -> Result<usize, HttpError> {
|
||||||
|
unreachable!("Creating a request always fails, thus this function will \
|
||||||
|
never be called; qed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Future for HttpWorker {
|
||||||
|
type Output = ();
|
||||||
|
|
||||||
|
fn poll(self: Pin<&mut Self>, _: &mut Context) -> Poll<Self::Output> {
|
||||||
|
Poll::Ready(())
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user