mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-15 07:55:45 +00:00
Split polkadot-service (#310)
* Substrate service * Splitting polkadot service * Specialised components * Specialised components * Docs and style * Docs and style * Final touches * Added db key assertion
This commit is contained in:
committed by
Gav Wood
parent
ee31955969
commit
b8216372c7
@@ -17,6 +17,7 @@
|
||||
//! External API for extrinsic pool.
|
||||
|
||||
use txpool;
|
||||
use futures::sync::mpsc;
|
||||
|
||||
/// Extrinsic pool error.
|
||||
pub trait Error: ::std::error::Error + Send + Sized {
|
||||
@@ -32,6 +33,9 @@ impl Error for txpool::Error {
|
||||
fn into_pool_error(self) -> Result<txpool::Error, Self> { Ok(self) }
|
||||
}
|
||||
|
||||
/// Modification notification event stream type;
|
||||
pub type EventStream = mpsc::UnboundedReceiver<()>;
|
||||
|
||||
/// Extrinsic pool.
|
||||
pub trait ExtrinsicPool<Ex, BlockId, Hash>: Send + Sync + 'static {
|
||||
/// Error type
|
||||
@@ -39,4 +43,10 @@ pub trait ExtrinsicPool<Ex, BlockId, Hash>: Send + Sync + 'static {
|
||||
|
||||
/// Submit a collection of extrinsics to the pool.
|
||||
fn submit(&self, block: BlockId, xt: Vec<Ex>) -> Result<Vec<Hash>, Self::Error>;
|
||||
|
||||
/// Returns light status of the pool.
|
||||
fn light_status(&self) -> txpool::LightStatus;
|
||||
|
||||
/// Return an event stream of transactions imported to the pool.
|
||||
fn import_notification_stream(&self) -> EventStream;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ use std::{
|
||||
collections::HashMap,
|
||||
fmt,
|
||||
marker::PhantomData,
|
||||
sync::{Arc, Weak},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use futures::sync::mpsc;
|
||||
@@ -40,7 +40,7 @@ pub struct Pool<Hash, VEx, S, E> where
|
||||
S,
|
||||
Listener<Hash>,
|
||||
>>,
|
||||
import_notification_sinks: Mutex<Vec<mpsc::UnboundedSender<Weak<VEx>>>>,
|
||||
import_notification_sinks: Mutex<Vec<mpsc::UnboundedSender<()>>>,
|
||||
}
|
||||
|
||||
impl<Hash, VEx, S, E> Pool<Hash, VEx, S, E> where
|
||||
@@ -62,15 +62,14 @@ impl<Hash, VEx, S, E> Pool<Hash, VEx, S, E> where
|
||||
pub fn import(&self, xt: VEx) -> Result<Arc<VEx>, E> {
|
||||
let result = self.pool.write().import(xt)?;
|
||||
|
||||
let weak = Arc::downgrade(&result);
|
||||
self.import_notification_sinks.lock()
|
||||
.retain(|sink| sink.unbounded_send(weak.clone()).is_ok());
|
||||
.retain(|sink| sink.unbounded_send(()).is_ok());
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
/// Return an event stream of transactions imported to the pool.
|
||||
pub fn import_notification_stream(&self) -> mpsc::UnboundedReceiver<Weak<VEx>> {
|
||||
pub fn import_notification_stream(&self) -> mpsc::UnboundedReceiver<()> {
|
||||
let (sink, stream) = mpsc::unbounded();
|
||||
self.import_notification_sinks.lock().push(sink);
|
||||
stream
|
||||
|
||||
Reference in New Issue
Block a user