Skip to content

Commit

Permalink
Merge a16b630 into 7736504
Browse files Browse the repository at this point in the history
  • Loading branch information
connec committed Sep 16, 2021
2 parents 7736504 + a16b630 commit 43016d3
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 115 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ on: [pull_request]

jobs:
lint:
if: github.repository_owner == 'maidsafe'
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@f114310111fdbd07e99f47f9ca13d62b3ec98372
- uses: wagoid/commitlint-github-action@59203cb6ee1ce85035e6fe7b3aa878cf80653739
2 changes: 1 addition & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub const DEFAULT_INITIAL_RETRY_INTERVAL: Duration = Duration::from_millis(500);
/// gives 5-6 retries in ~30 s total retry time.
pub const DEFAULT_MAX_RETRY_INTERVAL: Duration = Duration::from_secs(15);

/// Default for [`RetryConfig::retry_interval_multiplier`] (x1.5).
/// Default for [`RetryConfig::retry_delay_multiplier`] (x1.5).
///
/// Together with the default max and initial,
/// gives 5-6 retries in ~30 s total retry time.
Expand Down
22 changes: 16 additions & 6 deletions src/connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,18 @@ use tokio::sync::mpsc::{Receiver, Sender};
use tokio::time::{timeout, Duration};
use tracing::{trace, warn};

/// Connection instance to a node which can be used to send messages to it
/// A connection between two [`Endpoint`]s.
///
/// This is backed by an `Arc` and a small amount of metadata, so cloning is fairly cheap. The
/// connection is also pooled, meaning the same underlying connection will be used when connecting
/// multiple times to the same peer. If an error occurs on the connection, it will be removed from
/// the pool. See the documentation of [`Endpoint::connect_to`] for more details about connection
/// pooling.
///
/// [`Endpoint`]: crate::Endpoint
/// [`Endpoint::connect_to`]: crate::Endpoint::connect_to
#[derive(Clone)]
pub(crate) struct Connection<I: ConnId> {
pub struct Connection<I: ConnId> {
quic_conn: quinn::Connection,
remover: ConnectionRemover<I>,
}
Expand All @@ -45,6 +54,11 @@ impl<I: ConnId> Connection<I> {
Self { quic_conn, remover }
}

/// Get the address of the connected peer.
pub fn remote_address(&self) -> SocketAddr {
self.quic_conn.remote_address()
}

/// Priority default is 0. Both lower and higher can be passed in.
pub(crate) async fn open_bi(
&self,
Expand Down Expand Up @@ -81,10 +95,6 @@ impl<I: ConnId> Connection<I> {
}
}

pub(crate) fn remote_address(&self) -> SocketAddr {
self.quic_conn.remote_address()
}

async fn handle_error<T, E>(&self, result: Result<T, E>) -> Result<T, E> {
if result.is_err() {
self.remover.remove().await
Expand Down
Loading

0 comments on commit 43016d3

Please sign in to comment.