rpc: Fetch chainHead genesis hash

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2022-11-30 13:09:52 +00:00
parent c2dc0ce2cd
commit e7192f350a
3 changed files with 18 additions and 6 deletions
-6
View File
@@ -81,8 +81,6 @@ where
if let Some(event) = sub.next().await {
let event = event?;
println!("Got event: {:?}", event);
return match event {
ChainHeadEvent::Done(ChainHeadResult { result }) => {
let bytes = hex::decode(result.trim_start_matches("0x"))
@@ -148,8 +146,6 @@ where
if let Some(event) = sub.next().await {
let event = event?;
println!("Got event: {:?}", event);
return match event {
ChainHeadEvent::Done(ChainHeadResult { result }) => {
let result = match result {
@@ -195,8 +191,6 @@ where
if let Some(event) = sub.next().await {
let event = event?;
println!("Got event: {:?}", event);
return match event {
ChainHeadEvent::Done(ChainHeadResult { result }) => {
let bytes = hex::decode(result.trim_start_matches("0x"))
+15
View File
@@ -662,6 +662,21 @@ impl<T: Config> Rpc<T> {
Ok(header)
}
/// Get the chain head genesis hash.
pub async fn get_chainhead_genesis_hash(
&self,
) -> Result<T::Hash, Error> {
let hash = self
.client
.request(
"chainHead_unstable_genesisHash",
rpc_params![],
)
.await?;
Ok(hash)
}
/// Subscribe to the chain head storage.
pub async fn subscribe_chainhead_storage(
&self,