use crate::{block, rpc};
use serde::{Deserialize, Serialize};
use std::ops::Range;
pub struct Request {
min: block::Height,
max: block::Height,
}
impl Request {
pub fn new(min: block::Height, max: block::Height) -> Self {
Self { min, max }
}
}
impl From<Range<block::Height>> for Request {
fn from(range: Range<block::Height>) -> Request {
Request::new(range.start, range.end)
}
}
impl rpc::Request for Request {
type Response = Response;
fn path(&self) -> rpc::request::Path {
format!("/block?minHeight={}&maxHeight={}", self.min, self.max)
.parse()
.unwrap()
}
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Response {
pub last_height: block::Height,
pub block_metas: Vec<block::Meta>,
}
impl rpc::Response for Response {}