Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions sidechain/consensus/common/src/header_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

*/
use itp_types::H256;
use its_primitives::{traits::Header as HeaderT, types::header::SidechainHeader};
use its_primitives::traits::Header as HeaderT;
use std::{collections::HashMap, convert::From, hash::Hash as HashT};

/// Normally implemented on the `client` in substrate.
Expand All @@ -33,12 +33,12 @@ impl<Hash, Header> HeaderDbTrait for HeaderDb<Hash, Header>
where
// TODO: the H256 trait bounds are needed because: #1203
Hash: PartialEq + HashT + Into<H256> + From<H256> + core::cmp::Eq + Clone,
Header: HeaderT + Clone + Into<SidechainHeader>,
Header: HeaderT + Clone,
{
type Header = SidechainHeader;
type Header = Header;

fn header(&self, hash: &H256) -> Option<Self::Header> {
let header = self.0.get(&Hash::from(*hash))?;
Some(header.clone().into())
Some(header.clone())
}
}
4 changes: 0 additions & 4 deletions sidechain/consensus/common/src/is_descendant_of_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use core::{hash::Hash as HashT, marker::PhantomData};
use itp_types::H256;
use its_primitives::traits::Header as HeaderT;

#[allow(dead_code)]
pub struct IsDescendantOfBuilder<Hash, HeaderDb, Error>(PhantomData<(Hash, HeaderDb, Error)>);

impl<'a, Hash, HeaderDb, Error> IsDescendantOfBuilder<Hash, HeaderDb, Error>
Expand All @@ -30,7 +29,6 @@ where
{
/// Build the `is_descendant_of` closure for the fork-tree structure
/// to utilize when adding and removing nodes from the tree.
#[allow(dead_code)]
pub fn build_is_descendant_of(
current: Option<(&'a Hash, &'a Hash)>,
header_db: &'a HeaderDb,
Expand Down Expand Up @@ -69,7 +67,6 @@ where
}
}

#[allow(dead_code)]
pub struct LowestCommonAncestorFinder<Hash, HeaderDb>(PhantomData<(Hash, HeaderDb)>);

impl<Hash, HeaderDb> LowestCommonAncestorFinder<Hash, HeaderDb>
Expand All @@ -78,7 +75,6 @@ where
HeaderDb: HeaderDbTrait,
{
/// Used by the `build_is_descendant_of` to find the LCA of two nodes in the fork-tree.
#[allow(dead_code)]
fn find_lowest_common_ancestor(a: &Hash, b: &Hash, header_db: &HeaderDb) -> Result<Hash, ()> {
let header_1 = header_db.header(&a.clone().into()).ok_or(())?;
let header_2 = header_db.header(&b.clone().into()).ok_or(())?;
Expand Down
5 changes: 4 additions & 1 deletion sidechain/consensus/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ mod block_import_confirmation_handler;
mod block_import_queue_worker;
mod error;
mod header_db;
mod is_descendant_of_builder;
mod peer_block_sync;

// The feature flag will be removed once we use the module outside of tests.
#[cfg(test)]
mod is_descendant_of_builder;

#[cfg(test)]
mod test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl std::fmt::Display for TestError {

impl std::error::Error for TestError {}

#[cfg(test)]
mod tests {
use super::*;

Expand Down