Offchain-worker APIs stubs (#2615)

* WiP: HTTP Apis.

* Working on the API.

* Add docs, clean up the API.

* Expose ext_ stuff as well.

* Implement HTTP helpers for offchain sr-io.

* Remove HTTP stuff.

* Revert "Remove HTTP stuff."

This reverts commit 7cca029d6ae93c5849b50edfcc6d2c313ba3e5bf.

* HTTP apis.

* Additional offchain methods.

* Make it compile.

* Implement wasm-ext boundary of offchain methods.

* Add stubs for offchain stuff to prevent panics.

* Fix tests.

* Addres some more issues.

* Introduce typedef, use unsafe from_utf8

* Bump runtime version.

* Introduce error to distinguish deadline and io errors.

* Add local_storage_cas

* Some tests for offchain stuff.

* Address more grumbles.

* Fix tests compilation.

* Fix borked merge.

* Improve docs for expected return values from ext functions.

* Adding new sign/enrypt/decrypt APIs.
This commit is contained in:
Tomasz Drwięga
2019-05-31 09:33:44 +02:00
committed by Gavin Wood
parent 80b18c8531
commit 308ab4f269
26 changed files with 2648 additions and 120 deletions
@@ -24,7 +24,7 @@ use std::{
use futures::{IntoFuture, Future};
use parity_codec::{Encode, Decode};
use primitives::{H256, Blake2Hasher, convert_hash, NativeOrEncoded, OffchainExt};
use primitives::{offchain, H256, Blake2Hasher, convert_hash, NativeOrEncoded};
use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::{One, Block as BlockT, Header as HeaderT};
use state_machine::{
@@ -87,7 +87,7 @@ where
type Error = ClientError;
fn call<
O: OffchainExt,
O: offchain::Externalities,
>(
&self,
id: &BlockId<Block>,
@@ -111,7 +111,7 @@ where
fn contextual_call<
'a,
O: OffchainExt,
O: offchain::Externalities,
IB: Fn() -> ClientResult<()>,
EM: Fn(
Result<NativeOrEncoded<R>, Self::Error>,
@@ -154,7 +154,7 @@ where
}
fn call_at_state<
O: OffchainExt,
O: offchain::Externalities,
S: StateBackend<Blake2Hasher>,
FF: FnOnce(
Result<NativeOrEncoded<R>, Self::Error>,
@@ -230,7 +230,7 @@ impl<Block, B, Remote, Local> CallExecutor<Block, Blake2Hasher> for
type Error = ClientError;
fn call<
O: OffchainExt,
O: offchain::Externalities,
>(
&self,
id: &BlockId<Block>,
@@ -247,7 +247,7 @@ impl<Block, B, Remote, Local> CallExecutor<Block, Blake2Hasher> for
fn contextual_call<
'a,
O: OffchainExt,
O: offchain::Externalities,
IB: Fn() -> ClientResult<()>,
EM: Fn(
Result<NativeOrEncoded<R>, Self::Error>,
@@ -327,7 +327,7 @@ impl<Block, B, Remote, Local> CallExecutor<Block, Blake2Hasher> for
}
fn call_at_state<
O: OffchainExt,
O: offchain::Externalities,
S: StateBackend<Blake2Hasher>,
FF: FnOnce(
Result<NativeOrEncoded<R>, Self::Error>,