This repository has been archived by the owner on Nov 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transaction queue integration + submission RPC (#99)
* Implement transaction queue RPC. * whitespace * Support without_std env in environmental! (#110) * Make environmental crate support without_std env. * Small doc fixes. * Remove dead code.
- Loading branch information
Showing
19 changed files
with
209 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+340 Bytes
(100%)
demo/runtime/wasm/target/wasm32-unknown-unknown/release/demo_runtime.compact.wasm
Binary file not shown.
Binary file modified
BIN
+297 Bytes
(100%)
demo/runtime/wasm/target/wasm32-unknown-unknown/release/demo_runtime.wasm
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file modified
BIN
+202 Bytes
(100%)
polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.compact.wasm
Binary file not shown.
Binary file modified
BIN
+221 Bytes
(100%)
polkadot/runtime/wasm/target/wasm32-unknown-unknown/release/polkadot_runtime.wasm
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ version = "0.1.0" | |
authors = ["Parity Technologies <[email protected]>"] | ||
|
||
[dependencies] | ||
parking_lot = "0.4" | ||
error-chain = "0.11" | ||
jsonrpc-core = { git="https://github.com/paritytech/jsonrpc.git" } | ||
jsonrpc-macros = { git="https://github.com/paritytech/jsonrpc.git" } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2017 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/>. | ||
|
||
use client; | ||
use rpc; | ||
|
||
error_chain! { | ||
links { | ||
Client(client::error::Error, client::error::ErrorKind) #[doc = "Client error"]; | ||
} | ||
errors { | ||
/// Not implemented yet | ||
Unimplemented { | ||
description("not yet implemented"), | ||
display("Method Not Implemented"), | ||
} | ||
/// Invalid format | ||
InvalidFormat { | ||
description("invalid format"), | ||
display("Invalid format for the extrinsic data"), | ||
} | ||
/// Some error with the pool since the import failed. | ||
PoolError { | ||
description("pool import failed"), | ||
display("Pool import failed"), | ||
} | ||
} | ||
} | ||
|
||
impl From<Error> for rpc::Error { | ||
fn from(e: Error) -> Self { | ||
match e { | ||
Error(ErrorKind::Unimplemented, _) => rpc::Error { | ||
code: rpc::ErrorCode::ServerError(-1), | ||
message: "Not implemented yet".into(), | ||
data: None, | ||
}, | ||
_ => rpc::Error::internal_error(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2017 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/>. | ||
|
||
//! Substrate block-author/full-node API. | ||
use std::sync::Arc; | ||
use parking_lot::Mutex; | ||
use primitives::block::Extrinsic; | ||
|
||
pub mod error; | ||
|
||
#[cfg(test)] | ||
mod tests; | ||
|
||
use self::error::Result; | ||
|
||
build_rpc_trait! { | ||
/// Substrate authoring RPC API | ||
pub trait AuthorApi { | ||
/// Submit extrinsic for inclusion in block. | ||
#[rpc(name = "author_submitExtrinsic")] | ||
fn submit_extrinsic(&self, Extrinsic) -> Result<()>; | ||
} | ||
} | ||
|
||
/// Variant of the AuthorApi that doesn't need to be Sync + Send + 'static. | ||
pub trait AsyncAuthorApi: Send + 'static { | ||
/// Submit extrinsic for inclusion in block. | ||
fn submit_extrinsic(&mut self, Extrinsic) -> Result<()>; | ||
} | ||
|
||
impl<T: AsyncAuthorApi> AuthorApi for Arc<Mutex<T>> { | ||
fn submit_extrinsic(&self, xt: Extrinsic) -> Result<()> { | ||
self.as_ref().lock().submit_extrinsic(xt) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright 2017 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/>. | ||
|
||
use primitives::block; | ||
use substrate_executor as executor; | ||
use super::*; | ||
use super::error::*; | ||
|
||
#[derive(Default)] | ||
struct DummyTxPool { | ||
submitted: Vec<block::Extrinsic>, | ||
} | ||
|
||
impl AsyncAuthorApi for DummyTxPool { | ||
/// Submit extrinsic for inclusion in block. | ||
fn submit_extrinsic(&mut self, xt: Extrinsic) -> Result<()> { | ||
if self.submitted.len() < 1 { | ||
self.submitted.push(xt); | ||
Ok(()) | ||
} else { | ||
Err(ErrorKind::PoolError.into()) | ||
} | ||
} | ||
} | ||
|
||
#[test] | ||
fn submit_transaction_should_not_cause_error() { | ||
let mut p = Arc::new(Mutex::new(DummyTxPool::default())); | ||
|
||
assert_matches!( | ||
AuthorApi::submit_extrinsic(&p, block::Extrinsic(vec![])), | ||
Ok(()) | ||
); | ||
assert!( | ||
AuthorApi::submit_extrinsic(&p, block::Extrinsic(vec![])).is_err() | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters