coven_replication/sync/
status.rs1#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct DeviceActivity {
8 pub device_id: String,
9 pub author: String,
11 pub last_seq: u64,
13}
14
15pub(crate) fn other_device_activity(
19 commits: &[coven_protocol::store_commit::VerifiedStoreBatchCommit],
20 our_device_id: &str,
21) -> Vec<DeviceActivity> {
22 let mut other_devices: Vec<DeviceActivity> = Vec::new();
23
24 for commit in commits {
25 if commit.author().device_id.to_string() == our_device_id {
26 continue;
27 }
28
29 let activity = DeviceActivity {
30 device_id: commit.author().device_id.to_string(),
31 author: commit.author().author_pubkey.clone(),
32 last_seq: commit.reference().coord.sequence(),
33 };
34 match other_devices
35 .iter_mut()
36 .find(|current| current.device_id == activity.device_id)
37 {
38 Some(current) if current.last_seq < activity.last_seq => *current = activity,
39 Some(_) => {}
40 None => other_devices.push(activity),
41 }
42 }
43
44 other_devices
45}