blob: f64e9d003c8f43bfbc97d8aedb7d6b4612178b08 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
//! Implementation for the style of router status entries used in
//! microdesc consensus documents.
//
// Read this file in conjunction with `each_variety.rs`.
// See "module scope" ns_variety_definition_macros.rs.
use super::*;
// Import `each_variety.rs`, appropriately variegated
ns_do_variety_md! {}
// We bind some variety-agnostic names for the benefit of `each_variety.rs`,
// which reimports the contents of this module with `use super::*`.
pub(crate) use crate::doc::microdesc::{DOC_DIGEST_LEN, MdDigest as DocDigest};
/// The flavor
const FLAVOR: ConsensusFlavor = ConsensusFlavor::Microdesc;
impl RouterStatus {
/// Return the expected microdescriptor digest for this routerstatus
pub fn md_digest(&self) -> &DocDigest {
self.doc_digest()
}
}
/// Netdoc format helper module for referenced doc digest field in `m` (where it's an item)
///
/// See `doc_digest_parse2_real` in `rs/each_variety.rs`.
/// This is in `md.rs` because it's needed only for md consensuses.
/// Elsewhere, the value is in the `r` item, so is merely `ItemArgumentParseable`.
pub(crate) mod doc_digest_item_m {
use super::*;
use crate::parse2::ErrorProblem as EP;
use crate::parse2::UnparsedItem;
use std::result::Result;
/// Output the whole `m` item value
#[allow(clippy::unnecessary_wraps)]
pub(crate) fn write_item_value_onto(
digest: &FixedB64<DOC_DIGEST_LEN>,
out: ItemEncoder,
) -> Result<(), Bug> {
out.arg(digest);
Ok(())
}
/// Parse the whole `m` item value
pub(crate) fn from_unparsed(mut item: UnparsedItem) -> Result<FixedB64<DOC_DIGEST_LEN>, EP> {
item.check_no_object()?;
FixedB64::from_args(item.args_mut()).map_err(item.args().error_handler("doc_digest"))
}
}
|