massa icon indicating copy to clipboard operation
massa copied to clipboard

More genericity in NodeInfo KnowledgeView

Open AureliaDolo opened this issue 2 years ago • 1 comments

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

AureliaDolo avatar Mar 09 '22 13:03 AureliaDolo

This issue is stale! (no activity for 60 days)

github-actions[bot] avatar May 08 '22 18:05 github-actions[bot]

This has been refactor with network refactoring and doesn't exist anymore.

AurelienFT avatar May 11 '23 11:05 AurelienFT