Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/anemo/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ pub struct Config {
///
/// This limit is applied in the following ways:
/// - Inbound connections from [`KnownPeers`] with [`PeerAffinity::High`] or
/// [`PeerAffinity::Allowed`] bypass this limit. All other inbound
/// connections are only accepted if the total number of inbound and outbound
/// connections, irrespective of affinity, is less than this limit.
/// [`PeerAffinity::Allowed`] bypass this limit. All other inbound
/// connections are only accepted if the total number of inbound and outbound
/// connections, irrespective of affinity, is less than this limit.
/// - Outbound connections explicitly made by the application via [`Network::connect`] or
/// [`Network::connect_with_peer_id`] bypass this limit.
/// [`Network::connect_with_peer_id`] bypass this limit.
/// - Outbound connections made in the background, due to configured [`KnownPeers`], to peers with
/// [`PeerAffinity::High`] bypass this limit and are always attempted.
/// [`PeerAffinity::High`] bypass this limit and are always attempted.
///
/// If unspecified, there will be no limit on the number of concurrent connections.
///
Expand Down
5 changes: 4 additions & 1 deletion crates/anemo/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,12 @@ fn pki_error(error: webpki::Error) -> rustls::Error {
BadDer | BadDerTime => {
rustls::Error::InvalidCertificate(rustls::CertificateError::BadEncoding)
}
#[allow(deprecated)]
InvalidSignatureForPublicKey
| UnsupportedSignatureAlgorithm
| UnsupportedSignatureAlgorithmForPublicKey => {
| UnsupportedSignatureAlgorithmForPublicKey
| UnsupportedSignatureAlgorithmContext(..)
| UnsupportedSignatureAlgorithmForPublicKeyContext(..) => {
rustls::Error::InvalidCertificate(rustls::CertificateError::BadSignature)
}
e => {
Expand Down
2 changes: 1 addition & 1 deletion crates/anemo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub mod types;
pub use config::{Config, QuicConfig};
pub use error::{Error, Result};
pub use network::{Builder, KnownPeers, Network, NetworkRef, Peer};
pub use routing::Router;
pub use routing::{Router, ServicesOpen, ServicesSealed};
#[doc(inline)]
pub use types::{request::Request, response::Response, ConnectionOrigin, Direction, PeerId};

Expand Down
13 changes: 13 additions & 0 deletions crates/anemo/src/network/connection_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,19 @@ impl KnownPeers {
self.inner_mut().insert(peer_info.peer_id, peer_info)
}

pub fn batch_update<'a>(
&self,
to_remove: impl Iterator<Item = &'a PeerId>,
to_insert: impl Iterator<Item = PeerInfo>,
) -> (Vec<Option<PeerInfo>>, Vec<Option<PeerInfo>>) {
let mut inner = self.inner_mut();
let removed = to_remove.map(|peer_id| inner.remove(peer_id)).collect();
let inserted = to_insert
.map(|peer_info| inner.insert(peer_info.peer_id, peer_info))
.collect();
(removed, inserted)
}

fn inner(&self) -> std::sync::RwLockReadGuard<'_, HashMap<PeerId, PeerInfo>> {
self.0.read().unwrap()
}
Expand Down
7 changes: 4 additions & 3 deletions crates/anemo/src/network/request_handler.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::wire::MessageFrameCodec;
use super::{
wire::{network_message_frame_codec, read_request, write_response},
ActivePeers,
Expand All @@ -10,7 +11,7 @@ use bytes::Bytes;
use quinn::RecvStream;
use std::convert::Infallible;
use std::sync::Arc;
use tokio_util::codec::{FramedRead, FramedWrite, LengthDelimitedCodec};
use tokio_util::codec::{FramedRead, FramedWrite};
use tower::{util::BoxCloneService, ServiceExt};
use tracing::{debug, trace};

Expand Down Expand Up @@ -121,8 +122,8 @@ impl InboundRequestHandler {
struct BiStreamRequestHandler {
connection: Connection,
service: BoxCloneService<Request<Bytes>, Response<Bytes>, Infallible>,
send_stream: FramedWrite<SendStream, LengthDelimitedCodec>,
recv_stream: FramedRead<RecvStream, LengthDelimitedCodec>,
send_stream: FramedWrite<SendStream, MessageFrameCodec>,
recv_stream: FramedRead<RecvStream, MessageFrameCodec>,
}

impl BiStreamRequestHandler {
Expand Down
Loading
Loading