Lines
100 %
Functions
81.82 %
Branches
//! Calculate consensus footer
use super::*;
/// "Already computed" for footer calculoations
///
/// The footer can depend on all the previous consensus, notably the preamble and the routers.
#[derive(Debug, Clone, Copy)]
#[allow(unused)] // TODO DIRAUTH
pub(super) struct FooterAC<'r> {
/// Preamble
pub preamble: &'r netstatus::plain::Preamble,
/// Routerstatuses
pub routers: &'r [netstatus::plain::RouterStatus],
}
impl<'f> ConsensusesFromVotes<FooterAC<'f>> for netstatus::vote::Footer {
type PlainOutput = netstatus::plain::Footer;
type MdOutput = netstatus::md::Footer;
fn consensuses<'i>(
context: ConsensusContextRefs<FooterAC<'f>>,
_inputs: impl ComponentInVotes<&'i Self>,
) -> Result<(Self::PlainOutput, Self::MdOutput), ConsensusError>
where
Self: 'i,
{
calc! { both.consensus = make_footer_fields(context)?; }
Ok(construct_both! {
netstatus::plain::Footer, netstatus::md::Footer {
both. consensus;
} {
})
/// Calculate the actual footer, as a `ConsensusFooterFields`
/// Not `Aggregate` and doesn't take any inputs, because votes don't have footers
/// (so that field in a vote is `NotPresent`.)
fn make_footer_fields<'f>(
_context: ConsensusContextRefs<FooterAC<'f>>,
) -> Result<netstatus::ConsensusFooterFields, ConsensusError> {
let out_bandwidth_weights = ParamValues::default(); // TODO DIRAUTH
Ok(construct! {
netstatus::ConsensusFooterFields {
out. bandwidth_weights;