mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 09:31:12 +00:00
rpc/events: Add events for chainHead methods
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -41,7 +41,10 @@
|
||||
|
||||
use super::{
|
||||
rpc_params,
|
||||
subscription_events::FollowEvent,
|
||||
subscription_events::{
|
||||
ChainHeadEvent,
|
||||
FollowEvent,
|
||||
},
|
||||
RpcClient,
|
||||
RpcClientT,
|
||||
Subscription,
|
||||
@@ -629,7 +632,7 @@ impl<T: Config> Rpc<T> {
|
||||
&self,
|
||||
hash: T::Hash,
|
||||
subscription_id: String,
|
||||
) -> Result<Subscription<FollowEvent<T::Hash>>, Error> {
|
||||
) -> Result<Subscription<ChainHeadEvent<String>>, Error> {
|
||||
let subscription = self
|
||||
.client
|
||||
.subscribe(
|
||||
|
||||
@@ -125,3 +125,28 @@ pub enum FollowEvent<Hash> {
|
||||
/// will be generated.
|
||||
Stop,
|
||||
}
|
||||
|
||||
/// The result of a chain head method.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ChainHeadResult<T> {
|
||||
/// Result of the method.
|
||||
pub result: T,
|
||||
}
|
||||
|
||||
/// The event generated by the body / call / storage methods.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[serde(tag = "event")]
|
||||
pub enum ChainHeadEvent<T> {
|
||||
/// The request completed successfully.
|
||||
Done(ChainHeadResult<T>),
|
||||
/// The resources requested are inaccessible.
|
||||
///
|
||||
/// Resubmitting the request later might succeed.
|
||||
Inaccessible(ErrorEvent),
|
||||
/// An error occurred. This is definitive.
|
||||
Error(ErrorEvent),
|
||||
/// The provided subscription ID is stale or invalid.
|
||||
Disjoint,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user