Introduce 'intermediate_insert' method to hide implementation details (#12215)

Renaming from 'intermediate_take' to 'intermediate_remove'
This commit is contained in:
Davide Galassi
2022-09-21 11:42:12 +02:00
committed by GitHub
parent c6a9abcc68
commit 6c7020bb16
7 changed files with 32 additions and 46 deletions
+4 -9
View File
@@ -65,10 +65,7 @@ use sp_runtime::{
traits::{Block as BlockT, Header as HeaderT},
RuntimeString,
};
use std::{
borrow::Cow, cmp::Ordering, collections::HashMap, marker::PhantomData, sync::Arc,
time::Duration,
};
use std::{cmp::Ordering, collections::HashMap, marker::PhantomData, sync::Arc, time::Duration};
#[derive(Debug, thiserror::Error)]
pub enum Error<B: BlockT> {
@@ -358,8 +355,8 @@ where
let inner_seal = fetch_seal::<B>(block.post_digests.last(), block.header.hash())?;
let intermediate =
block.take_intermediate::<PowIntermediate<Algorithm::Difficulty>>(INTERMEDIATE_KEY)?;
let intermediate = block
.remove_intermediate::<PowIntermediate<Algorithm::Difficulty>>(INTERMEDIATE_KEY)?;
let difficulty = match intermediate.difficulty {
Some(difficulty) => difficulty,
@@ -455,9 +452,7 @@ where
let intermediate = PowIntermediate::<Algorithm::Difficulty> { difficulty: None };
block.header = checked_header;
block.post_digests.push(seal);
block
.intermediates
.insert(Cow::from(INTERMEDIATE_KEY), Box::new(intermediate) as Box<_>);
block.insert_intermediate(INTERMEDIATE_KEY, intermediate);
block.post_hash = Some(hash);
Ok((block, None))
+1 -5
View File
@@ -32,7 +32,6 @@ use sp_runtime::{
DigestItem,
};
use std::{
borrow::Cow,
collections::HashMap,
pin::Pin,
sync::{
@@ -212,10 +211,7 @@ where
let intermediate = PowIntermediate::<Algorithm::Difficulty> {
difficulty: Some(build.metadata.difficulty),
};
import_block
.intermediates
.insert(Cow::from(INTERMEDIATE_KEY), Box::new(intermediate) as Box<_>);
import_block.insert_intermediate(INTERMEDIATE_KEY, intermediate);
let header = import_block.post_header();
let mut block_import = self.block_import.lock();