Skip to content

Commit

Permalink
Implement send methods
Browse files Browse the repository at this point in the history
  • Loading branch information
danielSanchezQ committed Sep 7, 2023
1 parent 17fd5af commit 74d89ea
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions nomos-services/data-availability/src/network/adapters/libp2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ where
},
)))
}

async fn send<E: Serialize>(&self, data: E) -> Result<(), DynError> {
let message = wire::serialize(&data)?.into_boxed_slice();
self.network_relay
.send(NetworkMsg::Process(Command::Broadcast {
topic: NOMOS_DA_TOPIC.to_string(),
message,
}))
.await
.map_err(|(e, _)| Box::new(e) as DynError)
}
}

#[async_trait::async_trait]
Expand Down Expand Up @@ -93,10 +104,10 @@ where
}

async fn send_attestation(&self, attestation: Self::Attestation) -> Result<(), DynError> {
todo!()
self.send(attestation).await
}

async fn send_blob(&self, blob: Self::Blob) -> Result<(), DynError> {
todo!()
self.send(blob).await
}
}

0 comments on commit 74d89ea

Please sign in to comment.