Skip to content
Permalink
Browse files

update the leadership to the latest API

  • Loading branch information...
NicolasDP committed Mar 12, 2019
1 parent dc5e5aa commit a533c9cd1f8c26b10cada1150231b0f0e3ea03b2
@@ -1,8 +1,6 @@
//! Representation of the block in the mockchain.
use crate::key::{make_signature, make_signature_update, Hash};
use crate::leadership::Leader;
use crate::transaction::SignedTransaction;
use chain_addr::Address;
use chain_core::property::{self, Serialize};
use chain_crypto::Verification;

@@ -1,7 +1,7 @@
use crate::block::{Block, Proof, BLOCK_VERSION_CONSENSUS_BFT};
use crate::leadership::{BftLeader, Error, ErrorKind, PublicLeader, Update};
use crate::block::Block;
use crate::leadership::{BftLeader, Error, PublicLeader};

use chain_core::property::{self, Block as _, LeaderSelection};
use chain_core::property::{self, LeaderSelection};

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BftRoundRobinIndex(u64);
@@ -329,11 +329,10 @@ impl property::Update for GenesisSelectionDiff {
}

impl LeaderSelection for GenesisLeaderSelection {
type Update = Update;
type Block = Block;
type Error = Error;
type LeaderId = PublicLeader;

/*
fn diff(&self, input: &Self::Block) -> Result<Self::Update, Self::Error> {
let mut update = <Self::Update as property::Update>::empty();
@@ -651,7 +650,7 @@ impl LeaderSelection for GenesisLeaderSelection {
Ok(())
}

*/
fn get_leader_at(
&self,
date: <Self::Block as property::Block>::Date,
@@ -1,5 +1,4 @@
use crate::key::{deserialize_public_key, serialize_public_key};
use crate::stake::StakePoolId;
use chain_core::property;
use chain_crypto::algorithms::vrf::vrf::{self, ProvenOutputSeed};
use chain_crypto::{Ed25519Extended, FakeMMM, PublicKey, SecretKey};
@@ -1,8 +1,8 @@
use crate::{
block::{Block, BlockVersion, Proof, BLOCK_VERSION_CONSENSUS_NONE},
leadership::{Error, ErrorKind, PublicLeader, Update},
block::Block,
leadership::{Error, PublicLeader},
};
use chain_core::property::{self, Block as _, LeaderSelection};
use chain_core::property::{self, LeaderSelection};

/// Object for when there is no leadership for the block creation
///
@@ -24,38 +24,8 @@ pub enum NoLeadershipError {
impl LeaderSelection for NoLeadership {
type LeaderId = PublicLeader;
type Block = Block;
type Update = Update;
type Error = Error;

fn diff(&self, input: &Self::Block) -> Result<Self::Update, Self::Error> {
if input.version() != BLOCK_VERSION_CONSENSUS_NONE {
return Err(Error {
kind: ErrorKind::IncompatibleBlockVersion,
cause: Some(Box::new(NoLeadershipError::IncompatibleBlockVersion)),
});
}
match &input.header.proof {
Proof::None => {
let mut update = <Self::Update as property::Update>::empty();
update.previous_leader = PublicLeader::None;
update.next_leader = PublicLeader::None;
Ok(update)
}
Proof::Bft(_) => Err(Error {
kind: ErrorKind::IncompatibleLeadershipMode,
cause: Some(Box::new(NoLeadershipError::BlockProofIsDifferent)),
}),
Proof::GenesisPraos(_) => Err(Error {
kind: ErrorKind::IncompatibleLeadershipMode,
cause: Some(Box::new(NoLeadershipError::BlockProofIsDifferent)),
}),
}
}

fn apply(&mut self, _update: Self::Update) -> Result<(), Self::Error> {
Ok(())
}

fn get_leader_at(
&self,
_date: <Self::Block as property::Block>::Date,
@@ -1,7 +1,6 @@
mod transfer;
mod utxo;

use crate::key::Hash;
use crate::value::*;
use chain_addr::Address;
use chain_core::property;

0 comments on commit a533c9c

Please sign in to comment.
You can’t perform that action at this time.