aura_agent/runtime/effects/
sync.rs1use super::AuraEffectSystem;
2use async_trait::async_trait;
3use aura_core::effects::SyncMetrics;
4use aura_core::types::identifiers::DeviceId;
5use aura_core::{AttestedOp, Hash32};
6use aura_protocol::effects::{BloomDigest, SyncEffects, SyncError};
7
8#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
9#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
10impl SyncEffects for AuraEffectSystem {
11 async fn sync_with_peer(&self, peer_id: DeviceId) -> Result<SyncMetrics, SyncError> {
12 self.sync_handler.sync_with_peer(peer_id).await
13 }
14
15 async fn get_oplog_digest(&self) -> Result<BloomDigest, SyncError> {
16 self.sync_handler.get_oplog_digest().await
17 }
18
19 async fn get_missing_ops(
20 &self,
21 remote_digest: &BloomDigest,
22 ) -> Result<Vec<AttestedOp>, SyncError> {
23 self.sync_handler.get_missing_ops(remote_digest).await
24 }
25
26 async fn request_ops_from_peer(
27 &self,
28 peer_id: DeviceId,
29 cids: Vec<Hash32>,
30 ) -> Result<Vec<AttestedOp>, SyncError> {
31 self.sync_handler.request_ops_from_peer(peer_id, cids).await
32 }
33
34 async fn merge_remote_ops(&self, ops: Vec<AttestedOp>) -> Result<(), SyncError> {
35 self.sync_handler.merge_remote_ops(ops).await
36 }
37
38 async fn announce_new_op(&self, cid: Hash32) -> Result<(), SyncError> {
39 self.sync_handler.announce_new_op(cid).await
40 }
41
42 async fn request_op(&self, peer_id: DeviceId, cid: Hash32) -> Result<AttestedOp, SyncError> {
43 self.sync_handler.request_op(peer_id, cid).await
44 }
45
46 async fn push_op_to_peers(
47 &self,
48 op: AttestedOp,
49 peers: Vec<DeviceId>,
50 ) -> Result<(), SyncError> {
51 self.sync_handler.merge_remote_ops(vec![op]).await?;
53 let _ = peers;
54 Ok(())
55 }
56
57 async fn get_connected_peers(&self) -> Result<Vec<DeviceId>, SyncError> {
58 Ok(Vec::new())
59 }
60}