coven_replication/sync/
status.rs1use super::store::VerifiedStoreDeviceHead;
6
7#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct DeviceActivity {
10 pub device_id: String,
11 pub author: String,
14 pub last_seq: u64,
16}
17
18pub(crate) fn other_device_activity(
22 heads: &[VerifiedStoreDeviceHead],
23 our_device_id: &str,
24) -> Vec<DeviceActivity> {
25 let mut other_devices: Vec<DeviceActivity> = Vec::new();
26
27 for head in heads {
28 if head.author.device_id.to_string() == our_device_id {
29 continue;
30 }
31
32 let activity = DeviceActivity {
33 device_id: head.author.device_id.to_string(),
34 author: head.author.author_pubkey.clone(),
35 last_seq: head.head.slot_sequence(),
36 };
37 match other_devices
38 .iter_mut()
39 .find(|current| current.device_id == activity.device_id)
40 {
41 Some(current) if current.last_seq < activity.last_seq => *current = activity,
42 Some(_) => {}
43 None => other_devices.push(activity),
44 }
45 }
46
47 other_devices
48}