feat(mesh): show federated Archipelago nodes on the Mesh Map
Peers that opt in via a new "Share Location" toggle in Settings (server.set-location RPC) get plotted on other trusted peers' Mesh Map with a distinct Archy-logo marker, separate from raw LoRa radio peers. Location is persisted locally, carried in NodeStateSnapshot, and propagated through federation sync/delta like other node state. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
e3baaa5de3
commit
177b8a4338
@@ -506,6 +506,8 @@ mod tests {
|
||||
nostr_npub: None,
|
||||
own_fips_npub: None,
|
||||
federated_peers: Vec::new(),
|
||||
lat: None,
|
||||
lon: None,
|
||||
};
|
||||
|
||||
update_node_state(dir.path(), "did:key:z1", state)
|
||||
|
||||
@@ -208,6 +208,7 @@ async fn merge_transitive_peers(
|
||||
/// and route directly over FIPS from now on). Only peers we trust are
|
||||
/// shared — an Untrusted/Observer node should not be re-exported
|
||||
/// through us to the network.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn build_local_state(
|
||||
apps: Vec<AppStatus>,
|
||||
cpu: f64,
|
||||
@@ -221,6 +222,9 @@ pub fn build_local_state(
|
||||
nostr_npub: Option<String>,
|
||||
own_fips_npub: Option<String>,
|
||||
federated_peers: &[FederatedNode],
|
||||
// Only Some when the node has opted in via server.set-location's
|
||||
// `share` flag — see NodeStateSnapshot::lat/lon's doc comment.
|
||||
shared_location: Option<(f64, f64)>,
|
||||
) -> NodeStateSnapshot {
|
||||
let hints = federated_peers
|
||||
.iter()
|
||||
@@ -248,6 +252,8 @@ pub fn build_local_state(
|
||||
nostr_npub,
|
||||
own_fips_npub,
|
||||
federated_peers: hints,
|
||||
lat: shared_location.map(|(lat, _)| lat),
|
||||
lon: shared_location.map(|(_, lon)| lon),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,12 +347,14 @@ mod tests {
|
||||
None,
|
||||
None,
|
||||
&[],
|
||||
None,
|
||||
);
|
||||
assert_eq!(state.apps.len(), 1);
|
||||
assert_eq!(state.cpu_usage_percent, Some(25.5));
|
||||
assert_eq!(state.tor_active, Some(true));
|
||||
assert_eq!(state.node_name, Some("Test Node".to_string()));
|
||||
assert!(state.federated_peers.is_empty());
|
||||
assert_eq!(state.lat, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -392,7 +400,7 @@ mod tests {
|
||||
last_transport_at: None,
|
||||
},
|
||||
];
|
||||
let state = build_local_state(vec![], 0.0, 0, 0, 0, 0, 0, true, None, None, None, &peers);
|
||||
let state = build_local_state(vec![], 0.0, 0, 0, 0, 0, 0, true, None, None, None, &peers, None);
|
||||
assert_eq!(state.federated_peers.len(), 1);
|
||||
assert_eq!(state.federated_peers[0].did, "did:key:zTrusted");
|
||||
assert_eq!(
|
||||
|
||||
@@ -93,6 +93,14 @@ pub struct NodeStateSnapshot {
|
||||
/// re-export them in her own state snapshots).
|
||||
#[serde(default)]
|
||||
pub federated_peers: Vec<FederationPeerHint>,
|
||||
/// This node's own location, for the Mesh Map — only present when the
|
||||
/// sender has opted in via `server.set-location`'s `share` flag. Absent
|
||||
/// (not just null) for nodes that haven't opted in, so older receivers
|
||||
/// and the map's "no location shared" state both fall out naturally.
|
||||
#[serde(default)]
|
||||
pub lat: Option<f64>,
|
||||
#[serde(default)]
|
||||
pub lon: Option<f64>,
|
||||
}
|
||||
|
||||
/// Minimal peer summary shared via `NodeStateSnapshot.federated_peers`.
|
||||
|
||||
Reference in New Issue
Block a user