Trait nakamoto_node::client::Reactor
[−]pub trait Reactor {
type Waker: Waker;
fn new(
shutdown: Receiver<()>,
listening: Sender<SocketAddr>
) -> Result<Self, Error>;
fn run<P, E>(
&mut self,
listen_addrs: &[SocketAddr],
protocol: P,
publisher: E,
commands: Receiver<<P as Protocol>::Command>
) -> Result<(), Error>
where
P: Protocol,
E: Publisher<<P as Protocol>::Event>,
<P as Protocol>::DisconnectReason: Into<DisconnectReason<<P as Protocol>::DisconnectReason>>;
fn waker(&self) -> Self::Waker;
}Expand description
Any network reactor that can drive the light-client protocol.
Required Associated Types
Required Methods
Create a new reactor, initializing it with a publisher for protocol events, a channel to receive commands, and a channel to shut it down.
Run the given protocol state machine with the reactor.
Implementations on Foreign Types
sourceimpl Reactor for Reactor<TcpStream>
impl Reactor for Reactor<TcpStream>
sourcefn new(
shutdown: Receiver<()>,
listening: Sender<SocketAddr>
) -> Result<Reactor<TcpStream>, Error>
fn new(
shutdown: Receiver<()>,
listening: Sender<SocketAddr>
) -> Result<Reactor<TcpStream>, Error>
Construct a new reactor, given a channel to send events on.
sourcefn run<P, E>(
&mut self,
listen_addrs: &[SocketAddr],
protocol: P,
publisher: E,
commands: Receiver<<P as Protocol>::Command>
) -> Result<(), Error>where
P: Protocol,
E: Publisher<<P as Protocol>::Event>,
<P as Protocol>::DisconnectReason: Into<DisconnectReason<<P as Protocol>::DisconnectReason>>,
fn run<P, E>(
&mut self,
listen_addrs: &[SocketAddr],
protocol: P,
publisher: E,
commands: Receiver<<P as Protocol>::Command>
) -> Result<(), Error>where
P: Protocol,
E: Publisher<<P as Protocol>::Event>,
<P as Protocol>::DisconnectReason: Into<DisconnectReason<<P as Protocol>::DisconnectReason>>,
Run the given protocol with the reactor.
sourcefn waker(&self) -> <Reactor<TcpStream> as Reactor>::Waker
fn waker(&self) -> <Reactor<TcpStream> as Reactor>::Waker
Return a new waker.
Used to wake up the main event loop.