Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #344 from input-output-hk/loki
Planification of the leader selection per epoch
- Loading branch information
Showing
29 changed files
with
950 additions
and
377 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule cardano-deps
updated
from df2133 to 0ac5ac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use crate::blockcfg::{ChainLength, HeaderHash}; | ||
use chain_impl_mockchain::multiverse::GCRoot; | ||
use std::sync::Arc; | ||
|
||
/// `Branch` or `Fork` are the different _propositions_ of what is | ||
/// the current state of the ledger | ||
/// | ||
/// In some modes, like in BFT, it is very unlikely (near impossible) | ||
/// to experiences competitive branches because the leadership is | ||
/// deterministic and *absolute*: only one node is authorized to create | ||
/// a new block at a time. | ||
/// | ||
/// In other modes, like in genesis praos, the leadership is deterministic | ||
/// (in the sense we can reproduce the result in the same circumstances) | ||
/// but it is not necessarily *absolute*: it is possible that multiple nodes | ||
/// are elected to propose the next block. | ||
/// | ||
/// This Branch structure is useful to maintain states of different branches | ||
/// as well as the consensus branch: the **tip**. | ||
#[derive(Clone)] | ||
pub struct Branch { | ||
/// Make sure we hold the branch's details for as long as we need to | ||
/// in the multiverse. | ||
reference: Arc<GCRoot>, | ||
|
||
/// keep the chain length details of the branch | ||
/// | ||
/// This is a useful parameter to make choices regarding | ||
/// competitive branch (for the consensus, the choice of the **tip**). | ||
chain_length: ChainLength, | ||
} | ||
|
||
impl Branch { | ||
/// create a new branch from the given GCRoot | ||
#[inline] | ||
pub fn new(reference: GCRoot, chain_length: ChainLength) -> Self { | ||
Branch { | ||
reference: Arc::new(reference), | ||
chain_length, | ||
} | ||
} | ||
|
||
/// get the branch latest block hash | ||
#[inline] | ||
pub fn hash(&self) -> HeaderHash { | ||
**self.reference | ||
} | ||
|
||
/// get the branch latest block hash | ||
#[inline] | ||
pub fn chain_length(&self) -> &ChainLength { | ||
&self.chain_length | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
mod branch; | ||
mod chain; | ||
mod process; | ||
mod tip; | ||
|
||
pub use self::branch::Branch; | ||
pub use self::chain::{ | ||
handle_block, Blockchain, BlockchainR, HandleBlockError, HandledBlock, LoadError, | ||
}; | ||
pub use self::process::handle_input; | ||
pub use self::tip::{Tip, TipGetError, TipReplaceError}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.