mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +00:00
BlockId removal: refactor: ProofProvider (#12519)
* BlockId removal: refactor: ProofProvider It changes the arguments of methods of `ProofProvider` trait from: block: `BlockId<Block>` to: hash: `&Block::Hash` This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292) * LightClientRequestHandler: excessive BlockIdTo bound removed * imports cleanup * formatting * args tyeps cleanup
This commit is contained in:
committed by
GitHub
parent
e3b269ab0f
commit
1d5aa47bee
@@ -38,7 +38,7 @@ use sp_core::{
|
||||
hexdisplay::HexDisplay,
|
||||
storage::{ChildInfo, ChildType, PrefixedStorageKey},
|
||||
};
|
||||
use sp_runtime::{generic::BlockId, traits::Block};
|
||||
use sp_runtime::traits::Block;
|
||||
use std::{marker::PhantomData, sync::Arc};
|
||||
|
||||
const LOG_TARGET: &str = "light-client-request-handler";
|
||||
@@ -172,26 +172,22 @@ where
|
||||
|
||||
let block = Decode::decode(&mut request.block.as_ref())?;
|
||||
|
||||
let response =
|
||||
match self
|
||||
.client
|
||||
.execution_proof(&BlockId::Hash(block), &request.method, &request.data)
|
||||
{
|
||||
Ok((_, proof)) => {
|
||||
let r = schema::v1::light::RemoteCallResponse { proof: proof.encode() };
|
||||
Some(schema::v1::light::response::Response::RemoteCallResponse(r))
|
||||
},
|
||||
Err(e) => {
|
||||
trace!(
|
||||
"remote call request from {} ({} at {:?}) failed with: {}",
|
||||
peer,
|
||||
request.method,
|
||||
request.block,
|
||||
e,
|
||||
);
|
||||
None
|
||||
},
|
||||
};
|
||||
let response = match self.client.execution_proof(&block, &request.method, &request.data) {
|
||||
Ok((_, proof)) => {
|
||||
let r = schema::v1::light::RemoteCallResponse { proof: proof.encode() };
|
||||
Some(schema::v1::light::response::Response::RemoteCallResponse(r))
|
||||
},
|
||||
Err(e) => {
|
||||
trace!(
|
||||
"remote call request from {} ({} at {:?}) failed with: {}",
|
||||
peer,
|
||||
request.method,
|
||||
request.block,
|
||||
e,
|
||||
);
|
||||
None
|
||||
},
|
||||
};
|
||||
|
||||
Ok(schema::v1::light::Response { response })
|
||||
}
|
||||
@@ -215,25 +211,23 @@ where
|
||||
|
||||
let block = Decode::decode(&mut request.block.as_ref())?;
|
||||
|
||||
let response = match self
|
||||
.client
|
||||
.read_proof(&BlockId::Hash(block), &mut request.keys.iter().map(AsRef::as_ref))
|
||||
{
|
||||
Ok(proof) => {
|
||||
let r = schema::v1::light::RemoteReadResponse { proof: proof.encode() };
|
||||
Some(schema::v1::light::response::Response::RemoteReadResponse(r))
|
||||
},
|
||||
Err(error) => {
|
||||
trace!(
|
||||
"remote read request from {} ({} at {:?}) failed with: {}",
|
||||
peer,
|
||||
fmt_keys(request.keys.first(), request.keys.last()),
|
||||
request.block,
|
||||
error,
|
||||
);
|
||||
None
|
||||
},
|
||||
};
|
||||
let response =
|
||||
match self.client.read_proof(&block, &mut request.keys.iter().map(AsRef::as_ref)) {
|
||||
Ok(proof) => {
|
||||
let r = schema::v1::light::RemoteReadResponse { proof: proof.encode() };
|
||||
Some(schema::v1::light::response::Response::RemoteReadResponse(r))
|
||||
},
|
||||
Err(error) => {
|
||||
trace!(
|
||||
"remote read request from {} ({} at {:?}) failed with: {}",
|
||||
peer,
|
||||
fmt_keys(request.keys.first(), request.keys.last()),
|
||||
request.block,
|
||||
error,
|
||||
);
|
||||
None
|
||||
},
|
||||
};
|
||||
|
||||
Ok(schema::v1::light::Response { response })
|
||||
}
|
||||
@@ -265,7 +259,7 @@ where
|
||||
};
|
||||
let response = match child_info.and_then(|child_info| {
|
||||
self.client.read_child_proof(
|
||||
&BlockId::Hash(block),
|
||||
&block,
|
||||
&child_info,
|
||||
&mut request.keys.iter().map(AsRef::as_ref),
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ use sc_network_common::{
|
||||
config::ProtocolId,
|
||||
request_responses::{IncomingRequest, OutgoingResponse, ProtocolConfig},
|
||||
};
|
||||
use sp_runtime::{generic::BlockId, traits::Block as BlockT};
|
||||
use sp_runtime::traits::Block as BlockT;
|
||||
use std::{
|
||||
hash::{Hash, Hasher},
|
||||
sync::Arc,
|
||||
@@ -205,14 +205,14 @@ where
|
||||
|
||||
if !request.no_proof {
|
||||
let (proof, _count) = self.client.read_proof_collection(
|
||||
&BlockId::hash(block),
|
||||
&block,
|
||||
request.start.as_slice(),
|
||||
MAX_RESPONSE_BYTES,
|
||||
)?;
|
||||
response.proof = proof.encode();
|
||||
} else {
|
||||
let entries = self.client.storage_collection(
|
||||
&BlockId::hash(block),
|
||||
&block,
|
||||
request.start.as_slice(),
|
||||
MAX_RESPONSE_BYTES,
|
||||
)?;
|
||||
|
||||
Reference in New Issue
Block a user