hotshot_types/traits/
auction_results_provider.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//! This module defines the interaction layer with the Solver via the [`AuctionResultsProvider`] trait,
8//! which handles connecting to, and fetching the allocation results from, the Solver.
9
10use anyhow::Result;
11use async_trait::async_trait;
12
13use super::node_implementation::NodeType;
14
15/// The AuctionResultsProvider trait is the sole source of Solver-originated state and interaction,
16/// and returns the results of the Solver's allocation via the associated type. The associated type,
17/// `AuctionResult`, also implements the `HasUrls` trait, which requires that the output
18/// type has the requisite fields available.
19#[async_trait]
20pub trait AuctionResultsProvider<TYPES: NodeType>: Send + Sync + Clone {
21    /// Fetches the auction result for a view. Does not cache the result,
22    /// subsequent calls will invoke additional wasted calls.
23    async fn fetch_auction_result(&self, view_number: TYPES::View) -> Result<TYPES::AuctionResult>;
24}