Skip to content

Commit

Permalink
refactor(kad): use oneshots and async-await for outbound streams
Browse files Browse the repository at this point in the history
This refactoring addresses several aspects of the current handler implementation:

- Remove the manual state machine for outbound streams in favor of using `async-await`.
- Use `oneshot`s to track the number of requested outbound streams
- Use `futures_bounded::FuturesMap` to track the execution of a stream, thus applying a timeout to the entire request.

Resolves: #3130.
Related: #3268.
Related: #4510.

Pull-Request: #4901.
  • Loading branch information
thomaseizinger authored Nov 22, 2023
1 parent c718835 commit add1ff6
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 242 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions protocols/kad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ asynchronous-codec = { workspace = true }
futures = "0.3.29"
libp2p-core = { workspace = true }
libp2p-swarm = { workspace = true }
futures-bounded = { workspace = true }
quick-protobuf = "0.8"
quick-protobuf-codec = { workspace = true }
libp2p-identity = { workspace = true, features = ["rand"] }
Expand Down
1 change: 1 addition & 0 deletions protocols/kad/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3173,6 +3173,7 @@ impl QueryInfo {
multiaddrs: external_addresses.clone(),
connection_ty: crate::protocol::ConnectionType::Connected,
},
query_id,
},
},
QueryInfo::GetRecord { key, .. } => HandlerIn::GetRecord {
Expand Down
Loading

0 comments on commit add1ff6

Please sign in to comment.