Skip to content

Commit c1b273c

Browse files
authored
Merge branch 'main' into A0-1932-push-release-branches-and-tags-to-foundation-repo
2 parents 394df12 + a6d3a62 commit c1b273c

File tree

20 files changed

+829
-997
lines changed

20 files changed

+829
-997
lines changed

finality-aleph/src/network/clique/incoming.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::fmt::{Display, Error as FmtError, Formatter};
22

3-
use futures::channel::mpsc;
3+
use futures::channel::{mpsc, oneshot};
44
use log::{debug, info};
55

66
use crate::network::clique::{
@@ -40,6 +40,7 @@ async fn manage_incoming<SK: SecretKey, D: Data, S: Splittable>(
4040
stream: S,
4141
result_for_parent: mpsc::UnboundedSender<ResultForService<SK::PublicKey, D>>,
4242
data_for_user: mpsc::UnboundedSender<D>,
43+
authorization_requests_sender: mpsc::UnboundedSender<(SK::PublicKey, oneshot::Sender<bool>)>,
4344
) -> Result<(), IncomingError<SK::PublicKey>> {
4445
debug!(
4546
target: LOG_TARGET,
@@ -48,7 +49,13 @@ async fn manage_incoming<SK: SecretKey, D: Data, S: Splittable>(
4849
let (stream, protocol) = protocol(stream).await?;
4950
debug!(target: LOG_TARGET, "Negotiated protocol, running.");
5051
Ok(protocol
51-
.manage_incoming(stream, secret_key, result_for_parent, data_for_user)
52+
.manage_incoming(
53+
stream,
54+
secret_key,
55+
result_for_parent,
56+
data_for_user,
57+
authorization_requests_sender,
58+
)
5259
.await?)
5360
}
5461

@@ -62,9 +69,18 @@ pub async fn incoming<SK: SecretKey, D: Data, S: Splittable>(
6269
stream: S,
6370
result_for_parent: mpsc::UnboundedSender<ResultForService<SK::PublicKey, D>>,
6471
data_for_user: mpsc::UnboundedSender<D>,
72+
authorization_requests_sender: mpsc::UnboundedSender<(SK::PublicKey, oneshot::Sender<bool>)>,
6573
) {
6674
let addr = stream.peer_address_info();
67-
if let Err(e) = manage_incoming(secret_key, stream, result_for_parent, data_for_user).await {
75+
if let Err(e) = manage_incoming(
76+
secret_key,
77+
stream,
78+
result_for_parent,
79+
data_for_user,
80+
authorization_requests_sender,
81+
)
82+
.await
83+
{
6884
info!(
6985
target: LOG_TARGET,
7086
"Incoming connection from {} failed: {}.", addr, e

finality-aleph/src/network/clique/manager/legacy.rs

Lines changed: 0 additions & 301 deletions
This file was deleted.

finality-aleph/src/network/clique/manager/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ use futures::channel::mpsc;
88
use crate::network::{clique::PublicKey, Data, PeerId};
99

1010
mod direction;
11-
mod legacy;
12-
1311
use direction::DirectedPeers;
14-
pub use legacy::Manager as LegacyManager;
1512

1613
/// Error during sending data through the Manager
1714
#[derive(Debug, PartialEq, Eq)]
@@ -232,6 +229,10 @@ impl<PK: PublicKey + PeerId, A: Data, D: Data> Manager<PK, A, D> {
232229
pub fn status_report(&self) -> impl Display {
233230
ManagerStatus::new(self)
234231
}
232+
233+
pub fn is_authorized(&self, public_key: &PK) -> bool {
234+
self.wanted.interested(public_key)
235+
}
235236
}
236237

237238
#[cfg(test)]

finality-aleph/src/network/clique/mock.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,4 +554,5 @@ pub struct MockPrelims<D> {
554554
pub data_from_outgoing: Option<UnboundedReceiver<D>>,
555555
pub result_from_incoming: UnboundedReceiver<ResultForService<MockPublicKey, D>>,
556556
pub result_from_outgoing: UnboundedReceiver<ResultForService<MockPublicKey, D>>,
557+
pub authorization_requests: mpsc::UnboundedReceiver<(MockPublicKey, oneshot::Sender<bool>)>,
557558
}

0 commit comments

Comments
 (0)