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
impl Crds
sourcepub(crate) fn upserts(&self, value: &CrdsValue) -> bool
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.
pub fn insert( &mut self, value: CrdsValue, now: u64, route: GossipRoute ) -> Result<(), CrdsError>
pub fn get<'a, 'b, V>(&'a self, key: V::Key) -> Option<V>where V: CrdsEntry<'a, 'b>,
pub(crate) fn get_shred_version(&self, pubkey: &Pubkey) -> Option<u16>
sourcepub(crate) fn get_nodes(&self) -> impl Iterator<Item = &VersionedCrdsValue>
pub(crate) fn get_nodes(&self) -> impl Iterator<Item = &VersionedCrdsValue>
Returns all entries which are ContactInfo.
sourcepub(crate) fn get_nodes_contact_info(
&self
) -> impl Iterator<Item = &ContactInfo>
pub(crate) fn get_nodes_contact_info( &self ) -> impl Iterator<Item = &ContactInfo>
Returns ContactInfo of all known nodes.
sourcepub(crate) fn get_votes<'a>(
&'a self,
cursor: &'a mut Cursor
) -> impl Iterator<Item = &'a VersionedCrdsValue>
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.
sourcepub(crate) fn get_epoch_slots<'a>(
&'a self,
cursor: &'a mut Cursor
) -> impl Iterator<Item = &'a VersionedCrdsValue>
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.
sourcepub(crate) fn get_duplicate_shreds<'a>(
&'a self,
cursor: &'a mut Cursor
) -> impl Iterator<Item = &'a VersionedCrdsValue>
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.
sourcepub(crate) fn get_entries<'a>(
&'a self,
cursor: &'a mut Cursor
) -> impl Iterator<Item = &'a VersionedCrdsValue>
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.
sourcepub(crate) fn get_records(
&self,
pubkey: &Pubkey
) -> impl Iterator<Item = &VersionedCrdsValue>
pub(crate) fn get_records( &self, pubkey: &Pubkey ) -> impl Iterator<Item = &VersionedCrdsValue>
Returns all records associated with a pubkey.
sourcepub(crate) fn num_pubkeys(&self) -> usize
pub(crate) fn num_pubkeys(&self) -> usize
Returns number of unique pubkeys.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub(crate) fn par_values( &self ) -> ParValues<'_, CrdsValueLabel, VersionedCrdsValue>
pub(crate) fn num_purged(&self) -> usize
pub(crate) fn purged(&self) -> impl IndexedParallelIterator<Item = Hash> + '_
sourcepub(crate) fn trim_purged(&mut self, timestamp: u64)
pub(crate) fn trim_purged(&mut self, timestamp: u64)
Drops purged value hashes with timestamp less than the given one.
sourcepub(crate) fn filter_bitmask(
&self,
mask: u64,
mask_bits: u32
) -> impl Iterator<Item = &VersionedCrdsValue>
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’.
sourcepub(crate) fn update_record_timestamp(&mut self, pubkey: &Pubkey, now: u64)
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
sourcepub fn find_old_labels(
&self,
thread_pool: &ThreadPool,
now: u64,
timeouts: &CrdsTimeouts<'_>
) -> Vec<CrdsValueLabel>
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.
pub fn remove(&mut self, key: &CrdsValueLabel, now: u64)
sourcepub(crate) fn should_trim(&self, cap: usize) -> bool
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.
sourcepub(crate) fn trim(
&mut self,
cap: usize,
keep: &[Pubkey],
stakes: &HashMap<Pubkey, u64>,
now: u64
) -> Result<usize, CrdsError>
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.
fn drop( &mut self, size: usize, keep: &[Pubkey], stakes: &HashMap<Pubkey, u64>, now: u64 ) -> Result<usize, CrdsError>
pub(crate) fn take_stats(&self) -> CrdsStats
Trait Implementations§
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§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere T: 'a,
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> 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request