pub trait BlockChainClient:
Send
+ Sync
+ Clone {
// Required methods
fn get_latest_block_number<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_blocks<'life0, 'async_trait>(
&'life0 self,
start_block: u64,
end_block: Option<u64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<BlockType>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn get_contract_spec<'life0, 'life1, 'async_trait>(
&'life0 self,
_contract_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ContractSpec, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Expand description
Defines the core interface for blockchain clients
This trait must be implemented by all blockchain-specific clients to provide standardized access to blockchain data and operations.
Required Methods§
Sourcefn get_latest_block_number<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_latest_block_number<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves the latest block number from the blockchain
§Returns
Result<u64, anyhow::Error>
- The latest block number or an error
Sourcefn get_blocks<'life0, 'async_trait>(
&'life0 self,
start_block: u64,
end_block: Option<u64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<BlockType>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_blocks<'life0, 'async_trait>(
&'life0 self,
start_block: u64,
end_block: Option<u64>,
) -> Pin<Box<dyn Future<Output = Result<Vec<BlockType>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves a range of blocks from the blockchain
§Arguments
start_block
- The starting block numberend_block
- Optional ending block number. If None, only fetches start_block
§Returns
Result<Vec<BlockType>, anyhow::Error>
- Vector of blocks or an error
§Note
The implementation should handle cases where end_block is None by returning only the start_block data.
Provided Methods§
Sourcefn get_contract_spec<'life0, 'life1, 'async_trait>(
&'life0 self,
_contract_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ContractSpec, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_contract_spec<'life0, 'life1, 'async_trait>(
&'life0 self,
_contract_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<ContractSpec, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.