Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
feat: basic lib indexer structure [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
steph-rs committed Aug 6, 2024
1 parent 68142c5 commit 23ed6e5
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 7 deletions.
42 changes: 42 additions & 0 deletions core/lib/via_btc_client/src/indexer/mod.rs
Original file line number Diff line number Diff line change
@@ -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<dyn BitcoinRpc>,
network: Network,
}

#[async_trait]
impl BitcoinIndexerOpt for BitcoinInscriptionIndexer {
async fn new() -> BitcoinClientResult<Self>
where
Self: Sized,
{
todo!()
}

async fn process_blocks(
&self,
starting_block: u128,
ending_block: u128,
) -> BitcoinInscriptionIndexerResult<Vec<&str>> {
todo!()
}

async fn process_block(&self, block: u128) -> BitcoinInscriptionIndexerResult<Vec<&str>> {
todo!()
}

async fn are_blocks_connected(
&self,
parent_hash: &BlockHash,
child_hash: &BlockHash,
) -> BitcoinInscriptionIndexerResult<bool> {
todo!()
}
}
18 changes: 11 additions & 7 deletions core/lib/via_btc_client/src/traits.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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<Self>
pub trait BitcoinIndexerOpt: Send + Sync {
async fn new() -> types::BitcoinInscriptionIndexerResult<Self>
where
Self: Sized;
async fn get_inscription_messages(
async fn process_blocks(
&self,
starting_block: u128,
ending_block: u128,
) -> types::BitcoinInscriptionIndexerResult<Vec<&str>>;
async fn get_specific_block_inscription_messages(
async fn process_block(&self, block: u128)
-> types::BitcoinInscriptionIndexerResult<Vec<&str>>;

async fn are_blocks_connected(
&self,
block_height: u128,
) -> types::BitcoinInscriptionIndexerResult<Vec<&str>>;
parent_hash: &BlockHash,
child_hash: &BlockHash,
) -> types::BitcoinInscriptionIndexerResult<bool>;
}

#[allow(dead_code)]
Expand Down

0 comments on commit 23ed6e5

Please sign in to comment.