xfer
This commit is contained in:
parent
ff9b421631
commit
d527c4c8e7
16
.vscode/launch.json
vendored
16
.vscode/launch.json
vendored
@ -9,21 +9,31 @@
|
||||
"request": "attach",
|
||||
"name": "Attach to veilid-server",
|
||||
"program": "${workspaceFolder}/target/debug/veilid-server",
|
||||
"pid": "${command:pickMyProcess}"
|
||||
"pid": "${command:pickMyProcess}",
|
||||
"sourceLanguages": [
|
||||
"rust"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "attach",
|
||||
"name": "Attach to veilid-cli",
|
||||
"program": "${workspaceFolder}/target/debug/veilid-cli",
|
||||
"pid": "${command:pickMyProcess}"
|
||||
"pid": "${command:pickMyProcess}",
|
||||
"sourceLanguages": [
|
||||
"rust"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "attach",
|
||||
"name": "Attach to veilid-flutter example",
|
||||
"program": "${workspaceFolder}/veilid-flutter/example/build/linux/x64/debug/bundle/veilid_example",
|
||||
"pid": "${command:pickMyProcess}"
|
||||
"pid": "${command:pickMyProcess}",
|
||||
"sourceLanguages": [
|
||||
"rust",
|
||||
"dart"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
|
@ -344,11 +344,19 @@ impl RoutingTable {
|
||||
};
|
||||
|
||||
// Reconstruct all entries
|
||||
let inner = &mut *self.inner.write();
|
||||
|
||||
let mut all_entries: Vec<Arc<BucketEntry>> = Vec::with_capacity(all_entry_bytes.len());
|
||||
for entry_bytes in all_entry_bytes {
|
||||
let entryinner =
|
||||
from_rkyv(entry_bytes).wrap_err("failed to deserialize bucket entry")?;
|
||||
all_entries.push(Arc::new(BucketEntry::new_with_inner(entryinner)));
|
||||
let entry = Arc::new(BucketEntry::new_with_inner(entryinner));
|
||||
|
||||
// Keep strong reference in table
|
||||
all_entries.push(entry.clone());
|
||||
|
||||
// Keep all entries in weak table too
|
||||
inner.all_entries.insert(entry);
|
||||
}
|
||||
|
||||
// Validate serialized bucket map
|
||||
@ -364,8 +372,6 @@ impl RoutingTable {
|
||||
}
|
||||
|
||||
// Recreate buckets
|
||||
let inner = &mut *self.inner.write();
|
||||
|
||||
for (k, v) in serialized_bucket_map {
|
||||
let buckets = inner.buckets.get_mut(&k).unwrap();
|
||||
|
||||
|
@ -413,17 +413,25 @@ impl RoutingTableInner {
|
||||
}
|
||||
|
||||
/// Build the counts of entries per routing domain and crypto kind and cache them
|
||||
/// Only considers entries that have valid signed node info
|
||||
pub fn refresh_cached_entry_counts(&mut self) -> EntryCounts {
|
||||
self.live_entry_count.clear();
|
||||
let cur_ts = get_aligned_timestamp();
|
||||
self.with_entries_mut(cur_ts, BucketEntryState::Unreliable, |rti, entry| {
|
||||
entry.with_inner(|e| {
|
||||
if let Some(rd) = e.best_routing_domain(rti, RoutingDomainSet::all()) {
|
||||
for crypto_kind in e.crypto_kinds() {
|
||||
rti.live_entry_count
|
||||
.entry((rd, crypto_kind))
|
||||
.and_modify(|x| *x += 1)
|
||||
.or_insert(1);
|
||||
// Tally per routing domain and crypto kind
|
||||
for rd in RoutingDomain::all() {
|
||||
if let Some(sni) = e.signed_node_info(rd) {
|
||||
// Only consider entries that have valid signed node info in this domain
|
||||
if sni.has_any_signature() {
|
||||
// Tally
|
||||
for crypto_kind in e.crypto_kinds() {
|
||||
rti.live_entry_count
|
||||
.entry((rd, crypto_kind))
|
||||
.and_modify(|x| *x += 1)
|
||||
.or_insert(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -433,6 +441,7 @@ impl RoutingTableInner {
|
||||
}
|
||||
|
||||
/// Return the last cached entry counts
|
||||
/// Only considers entries that have valid signed node info
|
||||
pub fn cached_entry_counts(&self) -> EntryCounts {
|
||||
self.live_entry_count.clone()
|
||||
}
|
||||
@ -681,6 +690,7 @@ impl RoutingTableInner {
|
||||
let bucket_entry = self.unlocked_inner.calculate_bucket_index(&first_node_id);
|
||||
let bucket = self.get_bucket_mut(bucket_entry);
|
||||
let new_entry = bucket.add_new_entry(first_node_id.value);
|
||||
self.all_entries.insert(new_entry.clone());
|
||||
self.unlocked_inner.kick_queue.lock().insert(bucket_entry);
|
||||
|
||||
// Update the other bucket entries with the remaining node ids
|
||||
|
@ -27,7 +27,6 @@ pub type ValueSeqNum = u32;
|
||||
/// FOURCC code
|
||||
#[derive(
|
||||
Copy,
|
||||
Debug,
|
||||
Default,
|
||||
Clone,
|
||||
Hash,
|
||||
@ -61,6 +60,12 @@ impl fmt::Display for FourCC {
|
||||
write!(f, "{}", String::from_utf8_lossy(&self.0))
|
||||
}
|
||||
}
|
||||
impl fmt::Debug for FourCC {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
|
||||
write!(f, "{}", String::from_utf8_lossy(&self.0))
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for FourCC {
|
||||
type Err = VeilidAPIError;
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
|
Loading…
Reference in New Issue
Block a user