BlockId removal: &Hash to Hash (#12626)

It changes &Block::Hash argument to Block::Hash.

This PR is part of BlockId::Number refactoring analysis (paritytech/substrate#11292)
This commit is contained in:
Michal Kucharczyk
2022-11-07 22:42:16 +01:00
committed by GitHub
parent 7c4bfc9749
commit 1ed70004e7
49 changed files with 428 additions and 441 deletions
+1 -1
View File
@@ -126,7 +126,7 @@ where
Pin<Box<dyn Future<Output = error::Result<TransactionValidity>> + Send>>;
type BodyFuture = Ready<error::Result<Option<Vec<<Self::Block as BlockT>::Extrinsic>>>>;
fn block_body(&self, hash: &Block::Hash) -> Self::BodyFuture {
fn block_body(&self, hash: Block::Hash) -> Self::BodyFuture {
ready(self.client.block_body(hash).map_err(error::Error::from))
}
@@ -91,7 +91,7 @@ pub trait ChainApi: Send + Sync {
fn hash_and_length(&self, uxt: &ExtrinsicFor<Self>) -> (ExtrinsicHash<Self>, usize);
/// Returns a block body given the block.
fn block_body(&self, at: &<Self::Block as BlockT>::Hash) -> Self::BodyFuture;
fn block_body(&self, at: <Self::Block as BlockT>::Hash) -> Self::BodyFuture;
/// Returns a block header given the block id.
fn block_header(
+6 -6
View File
@@ -550,12 +550,12 @@ impl<N: Clone + Copy + AtLeast32Bit> RevalidationStatus<N> {
/// Prune the known txs for the given block.
async fn prune_known_txs_for_block<Block: BlockT, Api: graph::ChainApi<Block = Block>>(
block_hash: &Block::Hash,
block_hash: Block::Hash,
api: &Api,
pool: &graph::Pool<Api>,
) -> Vec<ExtrinsicHash<Api>> {
let extrinsics = api
.block_body(&block_hash)
.block_body(block_hash)
.await
.unwrap_or_else(|e| {
log::warn!("Prune known transactions: error request: {}", e);
@@ -567,7 +567,7 @@ async fn prune_known_txs_for_block<Block: BlockT, Api: graph::ChainApi<Block = B
log::trace!(target: "txpool", "Pruning transactions: {:?}", hashes);
let header = match api.block_header(&BlockId::Hash(*block_hash)) {
let header = match api.block_header(&BlockId::Hash(block_hash)) {
Ok(Some(h)) => h,
Ok(None) => {
log::debug!(target: "txpool", "Could not find header for {:?}.", block_hash);
@@ -580,7 +580,7 @@ async fn prune_known_txs_for_block<Block: BlockT, Api: graph::ChainApi<Block = B
};
if let Err(e) = pool
.prune(&BlockId::Hash(*block_hash), &BlockId::hash(*header.parent_hash()), &extrinsics)
.prune(&BlockId::Hash(block_hash), &BlockId::hash(*header.parent_hash()), &extrinsics)
.await
{
log::error!("Cannot prune known in the pool: {}", e);
@@ -638,7 +638,7 @@ where
tree_route
.enacted()
.iter()
.map(|h| prune_known_txs_for_block(&h.hash, &*api, &*pool)),
.map(|h| prune_known_txs_for_block(h.hash, &*api, &*pool)),
)
.await
.into_iter()
@@ -656,7 +656,7 @@ where
let hash = retracted.hash;
let block_transactions = api
.block_body(&hash)
.block_body(hash)
.await
.unwrap_or_else(|e| {
log::warn!("Failed to fetch block body: {}", e);
@@ -164,7 +164,7 @@ impl ChainApi for TestApi {
(Hashing::hash(&encoded), len)
}
fn block_body(&self, _id: &<Self::Block as BlockT>::Hash) -> Self::BodyFuture {
fn block_body(&self, _id: <Self::Block as BlockT>::Hash) -> Self::BodyFuture {
futures::future::ready(Ok(None))
}