mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 04:09:23 +00:00
Add a notification system for finalizations to serai-client, use in coordinator
This commit is contained in:
@@ -16,6 +16,8 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||
zeroize = "^1.5"
|
||||
thiserror = { version = "1", optional = true }
|
||||
|
||||
futures = "0.3"
|
||||
|
||||
scale = { package = "parity-scale-codec", version = "3" }
|
||||
scale-info = { version = "2", optional = true }
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use thiserror::Error;
|
||||
|
||||
use futures::stream::{Stream, StreamExt};
|
||||
|
||||
use scale::{Encode, Decode, Compact};
|
||||
mod scale_value;
|
||||
pub(crate) use scale_value::{Value, Composite, scale_value, scale_composite};
|
||||
@@ -259,6 +261,18 @@ impl Serai {
|
||||
self.get_block(hash.into()).await
|
||||
}
|
||||
|
||||
/// A stream which yields whenever new block(s) have been finalized.
|
||||
pub async fn newly_finalized_block(
|
||||
&self,
|
||||
) -> Result<impl Stream<Item = Result<(), SeraiError>>, SeraiError> {
|
||||
Ok(self.0.rpc().subscribe_finalized_block_headers().await.map_err(SeraiError::RpcError)?.map(
|
||||
|next| {
|
||||
next.map_err(SeraiError::RpcError)?;
|
||||
Ok(())
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
pub async fn get_nonce(&self, address: &SeraiAddress) -> Result<u32, SeraiError> {
|
||||
self
|
||||
.0
|
||||
|
||||
Reference in New Issue
Block a user