diff --git a/src/discv5.rs b/src/discv5.rs index 626e9117..5120fdb5 100644 --- a/src/discv5.rs +++ b/src/discv5.rs @@ -23,7 +23,7 @@ use crate::{ service::{QueryKind, Service, ServiceRequest, TalkRequest}, Config, DefaultProtocolId, Enr, IpMode, }; -use enr::{CombinedKey, EnrKey, Error as EnrError, NodeId}; +use enr::{CombinedKey, CombinedPublicKey ,EnrKey, Error as EnrError, NodeId}; use parking_lot::RwLock; use std::{ future::Future, @@ -82,9 +82,10 @@ pub enum Event { /// The main Discv5 Service struct. This provides the user-level API for performing queries and /// interacting with the underlying service. -pub struct Discv5

+pub struct Discv5

where P: ProtocolIdentity, + K: EnrKey, { config: Config, /// The channel to make requests from the main service. @@ -96,17 +97,20 @@ where /// The local ENR of the server. local_enr: Arc>, /// The key associated with the local ENR, required for updating the local ENR. - enr_key: Arc>, + enr_key: Arc>, // Type of socket we are using ip_mode: IpMode, /// Phantom for the protocol id. _phantom: PhantomData

, } - -impl Discv5

{ +impl Discv5 +where + P: ProtocolIdentity, + K: EnrKey, + { pub fn new( local_enr: Enr, - enr_key: CombinedKey, + enr_key: K, mut config: Config, ) -> Result { // ensure the keypair matches the one that signed the enr. @@ -737,7 +741,7 @@ impl Discv5

{ } } -impl Drop for Discv5

{ +impl> Drop for Discv5 { fn drop(&mut self) { self.shutdown(); } diff --git a/src/service.rs b/src/service.rs index 2661f846..91d1fa6e 100644 --- a/src/service.rs +++ b/src/service.rs @@ -17,6 +17,7 @@ use self::{ ip_vote::IpVote, query_info::{QueryInfo, QueryType}, }; +use enr::EnrKey; use crate::{ error::{RequestError, ResponseError}, handler::{Handler, HandlerIn, HandlerOut}, @@ -261,7 +262,7 @@ impl Default for NodesResponse { } } -impl Service { +impl Service { /// Builds the `Service` main struct. /// /// `local_enr` is the `ENR` representing the local node. This contains node identifying information, such @@ -269,7 +270,7 @@ impl Service { /// mechanism. pub async fn spawn( local_enr: Arc>, - enr_key: Arc>, + enr_key: Arc>, kbuckets: Arc>>, config: Config, ) -> Result<(oneshot::Sender<()>, mpsc::Sender), std::io::Error> {