Replace panicking todos with stubs and // TODO

Enables progress.
This commit is contained in:
Luke Parker
2022-10-21 21:14:05 -04:00
parent 5019f4cb65
commit 422f7e3e2f
3 changed files with 29 additions and 9 deletions

View File

@@ -21,7 +21,7 @@ use async_trait::async_trait;
use tokio::sync::RwLock as AsyncRwLock;
use sp_core::Decode;
use sp_core::{Encode, Decode};
use sp_application_crypto::sr25519::Signature;
use sp_inherents::CreateInherentDataProviders;
use sp_runtime::{
@@ -109,7 +109,8 @@ impl<
block: B,
providers: CIDP::InherentDataProviders,
) -> Result<(), Error> {
todo!()
// TODO
Ok(())
}
// Ensure this is part of a sequential import
@@ -218,6 +219,18 @@ impl<
Ok(())
}
fn import_justification_actual(
&mut self,
hash: B::Hash,
justification: Justification,
) -> Result<(), Error> {
self.verify_justification(hash, &justification)?;
self
.client
.finalize_block(BlockId::Hash(hash), Some(justification), true)
.map_err(|_| Error::InvalidJustification)
}
}
#[async_trait]
@@ -282,11 +295,7 @@ impl<
_: <B::Header as Header>::Number,
justification: Justification,
) -> Result<(), Error> {
self.verify_justification(hash, &justification)?;
self
.client
.finalize_block(BlockId::Hash(hash), Some(justification), true)
.map_err(|_| Error::InvalidJustification)
self.import_justification_actual(hash, justification)
}
}
@@ -325,7 +334,7 @@ impl<
const BLOCK_TIME: u32 = { (serai_runtime::MILLISECS_PER_BLOCK / 1000) as u32 };
fn signature_scheme(&self) -> Arc<TendermintSigner> {
todo!()
Arc::new(TendermintSigner::new())
}
fn weights(&self) -> Arc<TendermintWeights> {
@@ -333,7 +342,7 @@ impl<
}
async fn broadcast(&mut self, msg: SignedMessage<u16, Self::Block, Signature>) {
todo!()
// TODO
}
async fn slash(&mut self, validator: u16) {
@@ -348,6 +357,8 @@ impl<
}
fn add_block(&mut self, block: B, commit: Commit<TendermintSigner>) -> B {
self.import_justification_actual(block.hash(), (CONSENSUS_ID, commit.encode())).unwrap();
// Next block proposal
todo!()
}
}

View File

@@ -10,6 +10,14 @@ pub(crate) struct TendermintSigner {
lookup: Vec<Public>,
}
impl TendermintSigner {
pub(crate) fn new() -> TendermintSigner {
// TODO
let keys = Pair::from_string("//Alice", None).unwrap();
TendermintSigner { lookup: vec![keys.public()], keys }
}
}
impl SignatureScheme for TendermintSigner {
type ValidatorId = u16;
type Signature = Signature;

View File

@@ -4,6 +4,7 @@ use tendermint_machine::ext::{BlockNumber, Round, Weights};
const VALIDATORS: usize = 1;
// TODO: Move to sp_session
pub(crate) struct TendermintWeights;
impl Weights for TendermintWeights {
type ValidatorId = u16;