hotshot_types/traits/leaf_fetcher_network.rs
1// Copyright (c) 2021-2024 Espresso Systems (espressosys.com)
2// This file is part of the HotShot repository.
3
4// You should have received a copy of the MIT License
5// along with the HotShot repository. If not, see <https://mit-license.org/>.
6
7//! Network surface used by the test `Leaf2Fetcher` to send catchup
8//! request/response messages. The new-protocol routes it through its
9//! `Coordinator` instead of holding a second handle to the network.
10
11use async_trait::async_trait;
12
13use crate::{data::ViewNumber, traits::node_implementation::NodeType};
14
15/// Operations the test `Leaf2Fetcher` needs to drive epoch catchup.
16///
17/// Both methods send a serialized payload to a single recipient. The
18/// request/response split is for routing flexibility — implementations may
19/// dispatch them differently (e.g. through different queues).
20#[async_trait]
21pub trait LeafFetcherNetwork<TYPES: NodeType>: Send + Sync + 'static {
22 async fn send_leaf_request(
23 &self,
24 view: ViewNumber,
25 payload: Vec<u8>,
26 recipient: TYPES::SignatureKey,
27 ) -> anyhow::Result<()>;
28
29 async fn send_leaf_response(
30 &self,
31 view: ViewNumber,
32 payload: Vec<u8>,
33 recipient: TYPES::SignatureKey,
34 ) -> anyhow::Result<()>;
35}