pub trait BlockchainInterface {
    type Error: Error + Send + Sync + 'static;

Show 22 methods // Required methods fn get_block_hash(&self, height: u32) -> Result<BlockHash, Self::Error>; fn get_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Self::Error>; fn get_height(&self) -> Result<u32, Self::Error>; fn broadcast(&self, tx: &Transaction) -> Result<(), Self::Error>; fn estimate_fee(&self, target: usize) -> Result<f64, Self::Error>; fn get_block(&self, hash: &BlockHash) -> Result<Block, Self::Error>; fn get_best_block(&self) -> Result<(u32, BlockHash), Self::Error>; fn get_block_header( &self, hash: &BlockHash ) -> Result<BlockHeader, Self::Error>; fn subscribe(&self, tx: Arc<dyn BlockConsumer>); fn is_in_idb(&self) -> bool; fn get_unbroadcasted(&self) -> Vec<Transaction>; fn is_coinbase_mature( &self, height: u32, block: BlockHash ) -> Result<bool, Self::Error>; fn get_block_locator(&self) -> Result<Vec<BlockHash>, Self::Error>; fn get_block_locator_for_tip( &self, tip: BlockHash ) -> Result<Vec<BlockHash>, BlockchainError>; fn get_validation_index(&self) -> Result<u32, Self::Error>; fn rescan(&self, start_height: u32) -> Result<(), Self::Error>; fn get_rescan_index(&self) -> Option<u32>; fn get_block_height( &self, hash: &BlockHash ) -> Result<Option<u32>, Self::Error>; fn update_acc( &self, acc: Stump, block: UtreexoBlock, height: u32, proof: Proof, del_hashes: Vec<Hash> ) -> Result<Stump, Self::Error>; fn get_chain_tips(&self) -> Result<Vec<BlockHash>, Self::Error>; fn validate_block( &self, block: &Block, proof: Proof, inputs: HashMap<OutPoint, TxOut>, del_hashes: Vec<Hash>, acc: Stump ) -> Result<(), Self::Error>; fn get_fork_point(&self, block: BlockHash) -> Result<BlockHash, Self::Error>;
}
Expand description

This trait is the main interface between our blockchain backend and other services. It’ll be useful for transitioning from rpc to a p2p based node

Required Associated Types§

source

type Error: Error + Send + Sync + 'static

Required Methods§

source

fn get_block_hash(&self, height: u32) -> Result<BlockHash, Self::Error>

Returns the block with a given height in our current tip.

source

fn get_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Self::Error>

Returns a bitcoin Transaction given it’s txid.

source

fn get_height(&self) -> Result<u32, Self::Error>

Get the height of our best know chain.

source

fn broadcast(&self, tx: &Transaction) -> Result<(), Self::Error>

Broadcasts a transaction to the network.

source

fn estimate_fee(&self, target: usize) -> Result<f64, Self::Error>

Returns fee estimation for inclusion in target blocks.

source

fn get_block(&self, hash: &BlockHash) -> Result<Block, Self::Error>

Returns a block with a given hash if any.

source

fn get_best_block(&self) -> Result<(u32, BlockHash), Self::Error>

Returns the best known block

source

fn get_block_header(&self, hash: &BlockHash) -> Result<BlockHeader, Self::Error>

Returns associated header for block with hash

source

fn subscribe(&self, tx: Arc<dyn BlockConsumer>)

Register for receiving notifications for some event. Right now it only works for new blocks, but may work with transactions in the future too. if a module performs some heavy-lifting on the block’s data, it should pass in a vector or a channel where data can be transfered to the atual worker, otherwise chainstate will be stuck for as long as you have work to do.

source

fn is_in_idb(&self) -> bool

Tells whether or not we are on ibd

source

fn get_unbroadcasted(&self) -> Vec<Transaction>

Returns the list of unbroadcasted transactions.

source

fn is_coinbase_mature( &self, height: u32, block: BlockHash ) -> Result<bool, Self::Error>

