use futures_util::future::BoxFuture;
use kaspa_muhash::MuHash;
use std::sync::Arc;
use crate::{
acceptance_data::AcceptanceData,
api::args::{TransactionValidationArgs, TransactionValidationBatchArgs},
block::{Block, BlockTemplate, TemplateBuildMode, TemplateTransactionSelector, VirtualStateApproxId},
blockstatus::BlockStatus,
coinbase::MinerData,
daa_score_timestamp::DaaScoreTimestamp,
errors::{
block::{BlockProcessResult, RuleError},
coinbase::CoinbaseResult,
consensus::ConsensusResult,
pruning::PruningImportResult,
tx::TxResult,
},
header::Header,
pruning::{PruningPointProof, PruningPointTrustedData, PruningPointsList},
trusted::{ExternalGhostdagData, TrustedBlock},
tx::{MutableTransaction, Transaction, TransactionOutpoint, UtxoEntry},
BlockHashSet, BlueWorkType, ChainPath,
};
use kaspa_hashes::Hash;
pub use self::stats::{BlockCount, ConsensusStats};
pub mod args;
pub mod counters;
pub mod stats;
pub type BlockValidationFuture = BoxFuture<'static, BlockProcessResult<BlockStatus>>;
pub struct BlockValidationFutures {
pub block_task: BlockValidationFuture,
pub virtual_state_task: BlockValidationFuture,
}
#[allow(unused_variables)]
pub trait ConsensusApi: Send + Sync {
fn build_block_template(
&self,
miner_data: MinerData,
tx_selector: Box<dyn TemplateTransactionSelector>,
build_mode: TemplateBuildMode,
) -> Result<BlockTemplate, RuleError> {
unimplemented!()
}
fn validate_and_insert_block(&self, block: Block) -> BlockValidationFutures {
unimplemented!()
}
fn validate_and_insert_trusted_block(&self, tb: TrustedBlock) -> BlockValidationFutures {
unimplemented!()
}
fn validate_mempool_transaction(&self, transaction: &mut MutableTransaction, args: &TransactionValidationArgs) -> TxResult<()> {
unimplemented!()
}
fn validate_mempool_transactions_in_parallel(
&self,
transactions: &mut [MutableTransaction],
args: &TransactionValidationBatchArgs,
) -> Vec<TxResult<()>> {
unimplemented!()
}
fn populate_mempool_transaction(&self, transaction: &mut MutableTransaction) -> TxResult<()> {
unimplemented!()
}
fn populate_mempool_transactions_in_parallel(&self, transactions: &mut [MutableTransaction]) -> Vec<TxResult<()>> {
unimplemented!()
}
fn calculate_transaction_compute_mass(&self, transaction: &Transaction) -> u64 {
unimplemented!()
}
fn calculate_transaction_storage_mass(&self, transaction: &MutableTransaction) -> Option<u64> {
unimplemented!()
}
fn get_stats(&self) -> ConsensusStats {
unimplemented!()
}
fn get_virtual_daa_score(&self) -> u64 {
unimplemented!()
}
fn get_virtual_bits(&self) -> u32 {
unimplemented!()
}
fn get_virtual_past_median_time(&self) -> u64 {
unimplemented!()
}
fn get_virtual_merge_depth_root(&self) -> Option<Hash> {
unimplemented!()
}
fn get_virtual_merge_depth_blue_work_threshold(&self) -> BlueWorkType {
unimplemented!()
}
fn get_sink(&self) -> Hash {
unimplemented!()
}
fn get_sink_timestamp(&self) -> u64 {
unimplemented!()
}
fn get_current_block_color(&self, hash: Hash) -> Option<bool> {
unimplemented!()
}
fn get_virtual_state_approx_id(&self) -> VirtualStateApproxId {
unimplemented!()
}
fn get_source(&self) -> Hash {
unimplemented!()
}
fn estimate_block_count(&self) -> BlockCount {
unimplemented!()
}
fn is_nearly_synced(&self) -> bool {
unimplemented!()
}
fn get_virtual_chain_from_block(&self, low: Hash, chain_path_added_limit: Option<usize>) -> ConsensusResult<ChainPath> {
unimplemented!()
}
fn get_chain_block_samples(&self) -> Vec<DaaScoreTimestamp> {
unimplemented!()
}
fn get_virtual_parents(&self) -> BlockHashSet {
unimplemented!()
}
fn get_virtual_parents_len(&self) -> usize {
unimplemented!()
}
fn get_virtual_utxos(
&self,
from_outpoint: Option<TransactionOutpoint>,
chunk_size: usize,
skip_first: bool,
) -> Vec<(TransactionOutpoint, UtxoEntry)> {
unimplemented!()
}
fn get_tips(&self) -> Vec<Hash> {
unimplemented!()
}
fn get_tips_len(&self) -> usize {
unimplemented!()
}
fn modify_coinbase_payload(&self, payload: Vec<u8>, miner_data: &MinerData) -> CoinbaseResult<Vec<u8>> {
unimplemented!()
}
fn calc_transaction_hash_merkle_root(&self, txs: &[Transaction], pov_daa_score: u64) -> Hash {
unimplemented!()
}
fn validate_pruning_proof(&self, proof: &PruningPointProof) -> PruningImportResult<()> {
unimplemented!()
}
fn apply_pruning_proof(&self, proof: PruningPointProof, trusted_set: &[TrustedBlock]) -> PruningImportResult<()> {
unimplemented!()
}
fn import_pruning_points(&self, pruning_points: PruningPointsList) {
unimplemented!()
}
fn append_imported_pruning_point_utxos(&self, utxoset_chunk: &[(TransactionOutpoint, UtxoEntry)], current_multiset: &mut MuHash) {
unimplemented!()
}
fn import_pruning_point_utxo_set(&self, new_pruning_point: Hash, imported_utxo_multiset: MuHash) -> PruningImportResult<()> {
unimplemented!()
}
fn is_chain_ancestor_of(&self, low: Hash, high: Hash) -> ConsensusResult<bool> {
unimplemented!()
}
fn get_hashes_between(&self, low: Hash, high: Hash, max_blocks: usize) -> ConsensusResult<(Vec<Hash>, Hash)> {
unimplemented!()
}
fn get_header(&self, hash: Hash) -> ConsensusResult<Arc<Header>> {
unimplemented!()
}
fn get_headers_selected_tip(&self) -> Hash {
unimplemented!()
}
fn get_antipast_from_pov(&self, hash: Hash, context: Hash, max_traversal_allowed: Option<u64>) -> ConsensusResult<Vec<Hash>> {
unimplemented!()
}
fn get_anticone(&self, hash: Hash) -> ConsensusResult<Vec<Hash>> {
unimplemented!()
}
fn get_pruning_point_proof(&self) -> Arc<PruningPointProof> {
unimplemented!()
}
fn create_virtual_selected_chain_block_locator(&self, low: Option<Hash>, high: Option<Hash>) -> ConsensusResult<Vec<Hash>> {
unimplemented!()
}
fn create_block_locator_from_pruning_point(&self, high: Hash, limit: usize) -> ConsensusResult<Vec<Hash>> {
unimplemented!()
}
fn pruning_point_headers(&self) -> Vec<Arc<Header>> {
unimplemented!()
}
fn get_pruning_point_anticone_and_trusted_data(&self) -> ConsensusResult<Arc<PruningPointTrustedData>> {
unimplemented!()
}
fn get_block(&self, hash: Hash) -> ConsensusResult<Block> {
unimplemented!()
}
fn get_block_even_if_header_only(&self, hash: Hash) -> ConsensusResult<Block> {
unimplemented!()
}
fn get_ghostdag_data(&self, hash: Hash) -> ConsensusResult<ExternalGhostdagData> {
unimplemented!()
}
fn get_block_children(&self, hash: Hash) -> Option<Vec<Hash>> {
unimplemented!()
}
fn get_block_parents(&self, hash: Hash) -> Option<Arc<Vec<Hash>>> {
unimplemented!()
}
fn get_block_status(&self, hash: Hash) -> Option<BlockStatus> {
unimplemented!()
}
fn get_block_acceptance_data(&self, hash: Hash) -> ConsensusResult<Arc<AcceptanceData>> {
unimplemented!()
}
fn get_blocks_acceptance_data(
&self,
hashes: &[Hash],
merged_blocks_limit: Option<usize>,
) -> ConsensusResult<Vec<Arc<AcceptanceData>>> {
unimplemented!()
}
fn is_chain_block(&self, hash: Hash) -> ConsensusResult<bool> {
unimplemented!()
}
fn get_pruning_point_utxos(
&self,
expected_pruning_point: Hash,
from_outpoint: Option<TransactionOutpoint>,
chunk_size: usize,
skip_first: bool,
) -> ConsensusResult<Vec<(TransactionOutpoint, UtxoEntry)>> {
unimplemented!()
}
fn get_missing_block_body_hashes(&self, high: Hash) -> ConsensusResult<Vec<Hash>> {
unimplemented!()
}
fn pruning_point(&self) -> Hash {
unimplemented!()
}
fn get_daa_window(&self, hash: Hash) -> ConsensusResult<Vec<Hash>> {
unimplemented!()
}
fn get_trusted_block_associated_ghostdag_data_block_hashes(&self, hash: Hash) -> ConsensusResult<Vec<Hash>> {
unimplemented!()
}
fn estimate_network_hashes_per_second(&self, start_hash: Option<Hash>, window_size: usize) -> ConsensusResult<u64> {
unimplemented!()
}
fn validate_pruning_points(&self) -> ConsensusResult<()> {
unimplemented!()
}
fn are_pruning_points_violating_finality(&self, pp_list: PruningPointsList) -> bool {
unimplemented!()
}
fn creation_timestamp(&self) -> u64 {
unimplemented!()
}
fn finality_point(&self) -> Hash {
unimplemented!()
}
}
pub type DynConsensus = Arc<dyn ConsensusApi>;