fix indentation
This commit is contained in:
parent
fd4d7c4b68
commit
9358f81ac1
@ -44,13 +44,13 @@ pub mod provider;
|
|||||||
|
|
||||||
#[cfg(feature = "ipc")]
|
#[cfg(feature = "ipc")]
|
||||||
pub mod provider {
|
pub mod provider {
|
||||||
#![allow(dead_code, unused_assignments, unused_variables, missing_docs)] // codegen issues
|
#![allow(dead_code, unused_assignments, unused_variables, missing_docs)] // codegen issues
|
||||||
include!(concat!(env!("OUT_DIR"), "/provider.rs"));
|
include!(concat!(env!("OUT_DIR"), "/provider.rs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "ipc")]
|
#[cfg(feature = "ipc")]
|
||||||
pub mod remote {
|
pub mod remote {
|
||||||
pub use provider::LightProviderClient;
|
pub use provider::LightProviderClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod types;
|
mod types;
|
||||||
|
@ -58,33 +58,33 @@ pub enum Request {
|
|||||||
/// A request argument.
|
/// A request argument.
|
||||||
pub trait RequestArg {
|
pub trait RequestArg {
|
||||||
/// the response type.
|
/// the response type.
|
||||||
type Out;
|
type Out;
|
||||||
|
|
||||||
/// Create the request type.
|
/// Create the request type.
|
||||||
/// `extract` must not fail when presented with the corresponding
|
/// `extract` must not fail when presented with the corresponding
|
||||||
/// `Response`.
|
/// `Response`.
|
||||||
fn make(self) -> Request;
|
fn make(self) -> Request;
|
||||||
|
|
||||||
/// May not panic if the response corresponds with the request
|
/// May not panic if the response corresponds with the request
|
||||||
/// from `make`.
|
/// from `make`.
|
||||||
/// Is free to panic otherwise.
|
/// Is free to panic otherwise.
|
||||||
fn extract(r: Response) -> Self::Out;
|
fn extract(r: Response) -> Self::Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An adapter can be thought of as a grouping of request argument types.
|
/// An adapter can be thought of as a grouping of request argument types.
|
||||||
/// This is implemented for various tuples and convenient types.
|
/// This is implemented for various tuples and convenient types.
|
||||||
pub trait RequestAdapter {
|
pub trait RequestAdapter {
|
||||||
/// The output type.
|
/// The output type.
|
||||||
type Out;
|
type Out;
|
||||||
|
|
||||||
/// Infallibly produce requests. When `extract_from` is presented
|
/// Infallibly produce requests. When `extract_from` is presented
|
||||||
/// with the corresponding response vector, it may not fail.
|
/// with the corresponding response vector, it may not fail.
|
||||||
fn make_requests(self) -> Vec<Request>;
|
fn make_requests(self) -> Vec<Request>;
|
||||||
|
|
||||||
/// Extract the output type from the given responses.
|
/// Extract the output type from the given responses.
|
||||||
/// If they are the corresponding responses to the requests
|
/// If they are the corresponding responses to the requests
|
||||||
/// made by `make_requests`, do not panic.
|
/// made by `make_requests`, do not panic.
|
||||||
fn extract_from(Vec<Response>) -> Self::Out;
|
fn extract_from(Vec<Response>) -> Self::Out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper to implement `RequestArg` and `From` for a single request kind.
|
// helper to implement `RequestArg` and `From` for a single request kind.
|
||||||
@ -123,54 +123,54 @@ impl_single!(Code, Code, Bytes);
|
|||||||
impl_single!(Execution, TransactionProof, super::ExecutionResult);
|
impl_single!(Execution, TransactionProof, super::ExecutionResult);
|
||||||
|
|
||||||
macro_rules! impl_args {
|
macro_rules! impl_args {
|
||||||
() => {
|
() => {
|
||||||
impl<T: RequestArg> RequestAdapter for T {
|
impl<T: RequestArg> RequestAdapter for T {
|
||||||
type Out = T::Out;
|
type Out = T::Out;
|
||||||
|
|
||||||
fn make_requests(self) -> Vec<Request> {
|
fn make_requests(self) -> Vec<Request> {
|
||||||
vec![self.make()]
|
vec![self.make()]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_from(mut responses: Vec<Response>) -> Self::Out {
|
fn extract_from(mut responses: Vec<Response>) -> Self::Out {
|
||||||
T::extract(responses.pop().expect(SUPPLIED_MATCHES))
|
T::extract(responses.pop().expect(SUPPLIED_MATCHES))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($first: ident, $($next: ident,)*) => {
|
($first: ident, $($next: ident,)*) => {
|
||||||
impl<
|
impl<
|
||||||
$first: RequestArg,
|
$first: RequestArg,
|
||||||
$($next: RequestArg,)*
|
$($next: RequestArg,)*
|
||||||
>
|
>
|
||||||
RequestAdapter for ($first, $($next,)*) {
|
RequestAdapter for ($first, $($next,)*) {
|
||||||
type Out = ($first::Out, $($next::Out,)*);
|
type Out = ($first::Out, $($next::Out,)*);
|
||||||
|
|
||||||
fn make_requests(self) -> Vec<Request> {
|
fn make_requests(self) -> Vec<Request> {
|
||||||
let ($first, $($next,)*) = self;
|
let ($first, $($next,)*) = self;
|
||||||
|
|
||||||
vec![
|
vec![
|
||||||
$first.make(),
|
$first.make(),
|
||||||
$($next.make(),)*
|
$($next.make(),)*
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extract_from(responses: Vec<Response>) -> Self::Out {
|
fn extract_from(responses: Vec<Response>) -> Self::Out {
|
||||||
let mut iter = responses.into_iter();
|
let mut iter = responses.into_iter();
|
||||||
(
|
(
|
||||||
$first::extract(iter.next().expect(SUPPLIED_MATCHES)),
|
$first::extract(iter.next().expect(SUPPLIED_MATCHES)),
|
||||||
$($next::extract(iter.next().expect(SUPPLIED_MATCHES)),)*
|
$($next::extract(iter.next().expect(SUPPLIED_MATCHES)),)*
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl_args!($($next,)*);
|
impl_args!($($next,)*);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod impls {
|
mod impls {
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use super::{RequestAdapter, RequestArg, Request, Response, SUPPLIED_MATCHES};
|
use super::{RequestAdapter, RequestArg, Request, Response, SUPPLIED_MATCHES};
|
||||||
|
|
||||||
impl_args!(A, B, C, D, E, F, G, H, I, J, K, L,);
|
impl_args!(A, B, C, D, E, F, G, H, I, J, K, L,);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Requests coupled with their required data for verification.
|
/// Requests coupled with their required data for verification.
|
||||||
|
@ -131,7 +131,7 @@ impl TransactionQueue {
|
|||||||
|
|
||||||
if self.by_hash.contains_key(&hash) { return Err(TransactionError::AlreadyImported) }
|
if self.by_hash.contains_key(&hash) { return Err(TransactionError::AlreadyImported) }
|
||||||
|
|
||||||
let res = match self.by_account.entry(sender) {
|
let res = match self.by_account.entry(sender) {
|
||||||
Entry::Vacant(entry) => {
|
Entry::Vacant(entry) => {
|
||||||
entry.insert(AccountTransactions {
|
entry.insert(AccountTransactions {
|
||||||
cur_nonce: CurrentNonce::Assumed(nonce),
|
cur_nonce: CurrentNonce::Assumed(nonce),
|
||||||
|
Loading…
Reference in New Issue
Block a user