Struct solana_gossip::crds::Crds

source ·
pub struct Crds {
    table: IndexMap<CrdsValueLabel, VersionedCrdsValue>,
    cursor: Cursor,
    shards: CrdsShards,
    nodes: IndexSet<usize>,
    votes: BTreeMap<u64, usize>,
    epoch_slots: BTreeMap<u64, usize>,
    duplicate_shreds: BTreeMap<u64, usize>,
    records: HashMap<Pubkey, IndexSet<usize>>,
    entries: BTreeMap<u64, usize>,
    purged: VecDeque<(Hash, u64)>,
    shred_versions: HashMap<Pubkey, u16>,
    stats: Mutex<CrdsStats>,
}

Fields§

§table: IndexMap<CrdsValueLabel, VersionedCrdsValue>

Stores the map of labels and values

§cursor: Cursor§shards: CrdsShards§nodes: IndexSet<usize>§votes: BTreeMap<u64, usize>§epoch_slots: BTreeMap<u64, usize>§duplicate_shreds: BTreeMap<u64, usize>§records: HashMap<Pubkey, IndexSet<usize>>§entries: BTreeMap<u64, usize>§purged: VecDeque<(Hash, u64)>§shred_versions: HashMap<Pubkey, u16>§stats: Mutex<CrdsStats>

Implementations§

source§

impl Crds

source

pub(crate) fn upserts(&self, value: &CrdsValue) -> bool

Returns true if the given value updates an existing one in the table. The value is outdated and fails to insert, if it already exists in the table with a more recent wallclock.

source

pub fn insert( &mut self, value: CrdsValue, now: u64, route: GossipRoute ) -> Result<(), CrdsError>

source

pub fn get<'a, 'b, V>(&'a self, key: V::Key) -> Option<V>where V: CrdsEntry<'a, 'b>,

source

pub(crate) fn get_shred_version(&self, pubkey: &Pubkey) -> Option<u16>

source

pub(crate) fn get_nodes(&self) -> impl Iterator<Item = &VersionedCrdsValue>

Returns all entries which are ContactInfo.

source

pub(crate) fn get_nodes_contact_info( &self ) -> impl Iterator<Item = &ContactInfo>

Returns ContactInfo of all known nodes.

source

pub(crate) fn get_votes<'a>( &'a self, cursor: &'a mut Cursor ) -> impl Iterator<Item = &'a VersionedCrdsValue>

Returns all vote entries inserted since the given cursor. Updates the cursor as the votes are consumed.

source

pub(crate) fn get_epoch_slots<'a>( &'a self, cursor: &'a mut Cursor ) -> impl Iterator<Item = &'a VersionedCrdsValue>

Returns epoch-slots inserted since the given cursor. Updates the cursor as the values are consumed.

source

pub(crate) fn get_duplicate_shreds<'a>( &'a self, cursor: &'a mut Cursor ) -> impl Iterator<Item = &'a VersionedCrdsValue>

Returns duplicate-shreds inserted since the given cursor. Updates the cursor as the values are consumed.

source

pub(crate) fn get_entries<'a>( &'a self, cursor: &'a mut Cursor ) -> impl Iterator<Item = &'a VersionedCrdsValue>

Returns all entries inserted since the given cursor.

source

pub(crate) fn get_records( &self, pubkey: &Pubkey ) -> impl Iterator<Item = &VersionedCrdsValue>

Returns all records associated with a pubkey.

source

pub(crate) fn num_nodes(&self) -> usize

Returns number of known contact-infos (network size).

source

pub(crate) fn num_pubkeys(&self) -> usize

Returns number of unique pubkeys.

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub(crate) fn par_values( &self ) -> ParValues<'_, CrdsValueLabel, VersionedCrdsValue>

source

pub(crate) fn num_purged(&self) -> usize

source

pub(crate) fn purged(&self) -> impl IndexedParallelIterator<Item = Hash> + '_

source

pub(crate) fn trim_purged(&mut self, timestamp: u64)

Drops purged value hashes with timestamp less than the given one.

source

pub(crate) fn filter_bitmask( &self, mask: u64, mask_bits: u32 ) -> impl Iterator<Item = &VersionedCrdsValue>

Returns all crds values which the first ‘mask_bits’ of their hash value is equal to ‘mask’.

source

pub(crate) fn update_record_timestamp(&mut self, pubkey: &Pubkey, now: u64)

Update the timestamp’s of all the labels that are associated with Pubkey

source

pub fn find_old_labels( &self, thread_pool: &ThreadPool, now: u64, timeouts: &CrdsTimeouts<'_> ) -> Vec<CrdsValueLabel>

Find all the keys that are older or equal to the timeout.

  • timeouts - Pubkey specific timeouts with Pubkey::default() as the default timeout.
source

pub fn remove(&mut self, key: &CrdsValueLabel, now: u64)

source

pub(crate) fn should_trim(&self, cap: usize) -> bool

Returns true if the number of unique pubkeys in the table exceeds the given capacity (plus some margin). Allows skipping unnecessary calls to trim without obtaining a write lock on gossip.

source

pub(crate) fn trim( &mut self, cap: usize, keep: &[Pubkey], stakes: &HashMap<Pubkey, u64>, now: u64 ) -> Result<usize, CrdsError>

Trims the table by dropping all values associated with the pubkeys with the lowest stake, so that the number of unique pubkeys are bounded.

source

fn drop( &mut self, size: usize, keep: &[Pubkey], stakes: &HashMap<Pubkey, u64>, now: u64 ) -> Result<usize, CrdsError>

source

pub(crate) fn take_stats(&self) -> CrdsStats

Trait Implementations§

source§

impl Default for Crds

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Crds

§

impl Send for Crds

§

impl Sync for Crds

§

impl Unpin for Crds

§

impl UnwindSafe for Crds

Blanket Implementations§

source§

impl<T> AbiExample for T

source§

default fn example() -> T

source§

impl<T> AbiExample for T

source§

default fn example() -> T

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32 ) -> TaggedParser<'a, Implicit, Self, E>

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> TupleTree<T, ()> for T

§

const SIZE: Size = Size{ degree: 0, descendants: 0,}

§

fn descendants(_indirect_level: usize) -> usize

§

fn height() -> usize

§

fn preorder(self, f: &mut impl FnMut(Visit<T>))

§

fn preorder_with_size_hint(self, f: &mut impl FnMut(Visit<T>, Size))

§

fn postorder(self, f: &mut impl FnMut(Visit<T>))

§

fn postorder_with_size_hint(self, f: &mut impl FnMut(Visit<T>, Size))

§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more