use async_trait::async_trait;
use committable::Commitment;
use hotshot_types::{
traits::{node_implementation::NodeType, signature_key::SignatureKey},
utils::BuilderCommitment,
vid::VidCommitment,
};
use super::{
block_info::{AvailableBlockData, AvailableBlockHeaderInput, AvailableBlockInfo},
builder::{BuildError, TransactionStatus},
};
#[async_trait]
pub trait BuilderDataSource<TYPES: NodeType> {
async fn available_blocks(
&self,
for_parent: &VidCommitment,
view_number: u64,
sender: TYPES::SignatureKey,
signature: &<TYPES::SignatureKey as SignatureKey>::PureAssembledSignatureType,
) -> Result<Vec<AvailableBlockInfo<TYPES>>, BuildError>;
async fn claim_block(
&self,
block_hash: &BuilderCommitment,
view_number: u64,
sender: TYPES::SignatureKey,
signature: &<TYPES::SignatureKey as SignatureKey>::PureAssembledSignatureType,
) -> Result<AvailableBlockData<TYPES>, BuildError>;
async fn claim_block_with_num_nodes(
&self,
block_hash: &BuilderCommitment,
view_number: u64,
sender: TYPES::SignatureKey,
signature: &<TYPES::SignatureKey as SignatureKey>::PureAssembledSignatureType,
num_nodes: usize,
) -> Result<AvailableBlockData<TYPES>, BuildError>;
async fn claim_block_header_input(
&self,
block_hash: &BuilderCommitment,
view_number: u64,
sender: TYPES::SignatureKey,
signature: &<TYPES::SignatureKey as SignatureKey>::PureAssembledSignatureType,
) -> Result<AvailableBlockHeaderInput<TYPES>, BuildError>;
async fn builder_address(&self) -> Result<TYPES::BuilderSignatureKey, BuildError>;
}
#[async_trait]
pub trait AcceptsTxnSubmits<I>
where
I: NodeType,
{
async fn submit_txns(
&self,
txns: Vec<<I as NodeType>::Transaction>,
) -> Result<Vec<Commitment<<I as NodeType>::Transaction>>, BuildError>;
async fn txn_status(
&self,
txn_hash: Commitment<<I as NodeType>::Transaction>,
) -> Result<TransactionStatus, BuildError>;
}