gadget_common/module/
network.rs

1use crate::environments::GadgetEnvironment;
2use crate::Error;
3use async_trait::async_trait;
4use sp_core::ecdsa;
5
6#[async_trait]
7pub trait Network<Env: GadgetEnvironment>: Send + Sync + Clone + 'static {
8    async fn next_message(&self) -> Option<Env::ProtocolMessage>;
9    async fn send_message(&self, message: Env::ProtocolMessage) -> Result<(), Error>;
10
11    /// The ID of the king. Only relevant for ZkSaaS networks
12    fn greatest_authority_id(&self) -> Option<ecdsa::Public> {
13        None
14    }
15    /// If the network implementation requires a custom runtime, this function
16    /// should be manually implemented to keep the network alive
17    async fn run(self) -> Result<(), Error> {
18        Ok(())
19    }
20}