Skip to content

Commit

Permalink
fix : Lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Oct 28, 2024
1 parent a67cfa5 commit 9e9cb66
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/discv5.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<P = DefaultProtocolId, K : EnrKey>
pub struct Discv5<P = DefaultProtocolId, K = CombinedKey>
where
P: ProtocolIdentity,
K: EnrKey<PublicKey = CombinedPublicKey>,
{
config: Config,
/// The channel to make requests from the main service.
Expand All @@ -102,8 +103,11 @@ where
/// Phantom for the protocol id.
_phantom: PhantomData<P>,
}

impl<P: ProtocolIdentity, K:EnrKey> Discv5<P,K> {
impl<P, K> Discv5<P, K>
where
P: ProtocolIdentity,
K: EnrKey<PublicKey = CombinedPublicKey>,
{
pub fn new(
local_enr: Enr,
enr_key: K,
Expand Down Expand Up @@ -737,7 +741,7 @@ impl<P: ProtocolIdentity, K:EnrKey> Discv5<P,K> {
}
}

impl<P: ProtocolIdentity> Drop for Discv5<P> {
impl<P: ProtocolIdentity, K:EnrKey<PublicKey = CombinedPublicKey>> Drop for Discv5<P,K> {
fn drop(&mut self) {
self.shutdown();
}
Expand Down
5 changes: 3 additions & 2 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -268,15 +269,15 @@ impl Default for NodesResponse {
}
}

impl Service {
impl<K> Service {
/// Builds the `Service` main struct.
///
/// `local_enr` is the `ENR` representing the local node. This contains node identifying information, such
/// as IP addresses and ports which we wish to broadcast to other nodes via this discovery
/// mechanism.
pub async fn spawn<P: ProtocolIdentity>(
local_enr: Arc<RwLock<Enr>>,
enr_key: Arc<RwLock<CombinedKey>>,
enr_key: Arc<RwLock<K>>,
kbuckets: Arc<RwLock<KBucketsTable<NodeId, Enr>>>,
config: Config,
) -> Result<(oneshot::Sender<()>, mpsc::Sender<ServiceRequest>), std::io::Error> {
Expand Down

0 comments on commit 9e9cb66

Please sign in to comment.