Skip to content

Commit be60360

Browse files
committed
Add implementation feature to protocol id
1 parent 73f4f73 commit be60360

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/handler/request_call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pub use crate::node_info::{NodeAddress, NodeContact};
1+
pub use crate::node_info::{NodeContact};
22
use crate::{
33
packet::Packet,
44
rpc::{Request, RequestBody},

src/kbucket/entry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
2727
pub use super::{
2828
bucket::{
29-
AppliedPending, ConnectionState, InsertResult, Node, NodeStatus, MAX_NODES_PER_BUCKET,
29+
AppliedPending, ConnectionState, InsertResult, Node, NodeStatus,
3030
},
3131
key::*,
3232
ConnectionDirection,

src/packet/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,25 @@ pub const MESSAGE_NONCE_LENGTH: usize = 12;
2929
/// The Id nonce length (in bytes).
3030
pub const ID_NONCE_LENGTH: usize = 16;
3131

32+
pub struct Nat;
33+
34+
impl ProtocolIdentity<3> for Nat {
35+
const PROTOCOL_ID_BYTES: [u8; 6] = *b"discv5";
36+
const PROTOCOL_VERSION_BYTES: [u8; 2] = 0x0001_u16.to_be_bytes();
37+
const IMPLEMENTATION_FEATURES: [u8; 3] = *b"nat";
38+
}
3239
pub struct DefaultProtocolId {}
3340

3441
impl ProtocolIdentity for DefaultProtocolId {
3542
const PROTOCOL_ID_BYTES: [u8; 6] = *b"discv5";
3643
const PROTOCOL_VERSION_BYTES: [u8; 2] = 0x0001_u16.to_be_bytes();
44+
const IMPLEMENTATION_FEATURES: [u8; 0] = *b"";
3745
}
3846

39-
pub trait ProtocolIdentity {
47+
pub trait ProtocolIdentity<const N: usize = 0>: Sync + Send {
4048
const PROTOCOL_ID_BYTES: [u8; 6];
4149
const PROTOCOL_VERSION_BYTES: [u8; 2];
50+
const IMPLEMENTATION_FEATURES: [u8; N];
4251
}
4352

4453
pub(crate) const MAX_PACKET_SIZE: usize = 1280;

0 commit comments

Comments
 (0)