node: Implement binary encoding for messages

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier
2022-09-13 10:16:05 +02:00
parent c7f78eafb6
commit b3d3077ccc
11 changed files with 638 additions and 88 deletions
+11 -4
View File
@@ -2,6 +2,7 @@
pub mod config;
pub mod message;
pub mod peer;
pub mod wire;
use std::ops::{Deref, DerefMut};
use std::{collections::VecDeque, fmt, io, net, net::IpAddr};
@@ -667,6 +668,16 @@ pub struct Context<S, T, G> {
rng: Rng,
}
impl<S, T, G> Context<S, T, G>
where
T: storage::ReadStorage,
G: crypto::Signer,
{
pub(crate) fn id(&self) -> NodeId {
*self.signer.public_key()
}
}
impl<'r, S, T, G> Context<S, T, G>
where
T: storage::WriteStorage<'r>,
@@ -692,10 +703,6 @@ where
}
}
pub(crate) fn id(&self) -> NodeId {
*self.signer.public_key()
}
/// Process a peer inventory announcement by updating our routing table.
fn process_inventory(&mut self, inventory: &Inventory, from: NodeId, remote: &Url) {
for proj_id in inventory {