pub struct BlockchainService { /* private fields */ }Expand description
Blockchain validation and acceptance service
Orchestrates block validation, chain updates, UTXO set management, and consensus enforcement.
Implementations§
Source§impl BlockchainService
impl BlockchainService
Sourcepub fn new(
block_store: Arc<dyn BlockStore>,
chain_state: Arc<dyn ChainStateStore>,
peer_manager: Arc<dyn PeerManager>,
) -> Self
pub fn new( block_store: Arc<dyn BlockStore>, chain_state: Arc<dyn ChainStateStore>, peer_manager: Arc<dyn PeerManager>, ) -> Self
Create a new blockchain service
Sourcepub fn with_params(
block_store: Arc<dyn BlockStore>,
chain_state: Arc<dyn ChainStateStore>,
peer_manager: Arc<dyn PeerManager>,
consensus_params: ConsensusParams,
) -> Self
pub fn with_params( block_store: Arc<dyn BlockStore>, chain_state: Arc<dyn ChainStateStore>, peer_manager: Arc<dyn PeerManager>, consensus_params: ConsensusParams, ) -> Self
Create a new blockchain service with explicit consensus parameters.
Sourcepub async fn validate_and_accept_block(
&self,
block: &Block,
) -> Result<(), String>
pub async fn validate_and_accept_block( &self, block: &Block, ) -> Result<(), String>
Validate and accept a block into the blockchain
This performs:
- Duplicate block check
- Merkle root verification
- Consensus rule validation (block structure, transaction validity)
- UTXO set update (remove spent, add new outputs)
- Chain tip update
- Broadcast to peers
Sourcepub async fn process_new_transaction(
&self,
tx: &Transaction,
) -> Result<(), String>
pub async fn process_new_transaction( &self, tx: &Transaction, ) -> Result<(), String>
Process a new transaction (validate and prepare for mempool)
Performs:
- Basic consensus validation (structure, sizes, amounts)
- Double-spend check against UTXO set
- Input value verification (all inputs exist in UTXO set)
Sourcepub async fn get_chain_info(&self) -> Result<ChainInfo, String>
pub async fn get_chain_info(&self) -> Result<ChainInfo, String>
Get current chain information
Auto Trait Implementations§
impl Freeze for BlockchainService
impl !RefUnwindSafe for BlockchainService
impl Send for BlockchainService
impl Sync for BlockchainService
impl Unpin for BlockchainService
impl UnsafeUnpin for BlockchainService
impl !UnwindSafe for BlockchainService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more