mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
Extend the new api.blocks() to be the primary way to subscribe and fetch blocks/extrinsics/events (#691)
* First pass adding functions to get blocks and extrinsics * cargo fmt and cache block events * prefix block hash with 0x * pin streams for better ergonomics and add an example of subscribing to blocks * remove unused var * standardise on _all, _best and _finalized for different block header subs * WIP center subscribing around blocks * Remove the event filtering/subscribing stuff * clippy * we need tokio, silly clippy * add extrinsic_index() call * Update subxt/src/blocks/block_types.rs Co-authored-by: Andrew Jones <ascjones@gmail.com> Co-authored-by: Andrew Jones <ascjones@gmail.com>
This commit is contained in:
@@ -63,6 +63,9 @@ pub enum Error {
|
||||
/// Transaction progress error.
|
||||
#[error("Transaction error: {0}")]
|
||||
Transaction(#[from] TransactionError),
|
||||
/// Block related error.
|
||||
#[error("Block error: {0}")]
|
||||
Block(#[from] BlockError),
|
||||
/// An error encoding a storage address.
|
||||
#[error("Error encoding storage address: {0}")]
|
||||
StorageAddress(#[from] StorageAddressError),
|
||||
@@ -237,6 +240,24 @@ impl DispatchError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Block error
|
||||
#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
|
||||
pub enum BlockError {
|
||||
/// The block
|
||||
#[error(
|
||||
"Could not find a block with hash {0} (perhaps it was on a non-finalized fork?)"
|
||||
)]
|
||||
BlockHashNotFound(String),
|
||||
}
|
||||
|
||||
impl BlockError {
|
||||
/// Produce an error that a block with the given hash cannot be found.
|
||||
pub fn block_hash_not_found(hash: impl AsRef<[u8]>) -> BlockError {
|
||||
let hash = format!("0x{}", hex::encode(hash));
|
||||
BlockError::BlockHashNotFound(hash)
|
||||
}
|
||||
}
|
||||
|
||||
/// Transaction error.
|
||||
#[derive(Clone, Debug, Eq, thiserror::Error, PartialEq)]
|
||||
pub enum TransactionError {
|
||||
|
||||
Reference in New Issue
Block a user