mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-10 05:09:22 +00:00
Replace panicking todos with stubs and // TODO
Enables progress.
This commit is contained in:
@@ -21,7 +21,7 @@ use async_trait::async_trait;
|
|||||||
|
|
||||||
use tokio::sync::RwLock as AsyncRwLock;
|
use tokio::sync::RwLock as AsyncRwLock;
|
||||||
|
|
||||||
use sp_core::Decode;
|
use sp_core::{Encode, Decode};
|
||||||
use sp_application_crypto::sr25519::Signature;
|
use sp_application_crypto::sr25519::Signature;
|
||||||
use sp_inherents::CreateInherentDataProviders;
|
use sp_inherents::CreateInherentDataProviders;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
@@ -109,7 +109,8 @@ impl<
|
|||||||
block: B,
|
block: B,
|
||||||
providers: CIDP::InherentDataProviders,
|
providers: CIDP::InherentDataProviders,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
todo!()
|
// TODO
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure this is part of a sequential import
|
// Ensure this is part of a sequential import
|
||||||
@@ -218,6 +219,18 @@ impl<
|
|||||||
|
|
||||||
Ok(())
|
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]
|
#[async_trait]
|
||||||
@@ -282,11 +295,7 @@ impl<
|
|||||||
_: <B::Header as Header>::Number,
|
_: <B::Header as Header>::Number,
|
||||||
justification: Justification,
|
justification: Justification,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
self.verify_justification(hash, &justification)?;
|
self.import_justification_actual(hash, justification)
|
||||||
self
|
|
||||||
.client
|
|
||||||
.finalize_block(BlockId::Hash(hash), Some(justification), true)
|
|
||||||
.map_err(|_| Error::InvalidJustification)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -325,7 +334,7 @@ impl<
|
|||||||
const BLOCK_TIME: u32 = { (serai_runtime::MILLISECS_PER_BLOCK / 1000) as u32 };
|
const BLOCK_TIME: u32 = { (serai_runtime::MILLISECS_PER_BLOCK / 1000) as u32 };
|
||||||
|
|
||||||
fn signature_scheme(&self) -> Arc<TendermintSigner> {
|
fn signature_scheme(&self) -> Arc<TendermintSigner> {
|
||||||
todo!()
|
Arc::new(TendermintSigner::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn weights(&self) -> Arc<TendermintWeights> {
|
fn weights(&self) -> Arc<TendermintWeights> {
|
||||||
@@ -333,7 +342,7 @@ impl<
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn broadcast(&mut self, msg: SignedMessage<u16, Self::Block, Signature>) {
|
async fn broadcast(&mut self, msg: SignedMessage<u16, Self::Block, Signature>) {
|
||||||
todo!()
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn slash(&mut self, validator: u16) {
|
async fn slash(&mut self, validator: u16) {
|
||||||
@@ -348,6 +357,8 @@ impl<
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn add_block(&mut self, block: B, commit: Commit<TendermintSigner>) -> B {
|
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!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,14 @@ pub(crate) struct TendermintSigner {
|
|||||||
lookup: Vec<Public>,
|
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 {
|
impl SignatureScheme for TendermintSigner {
|
||||||
type ValidatorId = u16;
|
type ValidatorId = u16;
|
||||||
type Signature = Signature;
|
type Signature = Signature;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use tendermint_machine::ext::{BlockNumber, Round, Weights};
|
|||||||
|
|
||||||
const VALIDATORS: usize = 1;
|
const VALIDATORS: usize = 1;
|
||||||
|
|
||||||
|
// TODO: Move to sp_session
|
||||||
pub(crate) struct TendermintWeights;
|
pub(crate) struct TendermintWeights;
|
||||||
impl Weights for TendermintWeights {
|
impl Weights for TendermintWeights {
|
||||||
type ValidatorId = u16;
|
type ValidatorId = u16;
|
||||||
|
|||||||
Reference in New Issue
Block a user