node: Implement Client

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier
2022-09-13 10:16:05 +02:00
parent 35b0af9a68
commit e663e8c516
11 changed files with 228 additions and 38 deletions
+2 -6
View File
@@ -129,11 +129,7 @@ where
}
pub fn receive(&mut self, peer: &net::SocketAddr, msg: Message) {
let bytes = serde_json::to_vec(&Envelope {
magic: NETWORK_MAGIC,
msg,
})
.unwrap();
let bytes = serde_json::to_vec(&self.config().network.envelope(msg)).unwrap();
self.protocol.received_bytes(peer, &bytes);
}
@@ -212,7 +208,7 @@ where
}
/// Get a draining iterator over the peers's I/O outbox.
pub fn outbox(&mut self) -> impl Iterator<Item = Io<(), DisconnectReason>> + '_ {
pub fn outbox(&mut self) -> impl Iterator<Item = Io<Event, DisconnectReason>> + '_ {
self.protocol.outbox().drain(..)
}
}