fix: federation peer-joined updates empty onion addresses
When a node was already known (via link-node) but had an empty onion address, the peer-joined handler returned early without updating the onion. Now it patches missing onion/pubkey fields on existing nodes. Also adds update_node() to federation storage and updates the architecture comparison doc with system resources, StartOS/umbrelOS tabs, Web5 section, and comparison view. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ mod types;
|
||||
// Re-export all public items so `crate::federation::*` continues to work.
|
||||
pub use invites::{accept_invite, create_invite};
|
||||
pub use storage::{
|
||||
add_node, load_nodes, remove_node, save_nodes, set_trust_level,
|
||||
add_node, load_nodes, remove_node, save_nodes, set_trust_level, update_node,
|
||||
};
|
||||
pub use sync::{build_local_state, deploy_to_peer, sync_with_peer};
|
||||
pub use types::{AppStatus, FederatedNode, NodeStateSnapshot, TrustLevel};
|
||||
|
||||
@@ -96,6 +96,27 @@ pub async fn set_trust_level(
|
||||
Ok(nodes)
|
||||
}
|
||||
|
||||
/// Update a federated node's metadata (onion, pubkey, name, last_seen).
|
||||
pub async fn update_node(data_dir: &Path, updated: &FederatedNode) -> Result<()> {
|
||||
let mut nodes = load_nodes(data_dir).await?;
|
||||
if let Some(node) = nodes.iter_mut().find(|n| n.did == updated.did) {
|
||||
if !updated.onion.is_empty() {
|
||||
node.onion = updated.onion.clone();
|
||||
}
|
||||
if !updated.pubkey.is_empty() {
|
||||
node.pubkey = updated.pubkey.clone();
|
||||
}
|
||||
if updated.name.is_some() {
|
||||
node.name = updated.name.clone();
|
||||
}
|
||||
if updated.last_seen.is_some() {
|
||||
node.last_seen = updated.last_seen.clone();
|
||||
}
|
||||
save_nodes(data_dir, &nodes).await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn update_node_state(
|
||||
data_dir: &Path,
|
||||
did: &str,
|
||||
|
||||
Reference in New Issue
Block a user