kaspa_consensus_core/api/
mod.rs1use futures_util::future::BoxFuture;
2use kaspa_muhash::MuHash;
3use std::sync::Arc;
4
5use crate::{
6 acceptance_data::AcceptanceData,
7 api::args::{TransactionValidationArgs, TransactionValidationBatchArgs},
8 block::{Block, BlockTemplate, TemplateBuildMode, TemplateTransactionSelector, VirtualStateApproxId},
9 blockstatus::BlockStatus,
10 coinbase::MinerData,
11 daa_score_timestamp::DaaScoreTimestamp,
12 errors::{
13 block::{BlockProcessResult, RuleError},
14 coinbase::CoinbaseResult,
15 consensus::ConsensusResult,
16 pruning::PruningImportResult,
17 tx::TxResult,
18 },
19 header::Header,
20 pruning::{PruningPointProof, PruningPointTrustedData, PruningPointsList},
21 trusted::{ExternalGhostdagData, TrustedBlock},
22 tx::{MutableTransaction, Transaction, TransactionOutpoint, UtxoEntry},
23 BlockHashSet, BlueWorkType, ChainPath,
24};
25use kaspa_hashes::Hash;
26
27pub use self::stats::{BlockCount, ConsensusStats};
28
29pub mod args;
30pub mod counters;
31pub mod stats;
32
33pub type BlockValidationFuture = BoxFuture<'static, BlockProcessResult<BlockStatus>>;
34
35pub struct BlockValidationFutures {
37 pub block_task: BlockValidationFuture,
39
40 pub virtual_state_task: BlockValidationFuture,
44}
45
46#[allow(unused_variables)]
48pub trait ConsensusApi: Send + Sync {
49 fn build_block_template(
50 &self,
51 miner_data: MinerData,
52 tx_selector: Box<dyn TemplateTransactionSelector>,
53 build_mode: TemplateBuildMode,
54 ) -> Result<BlockTemplate, RuleError> {
55 unimplemented!()
56 }
57
58 fn validate_and_insert_block(&self, block: Block) -> BlockValidationFutures {
59 unimplemented!()
60 }
61
62 fn validate_and_insert_trusted_block(&self, tb: TrustedBlock) -> BlockValidationFutures {
63 unimplemented!()
64 }
65
66 fn validate_mempool_transaction(&self, transaction: &mut MutableTransaction, args: &TransactionValidationArgs) -> TxResult<()> {
69 unimplemented!()
70 }
71
72 fn validate_mempool_transactions_in_parallel(
75 &self,
76 transactions: &mut [MutableTransaction],
77 args: &TransactionValidationBatchArgs,
78 ) -> Vec<TxResult<()>> {
79 unimplemented!()
80 }
81
82 fn populate_mempool_transaction(&self, transaction: &mut MutableTransaction) -> TxResult<()> {
84 unimplemented!()
85 }
86
87 fn populate_mempool_transactions_in_parallel(&self, transactions: &mut [MutableTransaction]) -> Vec<TxResult<()>> {
89 unimplemented!()
90 }
91
92 fn calculate_transaction_compute_mass(&self, transaction: &Transaction) -> u64 {
93 unimplemented!()
94 }
95
96 fn calculate_transaction_storage_mass(&self, transaction: &MutableTransaction) -> Option<u64> {
97 unimplemented!()
98 }
99
100 fn get_stats(&self) -> ConsensusStats {
102 unimplemented!()
103 }
104
105 fn get_virtual_daa_score(&self) -> u64 {
106 unimplemented!()
107 }
108
109 fn get_virtual_bits(&self) -> u32 {
110 unimplemented!()
111 }
112
113 fn get_virtual_past_median_time(&self) -> u64 {
114 unimplemented!()
115 }
116
117 fn get_virtual_merge_depth_root(&self) -> Option<Hash> {
118 unimplemented!()
119 }
120
121 fn get_virtual_merge_depth_blue_work_threshold(&self) -> BlueWorkType {
125 unimplemented!()
126 }
127
128 fn get_sink(&self) -> Hash {
129 unimplemented!()
130 }
131
132 fn get_sink_timestamp(&self) -> u64 {
133 unimplemented!()
134 }
135
136 fn get_current_block_color(&self, hash: Hash) -> Option<bool> {
137 unimplemented!()
138 }
139
140 fn get_virtual_state_approx_id(&self) -> VirtualStateApproxId {
141 unimplemented!()
142 }
143
144 fn get_source(&self) -> Hash {
146 unimplemented!()
147 }
148
149 fn estimate_block_count(&self) -> BlockCount {
150 unimplemented!()
151 }
152
153 fn is_nearly_synced(&self) -> bool {
157 unimplemented!()
158 }
159
160 fn get_virtual_chain_from_block(&self, low: Hash, chain_path_added_limit: Option<usize>) -> ConsensusResult<ChainPath> {
166 unimplemented!()
167 }
168
169 fn get_chain_block_samples(&self) -> Vec<DaaScoreTimestamp> {
170 unimplemented!()
171 }
172
173 fn get_virtual_parents(&self) -> BlockHashSet {
174 unimplemented!()
175 }
176
177 fn get_virtual_parents_len(&self) -> usize {
178 unimplemented!()
179 }
180
181 fn get_virtual_utxos(
182 &self,
183 from_outpoint: Option<TransactionOutpoint>,
184 chunk_size: usize,
185 skip_first: bool,
186 ) -> Vec<(TransactionOutpoint, UtxoEntry)> {
187 unimplemented!()
188 }
189
190 fn get_tips(&self) -> Vec<Hash> {
191 unimplemented!()
192 }
193
194 fn get_tips_len(&self) -> usize {
195 unimplemented!()
196 }
197
198 fn modify_coinbase_payload(&self, payload: Vec<u8>, miner_data: &MinerData) -> CoinbaseResult<Vec<u8>> {
199 unimplemented!()
200 }
201
202 fn calc_transaction_hash_merkle_root(&self, txs: &[Transaction], pov_daa_score: u64) -> Hash {
203 unimplemented!()
204 }
205
206 fn validate_pruning_proof(&self, proof: &PruningPointProof) -> PruningImportResult<()> {
207 unimplemented!()
208 }
209
210 fn apply_pruning_proof(&self, proof: PruningPointProof, trusted_set: &[TrustedBlock]) -> PruningImportResult<()> {
211 unimplemented!()
212 }
213
214 fn import_pruning_points(&self, pruning_points: PruningPointsList) {
215 unimplemented!()
216 }
217
218 fn append_imported_pruning_point_utxos(&self, utxoset_chunk: &[(TransactionOutpoint, UtxoEntry)], current_multiset: &mut MuHash) {
219 unimplemented!()
220 }
221
222 fn import_pruning_point_utxo_set(&self, new_pruning_point: Hash, imported_utxo_multiset: MuHash) -> PruningImportResult<()> {
223 unimplemented!()
224 }
225
226 fn is_chain_ancestor_of(&self, low: Hash, high: Hash) -> ConsensusResult<bool> {
227 unimplemented!()
228 }
229
230 fn get_hashes_between(&self, low: Hash, high: Hash, max_blocks: usize) -> ConsensusResult<(Vec<Hash>, Hash)> {
231 unimplemented!()
232 }
233
234 fn get_header(&self, hash: Hash) -> ConsensusResult<Arc<Header>> {
235 unimplemented!()
236 }
237
238 fn get_headers_selected_tip(&self) -> Hash {
239 unimplemented!()
240 }
241
242 fn get_antipast_from_pov(&self, hash: Hash, context: Hash, max_traversal_allowed: Option<u64>) -> ConsensusResult<Vec<Hash>> {
246 unimplemented!()
247 }
248
249 fn get_anticone(&self, hash: Hash) -> ConsensusResult<Vec<Hash>> {
251 unimplemented!()
252 }
253
254 fn get_pruning_point_proof(&self) -> Arc<PruningPointProof> {
255 unimplemented!()
256 }
257
258 fn create_virtual_selected_chain_block_locator(&self, low: Option<Hash>, high: Option<Hash>) -> ConsensusResult<Vec<Hash>> {
259 unimplemented!()
260 }
261
262 fn create_block_locator_from_pruning_point(&self, high: Hash, limit: usize) -> ConsensusResult<Vec<Hash>> {
263 unimplemented!()
264 }
265
266 fn pruning_point_headers(&self) -> Vec<Arc<Header>> {
267 unimplemented!()
268 }
269
270 fn get_pruning_point_anticone_and_trusted_data(&self) -> ConsensusResult<Arc<PruningPointTrustedData>> {
271 unimplemented!()
272 }
273
274 fn get_block(&self, hash: Hash) -> ConsensusResult<Block> {
275 unimplemented!()
276 }
277
278 fn get_block_even_if_header_only(&self, hash: Hash) -> ConsensusResult<Block> {
279 unimplemented!()
280 }
281
282 fn get_ghostdag_data(&self, hash: Hash) -> ConsensusResult<ExternalGhostdagData> {
283 unimplemented!()
284 }
285
286 fn get_block_children(&self, hash: Hash) -> Option<Vec<Hash>> {
287 unimplemented!()
288 }
289
290 fn get_block_parents(&self, hash: Hash) -> Option<Arc<Vec<Hash>>> {
291 unimplemented!()
292 }
293
294 fn get_block_status(&self, hash: Hash) -> Option<BlockStatus> {
295 unimplemented!()
296 }
297
298 fn get_block_acceptance_data(&self, hash: Hash) -> ConsensusResult<Arc<AcceptanceData>> {
299 unimplemented!()
300 }
301
302 fn get_blocks_acceptance_data(
306 &self,
307 hashes: &[Hash],
308 merged_blocks_limit: Option<usize>,
309 ) -> ConsensusResult<Vec<Arc<AcceptanceData>>> {
310 unimplemented!()
311 }
312
313 fn is_chain_block(&self, hash: Hash) -> ConsensusResult<bool> {
314 unimplemented!()
315 }
316
317 fn get_pruning_point_utxos(
318 &self,
319 expected_pruning_point: Hash,
320 from_outpoint: Option<TransactionOutpoint>,
321 chunk_size: usize,
322 skip_first: bool,
323 ) -> ConsensusResult<Vec<(TransactionOutpoint, UtxoEntry)>> {
324 unimplemented!()
325 }
326
327 fn get_missing_block_body_hashes(&self, high: Hash) -> ConsensusResult<Vec<Hash>> {
328 unimplemented!()
329 }
330
331 fn pruning_point(&self) -> Hash {
332 unimplemented!()
333 }
334
335 fn get_daa_window(&self, hash: Hash) -> ConsensusResult<Vec<Hash>> {
337 unimplemented!()
338 }
339
340 fn get_trusted_block_associated_ghostdag_data_block_hashes(&self, hash: Hash) -> ConsensusResult<Vec<Hash>> {
343 unimplemented!()
344 }
345
346 fn estimate_network_hashes_per_second(&self, start_hash: Option<Hash>, window_size: usize) -> ConsensusResult<u64> {
347 unimplemented!()
348 }
349
350 fn validate_pruning_points(&self) -> ConsensusResult<()> {
351 unimplemented!()
352 }
353
354 fn are_pruning_points_violating_finality(&self, pp_list: PruningPointsList) -> bool {
355 unimplemented!()
356 }
357
358 fn creation_timestamp(&self) -> u64 {
359 unimplemented!()
360 }
361
362 fn finality_point(&self) -> Hash {
363 unimplemented!()
364 }
365}
366
367pub type DynConsensus = Arc<dyn ConsensusApi>;