pub trait UtxoProvider {
// Required method
fn get(&self, outpoint: &OutPoint) -> Option<Coin>;
// Provided method
fn batch_get(&self, outpoints: &[OutPoint]) -> HashMap<OutPoint, Coin> { ... }
}Expand description
Abstraction for UTXO access.
This trait decouples block verification from storage implementation, enabling:
- Substrate state lookups during normal operation
- Native RocksDB lookups for optimized storage
- Pre-fetched data during batch verification
- Cached lookups for improved performance
Required Methods§
Provided Methods§
Sourcefn batch_get(&self, outpoints: &[OutPoint]) -> HashMap<OutPoint, Coin>
fn batch_get(&self, outpoints: &[OutPoint]) -> HashMap<OutPoint, Coin>
Batch-fetch multiple UTXOs.
Returns a map containing only the UTXOs that were found. Missing outpoints are silently omitted from the result.
Default implementation calls get() for each outpoint.
Implementations should override for better performance.
Implementations on Foreign Types§
Source§impl UtxoProvider for HashMap<OutPoint, Coin>
Implementation for HashMap (used with pre-fetched UTXOs).
impl UtxoProvider for HashMap<OutPoint, Coin>
Implementation for HashMap (used with pre-fetched UTXOs).
This allows verification to use pre-fetched data without any storage access.