mirror of
https://github.com/serai-dex/serai.git
synced 2025-03-12 09:26:51 +00:00
Properly use check_block
This commit is contained in:
parent
eb59dd5a55
commit
49a26e5841
1 changed files with 13 additions and 7 deletions
|
@ -76,7 +76,18 @@ where
|
|||
type Error = Error;
|
||||
type Transaction = TransactionFor<C, B>;
|
||||
|
||||
async fn check_block(&mut self, block: BlockCheckParams<B>) -> Result<ImportResult, Self::Error> {
|
||||
async fn check_block(
|
||||
&mut self,
|
||||
mut block: BlockCheckParams<B>,
|
||||
) -> Result<ImportResult, Self::Error> {
|
||||
let info = self.client.info();
|
||||
if (info.best_hash != block.parent_hash) || ((info.best_number + 1u16.into()) != block.number) {
|
||||
Err(Error::Other("non-sequential import".into()))?;
|
||||
}
|
||||
|
||||
block.allow_missing_state = false;
|
||||
block.allow_missing_parent = false;
|
||||
|
||||
self.inner.check_block(block).await.map_err(Into::into)
|
||||
}
|
||||
|
||||
|
@ -85,11 +96,6 @@ where
|
|||
mut block: BlockImportParams<B, Self::Transaction>,
|
||||
new_cache: HashMap<CacheKeyId, Vec<u8>>,
|
||||
) -> Result<ImportResult, Self::Error> {
|
||||
let parent_hash = *block.header.parent_hash();
|
||||
if self.client.info().best_hash != parent_hash {
|
||||
Err(Error::Other("non-sequential import".into()))?;
|
||||
}
|
||||
|
||||
if let Some(body) = block.body.clone() {
|
||||
if let Some(justifications) = block.justifications {
|
||||
let mut iter = justifications.iter();
|
||||
|
@ -111,7 +117,7 @@ where
|
|||
self
|
||||
.check_inherents(
|
||||
B::new(block.header.clone(), body),
|
||||
self.providers.create_inherent_data_providers(parent_hash, ()).await?,
|
||||
self.providers.create_inherent_data_providers(*block.header.parent_hash(), ()).await?,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue