use std::io::Result;
use crate::{choices::status::Status, ids::Id};
#[tonic::async_trait]
pub trait Block: Decidable + Initializer + StatusWriter + Sync + Send {
async fn bytes(&self) -> &[u8];
async fn to_bytes(&self) -> Result<Vec<u8>>;
async fn height(&self) -> u64;
async fn timestamp(&self) -> u64;
async fn parent(&self) -> Id;
async fn verify(&mut self) -> Result<()>;
}
#[tonic::async_trait]
pub trait Decidable {
async fn id(&self) -> Id;
async fn status(&self) -> Status;
async fn accept(&mut self) -> Result<()>;
async fn reject(&mut self) -> Result<()>;
}
#[tonic::async_trait]
pub trait Initializer {
async fn init(&mut self, bytes: &[u8], status: Status) -> Result<()>;
}
#[tonic::async_trait]
pub trait StatusWriter {
async fn set_status(&mut self, status: Status);
}