diff --git a/core/lib/via_btc_client/src/indexer/mod.rs b/core/lib/via_btc_client/src/indexer/mod.rs index 8b137891791f..c3e55a0c145d 100644 --- a/core/lib/via_btc_client/src/indexer/mod.rs +++ b/core/lib/via_btc_client/src/indexer/mod.rs @@ -1 +1,43 @@ +use async_trait::async_trait; +use bitcoin::{BlockHash, Network}; +use crate::{ + traits::{BitcoinIndexerOpt, BitcoinRpc}, + types::{BitcoinClientResult, BitcoinInscriptionIndexerResult}, +}; + +#[allow(unused)] +pub struct BitcoinInscriptionIndexer { + pub rpc: Box, + network: Network, +} + +#[async_trait] +impl BitcoinIndexerOpt for BitcoinInscriptionIndexer { + async fn new() -> BitcoinClientResult + where + Self: Sized, + { + todo!() + } + + async fn process_blocks( + &self, + starting_block: u128, + ending_block: u128, + ) -> BitcoinInscriptionIndexerResult> { + todo!() + } + + async fn process_block(&self, block: u128) -> BitcoinInscriptionIndexerResult> { + todo!() + } + + async fn are_blocks_connected( + &self, + parent_hash: &BlockHash, + child_hash: &BlockHash, + ) -> BitcoinInscriptionIndexerResult { + todo!() + } +} diff --git a/core/lib/via_btc_client/src/traits.rs b/core/lib/via_btc_client/src/traits.rs index 10f4046bf874..4ae998465d9d 100644 --- a/core/lib/via_btc_client/src/traits.rs +++ b/core/lib/via_btc_client/src/traits.rs @@ -1,5 +1,5 @@ use async_trait::async_trait; -use bitcoin::{Address, Block, OutPoint, Transaction, TxOut, Txid}; +use bitcoin::{Address, Block, BlockHash, OutPoint, Transaction, TxOut, Txid}; use crate::types; @@ -90,19 +90,23 @@ pub trait BitcoinInscriber: Send + Sync { #[allow(dead_code)] #[async_trait] -pub trait BitcoinInscriptionIndexer: Send + Sync { - async fn new(config: &str) -> types::BitcoinInscriptionIndexerResult +pub trait BitcoinIndexerOpt: Send + Sync { + async fn new() -> types::BitcoinInscriptionIndexerResult where Self: Sized; - async fn get_inscription_messages( + async fn process_blocks( &self, starting_block: u128, ending_block: u128, ) -> types::BitcoinInscriptionIndexerResult>; - async fn get_specific_block_inscription_messages( + async fn process_block(&self, block: u128) + -> types::BitcoinInscriptionIndexerResult>; + + async fn are_blocks_connected( &self, - block_height: u128, - ) -> types::BitcoinInscriptionIndexerResult>; + parent_hash: &BlockHash, + child_hash: &BlockHash, + ) -> types::BitcoinInscriptionIndexerResult; } #[allow(dead_code)]