Checks if a coinbase is mature

source

fn get_block_locator(&self) -> Result<Vec<BlockHash>, Self::Error>

Returns a block locator

source

fn get_block_locator_for_tip( &self, tip: BlockHash ) -> Result<Vec<BlockHash>, BlockchainError>

Returns a block locator from a given tip

This method may be used to get the locator from a tip that’s not the best one

source

fn get_validation_index(&self) -> Result<u32, Self::Error>

Returns the last block we validated

source

fn rescan(&self, start_height: u32) -> Result<(), Self::Error>

Triggers a rescan, downloading (but not validating) all blocks in [start_height:tip]

source

fn get_rescan_index(&self) -> Option<u32>

Returns where we are in the rescan

source

fn get_block_height(&self, hash: &BlockHash) -> Result<Option<u32>, Self::Error>

Returns the height of a block, given it’s hash

source

fn update_acc( &self, acc: Stump, block: UtreexoBlock, height: u32, proof: Proof, del_hashes: Vec<Hash> ) -> Result<Stump, Self::Error>

source

fn get_chain_tips(&self) -> Result<Vec<BlockHash>, Self::Error>

source

fn validate_block( &self, block: &Block, proof: Proof, inputs: HashMap<OutPoint, TxOut>, del_hashes: Vec<Hash>, acc: Stump ) -> Result<(), Self::Error>

source

fn get_fork_point(&self, block: BlockHash) -> Result<BlockHash, Self::Error>

Implementations on Foreign Types§

source§

impl<T: BlockchainInterface> BlockchainInterface for Arc<T>

§

type Error = <T as BlockchainInterface>::Error

source§

fn get_tx(&self, txid: &Txid) -> Result<Option<Transaction>, Self::Error>

source§

fn rescan(&self, start_height: u32) -> Result<(), Self::Error>

source§

fn broadcast(&self, tx: &Transaction) -> Result<(), Self::Error>

source§

fn get_block(&self, hash: &BlockHash) -> Result<Block, Self::Error>

source§

fn subscribe(&self, tx: Arc<dyn BlockConsumer>)

source§

fn is_in_idb(&self) -> bool

source§

fn get_height(&self) -> Result<u32, Self::Error>

source§

fn estimate_fee(&self, target: usize) -> Result<f64, Self::Error>

source§

fn get_block_hash(&self, height: u32) -> Result<BlockHash, Self::Error>

source§

fn get_best_block(&self) -> Result<(u32, BlockHash), Self::Error>

source§

fn get_block_header(&self, hash: &BlockHash) -> Result<BlockHeader, Self::Error>

source§

fn get_rescan_index(&self) -> Option<u32>

source§

fn get_block_height(&self, hash: &BlockHash) -> Result<Option<u32>, Self::Error>

source§

fn get_unbroadcasted(&self) -> Vec<Transaction>

source§

fn get_block_locator(&self) -> Result<Vec<BlockHash>, Self::Error>

source§

fn is_coinbase_mature( &self, height: u32, block: BlockHash ) -> Result<bool, Self::Error>

source§

fn get_validation_index(&self) -> Result<u32, Self::Error>

source§

fn get_block_locator_for_tip( &self, tip: BlockHash ) -> Result<Vec<BlockHash>, BlockchainError>

source§

fn update_acc( &self, acc: Stump, block: UtreexoBlock, height: u32, proof: Proof, del_hashes: Vec<Hash> ) -> Result<Stump, Self::Error>

source§

fn get_chain_tips(&self) -> Result<Vec<BlockHash>, Self::Error>

source§

fn validate_block( &self, block: &Block, proof: Proof, inputs: HashMap<OutPoint, TxOut>, del_hashes: Vec<Hash>, acc: Stump ) -> Result<(), Self::Error>

source§

fn get_fork_point(&self, block: BlockHash) -> Result<BlockHash, Self::Error>

Implementors§