fix(sync): remove redundant error (#476)

This commit is contained in:
Roman Krasiuk
2022-12-16 10:08:49 +02:00
committed by GitHub
parent 6a70494612
commit e9ec6c2847
3 changed files with 3 additions and 10 deletions

View File

@ -106,7 +106,7 @@ where
pub(crate) fn get_block_hash(&self, number: BlockNumber) -> Result<BlockHash, StageError> {
let hash = self
.get::<tables::CanonicalHeaders>(number)?
.ok_or(DatabaseIntegrityError::CanonicalHash { number })?;
.ok_or(DatabaseIntegrityError::CanonicalHeader { number })?;
Ok(hash)
}

View File

@ -69,13 +69,6 @@ impl StageError {
#[derive(Error, Debug)]
#[allow(missing_docs)]
pub enum DatabaseIntegrityError {
// TODO(onbjerg): What's the difference between this and the one below?
/// The canonical hash for a block is missing from the database.
#[error("No canonical hash for block #{number}")]
CanonicalHash {
/// The block number key
number: BlockNumber,
},
/// The canonical header for a block is missing from the database.
#[error("No canonical header for block #{number}")]
CanonicalHeader {

View File

@ -178,7 +178,7 @@ impl<D: HeaderDownloader, C: Consensus, H: HeadersClient, S: StatusUpdater>
// Get head hash and reposition the cursor
let (head_num, head_hash) = cursor
.seek_exact(stage_progress)?
.ok_or(DatabaseIntegrityError::CanonicalHash { number: stage_progress })?;
.ok_or(DatabaseIntegrityError::CanonicalHeader { number: stage_progress })?;
// Construct head
let (_, head) = header_cursor
@ -415,7 +415,7 @@ mod tests {
// Empty database
assert_matches!(
stage.get_head_and_tip(&db, stage_progress).await,
Err(StageError::DatabaseIntegrity(DatabaseIntegrityError::CanonicalHash { number }))
Err(StageError::DatabaseIntegrity(DatabaseIntegrityError::CanonicalHeader { number }))
if number == stage_progress
);