massa
massa copied to clipboard
More genericity in NodeInfo KnowledgeView
Not sure about it but maybe we could try to have some generic struct (Im' open to suggestions regarding names :wink: )
struct Snapshot<U: impl PreHashed> {
known: Map<U, (bool, instant)>,
wanted: Map<U, instant>,
asked: Map<U, instant>,
}
impl SnapShot<U: impl Prehashed> {
/// if there are too many items, prune them
fn prune(&mut self, cfg: SnapshotCOnfig) {}
/// these three function would update the timestamps if needed and all the other updates too
fn insert_known(&mut self, item: U, knows: bool) {}
fn insert_wanted(&mut self, item: U) {}
fn insert_asked(&mut self, item: U) {}
// the remove functions too
fn knows(&self, item: U) -> bool {}
}
struct SnapshotConfig {
max_known_item_count: usize,
max_wanted_item_count: usize,
max_asked_item_count: usize,
}
struct NodeInfo {
operation_snapshot: Snapshot<OperationId>,
endorsement_snapshot: Snapshot<EndorsementId>,
block_snapshot: Snapshot<BlockId>,
..
}
Originally posted by @AureliaDolo in https://github.com/massalabs/massa/issues/2384#issuecomment-1061954932
This issue is stale! (no activity for 60 days)
This has been refactor with network refactoring and doesn't exist anymore.