implements generic lookups into gossip crds table (#18765)

This commit adds CrdsEntry trait which allows generic lookups into crds
table. For example to get ContactInfo or LowestSlot associated with a
Pubkey, the lookup code would be respectively:
   crds.get::<&ContactInfo>(pubkey)
   crds.get::<&LowestSlot>(pubkey)
This commit is contained in:
behzad nouri
2021-07-21 12:16:26 +00:00
committed by GitHub
parent 65152373de
commit bbd22f06f4
11 changed files with 204 additions and 108 deletions

View File

@@ -21,7 +21,7 @@ fn new_test_crds_value<R: Rng>(rng: &mut R) -> VersionedCrdsValue {
let label = value.label();
let mut crds = Crds::default();
crds.insert(value, timestamp()).unwrap();
crds.get(&label).cloned().unwrap()
crds.get::<&VersionedCrdsValue>(&label).cloned().unwrap()
}
fn bench_crds_shards_find(bencher: &mut Bencher, num_values: usize, mask_bits: u32) {