mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-16 07:21:07 +00:00
subxt: Expose chainHeadFollow on the backend and test order of blocks
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -16,6 +16,8 @@ mod follow_stream_driver;
|
||||
mod follow_stream_unpin;
|
||||
mod storage_items;
|
||||
|
||||
pub use follow_stream_unpin::BlockRef as UnstableBlockRef;
|
||||
|
||||
pub mod rpc_methods;
|
||||
|
||||
use self::rpc_methods::{
|
||||
@@ -25,6 +27,7 @@ use crate::backend::{
|
||||
rpc::RpcClient, Backend, BlockRef, BlockRefT, RuntimeVersion, StorageResponse, StreamOf,
|
||||
StreamOfResults, TransactionStatus,
|
||||
};
|
||||
|
||||
use crate::config::BlockHash;
|
||||
use crate::error::{Error, RpcError};
|
||||
use crate::Config;
|
||||
@@ -332,6 +335,18 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
|
||||
next_ref.ok_or_else(|| RpcError::SubscriptionDropped.into())
|
||||
}
|
||||
|
||||
async fn chain_head_follow(
|
||||
&self,
|
||||
) -> Result<StreamOfResults<FollowEvent<UnstableBlockRef<T::Hash>>>, Error> {
|
||||
let stream = self
|
||||
.follow_handle
|
||||
.subscribe()
|
||||
.events()
|
||||
.map(|event| Ok(event));
|
||||
|
||||
Ok(StreamOf(Box::pin(stream)))
|
||||
}
|
||||
|
||||
async fn current_runtime_version(&self) -> Result<RuntimeVersion, Error> {
|
||||
// Just start a stream of version infos, and return the first value we get from it.
|
||||
let runtime_version = self.stream_runtime_version().await?.next().await;
|
||||
|
||||
Reference in New Issue
Block a user