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