mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 05:09:22 +00:00
Properly use check_block
This commit is contained in:
@@ -76,7 +76,18 @@ where
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Transaction = TransactionFor<C, B>;
|
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)
|
self.inner.check_block(block).await.map_err(Into::into)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,11 +96,6 @@ where
|
|||||||
mut block: BlockImportParams<B, Self::Transaction>,
|
mut block: BlockImportParams<B, Self::Transaction>,
|
||||||
new_cache: HashMap<CacheKeyId, Vec<u8>>,
|
new_cache: HashMap<CacheKeyId, Vec<u8>>,
|
||||||
) -> Result<ImportResult, Self::Error> {
|
) -> 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(body) = block.body.clone() {
|
||||||
if let Some(justifications) = block.justifications {
|
if let Some(justifications) = block.justifications {
|
||||||
let mut iter = justifications.iter();
|
let mut iter = justifications.iter();
|
||||||
@@ -111,7 +117,7 @@ where
|
|||||||
self
|
self
|
||||||
.check_inherents(
|
.check_inherents(
|
||||||
B::new(block.header.clone(), body),
|
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?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user