Skip to content

kad: Query::next_action() message is ignored by the kademlia handler #230

Open
@lexnv

Description

Query::next_action() method returns a QueryAction that contains a raw kademlia message.
For the FindNode query type it is the FIND_NODE message, for GetRecords query type it is the GET_VALUE message.

pub fn next_action(&mut self) -> Option<QueryAction> {

The message is ignored by the kademlia handler on_query_action method:

while let Some(action) = self.engine.next_action() {
if let Err((query, peer)) = self.on_query_action(action).await {
self.disconnect_peer(peer, Some(query)).await;
}
}

The following lines are ignoring the provided message, and sending the FindNode request regardless of the message provided:

QueryAction::SendMessage { query, peer, .. } => {
if self
.open_substream_or_dial(peer, PeerAction::SendFindNode(query), Some(query))
.is_err()
{
// Announce the error to the query engine.
self.engine.register_response_failure(query, peer);
}

The intention behind this behavior was to advance the discoverability of the network. For example, GetRecords query must first discover the network, then publish a GET_VALUE request.

Consider untangling the query message with the kademlia handler and to allow queries to decide which message should be sent.
We can further look into optimizing the number of messages sent from the query engine to the kademlia handler (since some of them may be redundant as in this case)

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions