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
use std::io::Result;
use crate::{
ids::Id,
subnet::rpc::{consensus::snowman, snow::engine::common::vm::Vm},
};
#[tonic::async_trait]
pub trait ChainVm: Vm + Getter + Parser {
async fn build_block(&self) -> Result<Box<dyn snowman::Block + Send + Sync>>;
async fn issue_tx(&self) -> Result<Box<dyn snowman::Block + Send + Sync>>;
async fn set_preference(&self, id: Id) -> Result<()>;
async fn last_accepted(&self) -> Result<Id>;
}
#[tonic::async_trait]
pub trait Getter {
async fn get_block(&self, id: Id) -> Result<Box<dyn snowman::Block + Send + Sync>>;
}
#[tonic::async_trait]
pub trait Parser {
async fn parse_block(&self, bytes: &[u8]) -> Result<Box<dyn snowman::Block + Send + Sync>>;
}