style: apply fmt to entire workspace

This commit is contained in:
Santiago Carmuega 2021-12-09 07:03:13 -03:00
parent 1b6cbbc095
commit 336d2400f4
23 changed files with 111 additions and 67 deletions

View file

@ -2,8 +2,11 @@ use net2::TcpStreamExt;
use pallas_machines::primitives::Point;
use std::net::TcpStream;
use pallas_blockfetch::BlockFetchClient;
use pallas_handshake::{MAINNET_MAGIC, n2n::{Client, VersionTable}};
use pallas_blockfetch::{BatchClient, NoopObserver};
use pallas_handshake::{
n2n::{Client, VersionTable},
MAINNET_MAGIC,
};
use pallas_machines::run_agent;
use pallas_multiplexer::Multiplexer;
@ -37,7 +40,7 @@ fn main() {
);
let mut bf_channel = muxer.use_channel(3);
let bf = BlockFetchClient::initial(range);
let bf = BatchClient::initial(range, NoopObserver {});
let bf_last = run_agent(bf, &mut bf_channel);
println!("{:?}", bf_last);
}

View file

@ -94,18 +94,25 @@ pub trait Observer {
}
}
#[derive(Debug)]
pub struct NoopObserver {}
impl Observer for NoopObserver {}
#[derive(Debug)]
pub struct BatchClient<O> where O: Observer {
pub struct BatchClient<O>
where
O: Observer,
{
pub state: State,
pub range: (Point, Point),
pub observer: O,
}
impl<O> BatchClient<O> where O: Observer {
impl<O> BatchClient<O>
where
O: Observer,
{
pub fn initial(range: (Point, Point), observer: O) -> Self {
Self {
state: State::Idle,
@ -128,7 +135,10 @@ impl<O> BatchClient<O> where O: Observer {
}
}
impl<O> Agent for BatchClient<O> where O: Observer {
impl<O> Agent for BatchClient<O>
where
O: Observer,
{
type Message = Message;
fn is_done(&self) -> bool {
@ -176,13 +186,19 @@ impl<O> Agent for BatchClient<O> where O: Observer {
}
#[derive(Debug)]
pub struct OnDemandClient<O> where O: Observer {
pub struct OnDemandClient<O>
where
O: Observer,
{
pub state: State,
pub requests: Receiver<Point>,
pub observer: O,
}
impl<O> OnDemandClient<O> where O: Observer {
impl<O> OnDemandClient<O>
where
O: Observer,
{
pub fn initial(requests: Receiver<Point>, observer: O) -> Self {
Self {
state: State::Idle,
@ -207,7 +223,10 @@ impl<O> OnDemandClient<O> where O: Observer {
}
}
impl<O> Agent for OnDemandClient<O> where O: Observer {
impl<O> Agent for OnDemandClient<O>
where
O: Observer,
{
type Message = Message;
// we're never done because we react to external work requests.