1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use std::io::Result;
use crate::ids;
use chrono::{DateTime, Utc};
#[tonic::async_trait]
pub trait NetworkAppHandler {
async fn app_request(
&self,
node_id: &ids::node::Id,
request_id: u32,
deadline: DateTime<Utc>,
request: &[u8],
) -> Result<()>;
async fn app_request_failed(&self, node_id: &ids::node::Id, request_id: u32) -> Result<()>;
async fn app_response(
&self,
node_id: &ids::node::Id,
request_id: u32,
response: &[u8],
) -> Result<()>;
async fn app_gossip(&self, node_id: &ids::node::Id, msg: &[u8]) -> Result<()>;
}
#[tonic::async_trait]
pub trait CrossChainAppHandler {
async fn cross_chain_app_request(
&self,
chain_id: &ids::Id,
request_id: u32,
deadline: DateTime<Utc>,
request: &[u8],
) -> Result<()>;
async fn cross_chain_app_request_failed(
&self,
chain_id: &ids::Id,
request_id: u32,
) -> Result<()>;
async fn cross_chain_app_response(
&self,
chain_id: &ids::Id,
request_id: u32,
response: &[u8],
) -> Result<()>;
}
pub trait AppHandler: NetworkAppHandler + CrossChainAppHandler {}