Trait nakamoto_net::Reactor
source · pub trait Reactor<Id: PeerId = SocketAddr> {
type Waker: Waker;
fn new(
shutdown: Receiver<()>,
listening: Sender<SocketAddr>
) -> Result<Self, Error>
where
Self: Sized;
fn run<S, E>(
&mut self,
listen_addrs: &[SocketAddr],
service: S,
publisher: E,
commands: Receiver<S::Command>
) -> Result<(), Error>
where
S: Service<Id>,
S::DisconnectReason: Into<Disconnect<S::DisconnectReason>>,
E: Publisher<S::Event>;
fn waker(&self) -> Self::Waker;
}
Expand description
Any network reactor that can drive the light-client service.
Required Associated Types
Required Methods
sourcefn new(
shutdown: Receiver<()>,
listening: Sender<SocketAddr>
) -> Result<Self, Error>where
Self: Sized,
fn new(
shutdown: Receiver<()>,
listening: Sender<SocketAddr>
) -> Result<Self, Error>where
Self: Sized,
Create a new reactor, initializing it with a publisher for service events, a channel to receive commands, and a channel to shut it down.
sourcefn run<S, E>(
&mut self,
listen_addrs: &[SocketAddr],
service: S,
publisher: E,
commands: Receiver<S::Command>
) -> Result<(), Error>where
S: Service<Id>,
S::DisconnectReason: Into<Disconnect<S::DisconnectReason>>,
E: Publisher<S::Event>,
fn run<S, E>(
&mut self,
listen_addrs: &[SocketAddr],
service: S,
publisher: E,
commands: Receiver<S::Command>
) -> Result<(), Error>where
S: Service<Id>,
S::DisconnectReason: Into<Disconnect<S::DisconnectReason>>,
E: Publisher<S::Event>,
Run the given service with the reactor.
Takes:
- The addresses to listen for connections on.
- The
Service
to run. - The
StateMachine::Event
publisher to use when the service emits events. - The
Service::Command
channel on which commands will be received.