pub struct SectionTree { /* private fields */ }Expand description
Container for storing information about other sections in the network.
Implementations§
Source§impl SectionTree
impl SectionTree
Sourcepub fn new(
genesis_sap: SectionSigned<SectionAuthorityProvider>,
) -> Result<SectionTree, Error>
pub fn new( genesis_sap: SectionSigned<SectionAuthorityProvider>, ) -> Result<SectionTree, Error>
Create a SectionTree with just the genesis section
Sourcepub fn from_bytes(bytes: &[u8]) -> Result<SectionTree, Error>
pub fn from_bytes(bytes: &[u8]) -> Result<SectionTree, Error>
Create a new SectionTree deserialised from bytes
Sourcepub async fn from_disk(path: &Path) -> Result<SectionTree, Error>
pub async fn from_disk(path: &Path) -> Result<SectionTree, Error>
Create a new SectionTree deserialised from a file
Sourcepub fn genesis_key(&self) -> &PublicKey
pub fn genesis_key(&self) -> &PublicKey
Returns the genesis key of the Network
pub fn get_sections_dag(&self) -> &SectionsDAG
pub fn prefixes(&self) -> impl Iterator<Item = &Prefix>
Sourcepub fn closest(
&self,
name: &XorName,
exclude: Option<&Prefix>,
) -> Option<&SectionSigned<SectionAuthorityProvider>>
pub fn closest( &self, name: &XorName, exclude: Option<&Prefix>, ) -> Option<&SectionSigned<SectionAuthorityProvider>>
Returns the known section that is closest to the given name,
regardless of whether name belongs in that section or not.
If provided, it excludes any section matching the passed prefix.
Sourcepub fn all(&self) -> impl Iterator<Item = &SectionAuthorityProvider>
pub fn all(&self) -> impl Iterator<Item = &SectionAuthorityProvider>
Returns all known sections SAP.
Sourcepub fn get(&self, prefix: &Prefix) -> Option<SectionAuthorityProvider>
pub fn get(&self, prefix: &Prefix) -> Option<SectionAuthorityProvider>
Get SectionAuthorityProvider of a known section with the given prefix.
Sourcepub fn get_signed(
&self,
prefix: &Prefix,
) -> Option<&SectionSigned<SectionAuthorityProvider>>
pub fn get_signed( &self, prefix: &Prefix, ) -> Option<&SectionSigned<SectionAuthorityProvider>>
Get signed SectionAuthorityProvider of a known section with the given prefix.
Sourcepub fn get_signed_by_key(
&self,
section_key: &PublicKey,
) -> Option<&SectionSigned<SectionAuthorityProvider>>
pub fn get_signed_by_key( &self, section_key: &PublicKey, ) -> Option<&SectionSigned<SectionAuthorityProvider>>
Get signed SectionAuthorityProvider of a known section with the given section key.
Sourcepub fn get_signed_by_name(
&self,
name: &XorName,
) -> Result<SectionSigned<SectionAuthorityProvider>, Error>
pub fn get_signed_by_name( &self, name: &XorName, ) -> Result<SectionSigned<SectionAuthorityProvider>, Error>
Returns the section authority provider for the prefix that matches name.
In case there is no prefix matches the name, we shall return the one with longest
common bits. i.e. for the name of 00xxx, if we have 01 and 1, then we shall return
with 01.
Sourcepub fn get_signed_by_prefix(
&self,
prefix: &Prefix,
) -> Result<SectionSigned<SectionAuthorityProvider>, Error>
pub fn get_signed_by_prefix( &self, prefix: &Prefix, ) -> Result<SectionSigned<SectionAuthorityProvider>, Error>
Get the section that matches prefix. In case of multiple matches, returns the
one with the longest prefix.
Sourcepub fn section_keys(&self) -> Vec<PublicKey>
pub fn section_keys(&self) -> Vec<PublicKey>
Returns the known section public keys.
Sourcepub fn known_sections_count(&self) -> usize
pub fn known_sections_count(&self) -> usize
Get total number of known sections
pub fn generate_section_tree_update( &self, prefix: &Prefix, ) -> Result<SectionTreeUpdate, Error>
Sourcepub fn update_the_section_tree(
&mut self,
section_tree_update: SectionTreeUpdate,
) -> Result<bool, Error>
pub fn update_the_section_tree( &mut self, section_tree_update: SectionTreeUpdate, ) -> Result<bool, Error>
Update our SectionTree if the provided update can be verified
Returns true if an update was made
Sourcepub fn insert_without_chain(
&mut self,
sap: SectionSigned<SectionAuthorityProvider>,
) -> bool
pub fn insert_without_chain( &mut self, sap: SectionSigned<SectionAuthorityProvider>, ) -> bool
For testing purpose, we may need to populate a section_tree without a proof chain.
Sourcepub async fn write_to_disk(&self, path: &Path) -> Result<(), Error>
pub async fn write_to_disk(&self, path: &Path) -> Result<(), Error>
Serialise and write it to disk on the provided file path
Sourcepub fn network_stats(&self, our: &SectionAuthorityProvider) -> NetworkStats
pub fn network_stats(&self, our: &SectionAuthorityProvider) -> NetworkStats
Returns network statistics.
Trait Implementations§
Source§impl Clone for SectionTree
impl Clone for SectionTree
Source§fn clone(&self) -> SectionTree
fn clone(&self) -> SectionTree
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SectionTree
impl Debug for SectionTree
Source§impl<'de> Deserialize<'de> for SectionTree
impl<'de> Deserialize<'de> for SectionTree
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SectionTree, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SectionTree, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Ord for SectionTree
impl Ord for SectionTree
Source§fn cmp(&self, other: &SectionTree) -> Ordering
fn cmp(&self, other: &SectionTree) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for SectionTree
impl PartialEq for SectionTree
Source§impl PartialOrd for SectionTree
impl PartialOrd for SectionTree
Source§impl Serialize for SectionTree
impl Serialize for SectionTree
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for SectionTree
Auto Trait Implementations§
impl Freeze for SectionTree
impl RefUnwindSafe for SectionTree
impl Send for SectionTree
impl Sync for SectionTree
impl Unpin for SectionTree
impl UnwindSafe for SectionTree
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.