Skip to content

Commit

Permalink
kad: Refactor GetRecord query and add tests (#97)
Browse files Browse the repository at this point in the history
This PR refactors the `GetRecord` query to make it more robust.
- Avoid panics on unwraps and unimplemented logic
- Separate config immutable variables from main query logic
- Simplifies logic of `next_action` method 
- Private methods for internal logic

Builds on top of: #96

cc @paritytech/networking

---------

Signed-off-by: Alexandru Vasile <[email protected]>
  • Loading branch information
lexnv authored May 16, 2024
1 parent 423a35d commit 5548223
Show file tree
Hide file tree
Showing 3 changed files with 367 additions and 97 deletions.
3 changes: 1 addition & 2 deletions src/protocol/libp2p/kademlia/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,12 @@ use tokio::sync::mpsc::{Receiver, Sender};

use std::collections::{hash_map::Entry, HashMap};

pub use self::handle::RecordsType;
pub use config::{Config, ConfigBuilder};
pub use handle::{KademliaEvent, KademliaHandle, Quorum, RoutingTableUpdateMode};
pub use query::QueryId;
pub use record::{Key as RecordKey, PeerRecord, Record};

pub use self::handle::RecordsType;

/// Logging target for the file.
const LOG_TARGET: &str = "litep2p::ipfs::kademlia";

Expand Down
Loading

0 comments on commit 5548223

Please sign in to comment.