mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 10:01:17 +00:00
blocks: Fetch block's events
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::{
|
|||||||
BlockError,
|
BlockError,
|
||||||
Error,
|
Error,
|
||||||
},
|
},
|
||||||
events,
|
events::{self, Events},
|
||||||
metadata::DecodeWithMetadata,
|
metadata::DecodeWithMetadata,
|
||||||
rpc::{
|
rpc::{
|
||||||
types::{
|
types::{
|
||||||
@@ -30,6 +30,7 @@ use crate::{
|
|||||||
use codec::Decode;
|
use codec::Decode;
|
||||||
use derivative::Derivative;
|
use derivative::Derivative;
|
||||||
use futures::lock::Mutex as AsyncMutex;
|
use futures::lock::Mutex as AsyncMutex;
|
||||||
|
use sp_core::twox_128;
|
||||||
use sp_runtime::traits::{
|
use sp_runtime::traits::{
|
||||||
Hash,
|
Hash,
|
||||||
Header,
|
Header,
|
||||||
@@ -209,6 +210,23 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetch the block's events.
|
||||||
|
pub async fn events(&self) -> Result<Events<T>, ChainHeadError> {
|
||||||
|
let mut storage_key = twox_128(b"System").to_vec();
|
||||||
|
storage_key.extend(twox_128(b"Events").to_vec());
|
||||||
|
let Some(event_bytes) = self.storage_raw(&storage_key).await? else {
|
||||||
|
return Err(ChainHeadError::Other(
|
||||||
|
"Failed to fetch System::Events storage".into()
|
||||||
|
))
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(Events::new(
|
||||||
|
self.client.metadata(),
|
||||||
|
self.hash.clone(),
|
||||||
|
event_bytes,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
/// Wrapper to fetch the block's body from the `chainHead_body` subscription.
|
/// Wrapper to fetch the block's body from the `chainHead_body` subscription.
|
||||||
async fn fetch_body(
|
async fn fetch_body(
|
||||||
&self,
|
&self,
|
||||||
|
|||||||
Reference in New Issue
Block a user