litep2p
litep2p copied to clipboard
kad: Implement query timeouts
Currently, Kademlia queries (find_node / get_records) run until completion, or until they cannot make progress.
Add a configurable timeout for the kademlia queries. It might benefit some users (including substrate) to provide partial results on timeouts, similar to libp2p.
Some datapoints extracted from a toy app:
KAD query QueryId(80), failed in 449.532123ms
KAD query QueryId(86), failed in 449.599902ms
KAD query QueryId(33), failed in 449.786758ms
KAD query QueryId(18), FindNodeSuccess in 82.518983766s
KAD query QueryId(25), FindNodeSuccess in 90.915692115s
KAD query QueryId(0), FindNodeSuccess in 90.992373909s
KAD query QueryId(5), FindNodeSuccess in 95.203866521s