pub fn query_peer_density(
    env: EnvWrite,
    kitsune_space: Arc<kitsune_p2p::KitsuneSpace>,
    sgd_arc: SgdArc,
) -> ConductorResult<PeerDensity> {
    let now = now();
    let arcs = env.conn()?.p2p_list()?;
    let arcs = fallible_iterator::convert(arcs.into_iter().map(ConductorResult::Ok))
        .filter_map(|v| {
            if sgd_arc.contains(v.agent.get_loc()) {
                if v.space == kitsune_space && !is_expired(now, &v) {
                    Ok(Some(v.storage_arc))
                } else {
                    Ok(None)
                }
            } else {
                Ok(None)
            }
        })
        .collect()?;

    // contains is already checked in the iterator
    let bucket = SgdArcBucket::new_unchecked(sgd_arc, arcs);

    Ok(bucket.density())
}
/// Get the peer density an agent is currently seeing within
/// a given [`SgdArc`]
Get the peer density an agent is currently seeing within
a given [`SgdArc`]
Get the peer density an agent is currently seeing within a given [ ` SgdArc ` ]
pub fn query_peer_density(
    env: EnvWrite,
    kitsune_space: Arc<kitsune_p2p::KitsuneSpace>,
    sgd_arc: SgdArc,
) -> ConductorResult<PeerDensity> {
    let now = now();
    let arcs = env.conn()?.p2p_list()?;
    let arcs = fallible_iterator::convert(arcs.into_iter().map(ConductorResult::Ok))
        .filter_map(|v| {
            if sgd_arc.contains(v.agent.get_loc()) {
                if v.space == kitsune_space && !is_expired(now, &v) {
                    Ok(Some(v.storage_arc))
                } else {
                    Ok(None)
                }
            } else {
                Ok(None)
            }
        })
        .collect()?;
    // contains is already checked in the iterator
    let bucket = SgdArcBucket::new_unchecked(sgd_arc, arcs);
    Ok(bucket.density())
}
pub fn query_peer_density ( env : EnvWrite , kitsune_space : Arc < kitsune_p2p :: KitsuneSpace > , sgd_arc : SgdArc , ) -> ConductorResult < PeerDensity > { let now = now ( ) ; let arcs = env . conn ( ) ? . p2p_list ( ) ? ; let arcs = fallible_iterator :: convert ( arcs . into_iter ( ) . map ( ConductorResult :: Ok ) ) . filter_map ( | v | { if sgd_arc . contains ( v . agent . get_loc ( ) ) { if v . space == kitsune_space && ! is_expired ( now , & v ) { Ok ( Some ( v . storage_arc ) ) } else { Ok ( None ) } } else { Ok ( None ) } } ) . collect ( ) ? ; // contains is already checked in the iterator let bucket = SgdArcBucket :: new_unchecked ( sgd_arc , arcs ) ; Ok ( bucket . density ( ) ) }
Get the peer density an agent is currently seeing within
a given [`SgdArc`]
Get the peer density an agent is currently seeing within a given [ ` SgdArc ` ]
env
EnvWrite
kitsune_space
Arc<kitsune_p2p::KitsuneSpace>
sgd_arc
SgdArc
env
EnvWrite
kitsune_space
Arc<kitsune_p2p::KitsuneSpace>
sgd_arc
SgdArc