hotshot_builder_api/v0_1/
data_source.rs1use async_trait::async_trait;
8use committable::Commitment;
9use hotshot_types::{
10 data::VidCommitment,
11 traits::{node_implementation::NodeType, signature_key::SignatureKey},
12 utils::BuilderCommitment,
13};
14
15use super::{
16 block_info::{AvailableBlockData, AvailableBlockHeaderInputV1, AvailableBlockInfo},
17 builder::{BuildError, TransactionStatus},
18};
19
20#[async_trait]
21pub trait BuilderDataSource<TYPES: NodeType> {
22 async fn available_blocks(
24 &self,
25 for_parent: &VidCommitment,
26 view_number: u64,
27 sender: TYPES::SignatureKey,
28 signature: &<TYPES::SignatureKey as SignatureKey>::PureAssembledSignatureType,
29 ) -> Result<Vec<AvailableBlockInfo<TYPES>>, BuildError>;
30
31 async fn claim_block(
33 &self,
34 block_hash: &BuilderCommitment,
35 view_number: u64,
36 sender: TYPES::SignatureKey,
37 signature: &<TYPES::SignatureKey as SignatureKey>::PureAssembledSignatureType,
38 ) -> Result<AvailableBlockData<TYPES>, BuildError>;
39
40 async fn claim_block_with_num_nodes(
43 &self,
44 block_hash: &BuilderCommitment,
45 view_number: u64,
46 sender: TYPES::SignatureKey,
47 signature: &<TYPES::SignatureKey as SignatureKey>::PureAssembledSignatureType,
48 num_nodes: usize,
49 ) -> Result<AvailableBlockData<TYPES>, BuildError>;
50
51 async fn claim_block_header_input(
53 &self,
54 block_hash: &BuilderCommitment,
55 view_number: u64,
56 sender: TYPES::SignatureKey,
57 signature: &<TYPES::SignatureKey as SignatureKey>::PureAssembledSignatureType,
58 ) -> Result<AvailableBlockHeaderInputV1<TYPES>, BuildError>;
59
60 async fn builder_address(&self) -> Result<TYPES::BuilderSignatureKey, BuildError>;
62}
63
64#[async_trait]
65pub trait AcceptsTxnSubmits<I>
66where
67 I: NodeType,
68{
69 async fn submit_txns(
70 &self,
71 txns: Vec<<I as NodeType>::Transaction>,
72 ) -> Result<Vec<Commitment<<I as NodeType>::Transaction>>, BuildError>;
73
74 async fn txn_status(
75 &self,
76 txn_hash: Commitment<<I as NodeType>::Transaction>,
77 ) -> Result<TransactionStatus, BuildError>;
78}