Adds parity_getRawBlockByNumber, parity_submitRawBlock (#10609)
* adds parity_getRawBlockByNumber (cherry picked from commit 1b418f592a03d45997f54304ca10889a96199509) * added parity_submitRawBlock * remove space Co-Authored-By: Andronik Ordian <write@reusable.software>
This commit is contained in:
@@ -47,6 +47,8 @@ use v1::types::{
|
||||
Log, Filter,
|
||||
};
|
||||
use Host;
|
||||
use v1::helpers::errors::light_unimplemented;
|
||||
use v1::types::block_number_to_id;
|
||||
|
||||
/// Parity implementation for light client.
|
||||
pub struct ParityClient<S, OD>
|
||||
@@ -407,4 +409,16 @@ where
|
||||
fn verify_signature(&self, is_prefixed: bool, message: Bytes, r: H256, s: H256, v: U64) -> Result<RecoveredAccount> {
|
||||
verify_signature(is_prefixed, message, r, s, v, self.light_dispatch.client.signing_chain_id())
|
||||
}
|
||||
|
||||
fn get_raw_block_by_number(&self, block: BlockNumber) -> BoxFuture<Option<Bytes>> {
|
||||
Box::new(
|
||||
self.fetcher()
|
||||
.block(block_number_to_id(block))
|
||||
.map(|block| Some(Bytes::from(block.raw().to_vec())))
|
||||
)
|
||||
}
|
||||
|
||||
fn submit_raw_block(&self, _block: Bytes) -> Result<H256> {
|
||||
Err(light_unimplemented(None))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ use v1::types::{
|
||||
block_number_to_id
|
||||
};
|
||||
use Host;
|
||||
use ethcore::verification::queue::kind::blocks::Unverified;
|
||||
|
||||
/// Parity implementation.
|
||||
pub struct ParityClient<C, M, U> {
|
||||
@@ -462,4 +463,22 @@ impl<C, M, U, S> Parity for ParityClient<C, M, U> where
|
||||
fn verify_signature(&self, is_prefixed: bool, message: Bytes, r: H256, s: H256, v: U64) -> Result<RecoveredAccount> {
|
||||
verify_signature(is_prefixed, message, r, s, v, self.client.signing_chain_id())
|
||||
}
|
||||
|
||||
fn get_raw_block_by_number(&self, block_number: BlockNumber) -> BoxFuture<Option<Bytes>> {
|
||||
Box::new(futures::done(
|
||||
Ok(
|
||||
self.client
|
||||
.block(block_number_to_id(block_number))
|
||||
.map(|block| Bytes::from(block.raw().to_vec()))
|
||||
)
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
fn submit_raw_block(&self, block: Bytes) -> Result<H256> {
|
||||
let result = self.client.import_block(
|
||||
Unverified::from_rlp(block.into_vec()).map_err(errors::rlp)?
|
||||
);
|
||||
Ok(result.map_err(errors::cannot_submit_block)?)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user