mirror of
https://github.com/serai-dex/serai.git
synced 2025-01-24 11:36:18 +00:00
Add an already in chain check to block import
While the inner should do this for us, we call verify_order on our end *before* inner to ensure sequential import. Accordingly, we need to provide our own check. Removes errors of "non-sequential import" when trying to re-import an existing block.
This commit is contained in:
parent
16065ccd4e
commit
40b6cb7106
1 changed files with 4 additions and 1 deletions
|
@ -4,7 +4,7 @@ use async_trait::async_trait;
|
||||||
|
|
||||||
use sp_api::BlockId;
|
use sp_api::BlockId;
|
||||||
use sp_runtime::traits::Block;
|
use sp_runtime::traits::Block;
|
||||||
use sp_blockchain::{HeaderBackend, Backend as BlockchainBackend};
|
use sp_blockchain::{BlockStatus, HeaderBackend, Backend as BlockchainBackend};
|
||||||
use sp_consensus::{Error, CacheKeyId, SelectChain};
|
use sp_consensus::{Error, CacheKeyId, SelectChain};
|
||||||
|
|
||||||
use sc_consensus::{BlockCheckParams, BlockImportParams, ImportResult, BlockImport, Verifier};
|
use sc_consensus::{BlockCheckParams, BlockImportParams, ImportResult, BlockImport, Verifier};
|
||||||
|
@ -28,6 +28,9 @@ where
|
||||||
&mut self,
|
&mut self,
|
||||||
mut block: BlockCheckParams<T::Block>,
|
mut block: BlockCheckParams<T::Block>,
|
||||||
) -> Result<ImportResult, Self::Error> {
|
) -> Result<ImportResult, Self::Error> {
|
||||||
|
if self.client.status(BlockId::Hash(block.hash)).unwrap() == BlockStatus::InChain {
|
||||||
|
return Ok(ImportResult::AlreadyInChain);
|
||||||
|
}
|
||||||
self.verify_order(block.parent_hash, block.number)?;
|
self.verify_order(block.parent_hash, block.number)?;
|
||||||
|
|
||||||
// Does not verify origin here as origin only applies to unfinalized blocks
|
// Does not verify origin here as origin only applies to unfinalized blocks
|
||||||
|
|
Loading…
Reference in a new issue