node: Improve wire code

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier
2022-09-13 10:16:05 +02:00
parent 9d3030a093
commit 1dec499e3d
4 changed files with 130 additions and 57 deletions
+4 -4
View File
@@ -92,15 +92,15 @@ impl Arbitrary for Message {
impl Arbitrary for Address {
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
if bool::arbitrary(g) {
Address::Ip {
ip: net::IpAddr::V4(net::Ipv4Addr::from(u32::arbitrary(g))),
Address::Ipv4 {
ip: net::Ipv4Addr::from(u32::arbitrary(g)),
port: u16::arbitrary(g),
}
} else {
let octets: [u8; 16] = ByteArray::<16>::arbitrary(g).into_inner();
Address::Ip {
ip: net::IpAddr::V6(net::Ipv6Addr::from(octets)),
Address::Ipv6 {
ip: net::Ipv6Addr::from(octets),
port: u16::arbitrary(g),
}
}
+1 -4
View File
@@ -147,10 +147,7 @@ where
Message::hello(
peer.id(),
self.local_time().as_secs(),
vec![Address::Ip {
ip: remote.ip(),
port: remote.port(),
}],
vec![Address::from(remote)],
git,
),
);