Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A0-1576: Move clique network into network #811

Merged
merged 6 commits into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 0 additions & 2 deletions finality-aleph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ mod nodes;
mod party;
mod session;
mod session_map;
mod tcp_network;
#[cfg(test)]
pub mod testing;
mod validator_network;

pub use abft::{Keychain, NodeCount, NodeIndex, Recipient, SignatureSet, SpawnHandle};
pub use aleph_primitives::{AuthorityId, AuthorityPair, AuthoritySignature};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use std::fmt::{Display, Error as FmtError, Formatter};
use futures::channel::mpsc;
use log::{debug, info};

use crate::validator_network::{
use crate::network::clique::{
protocols::{protocol, ProtocolError, ProtocolNegotiationError, ResultForService},
Data, PublicKey, SecretKey, Splittable,
Data, PublicKey, SecretKey, Splittable, LOG_TARGET,
};

enum IncomingError<PK: PublicKey> {
Expand Down Expand Up @@ -41,9 +41,12 @@ async fn manage_incoming<SK: SecretKey, D: Data, S: Splittable>(
result_for_parent: mpsc::UnboundedSender<ResultForService<SK::PublicKey, D>>,
data_for_user: mpsc::UnboundedSender<D>,
) -> Result<(), IncomingError<SK::PublicKey>> {
debug!(target: "validator-network", "Performing incoming protocol negotiation.");
debug!(
target: LOG_TARGET,
"Performing incoming protocol negotiation."
);
let (stream, protocol) = protocol(stream).await?;
debug!(target: "validator-network", "Negotiated protocol, running.");
debug!(target: LOG_TARGET, "Negotiated protocol, running.");
Ok(protocol
.manage_incoming(stream, secret_key, result_for_parent, data_for_user)
.await?)
Expand All @@ -62,6 +65,9 @@ pub async fn incoming<SK: SecretKey, D: Data, S: Splittable>(
) {
let addr = stream.peer_address_info();
if let Err(e) = manage_incoming(secret_key, stream, result_for_parent, data_for_user).await {
info!(target: "validator-network", "Incoming connection from {} failed: {}.", addr, e);
info!(
target: LOG_TARGET,
"Incoming connection from {} failed: {}.", addr, e
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
use codec::DecodeAll;
use tokio::io::{AsyncReadExt, AsyncWriteExt};

use crate::validator_network::Data;
use crate::network::Data;

// We allow sending up to 16MiB, that should be enough forever.
pub const MAX_DATA_SIZE: u32 = 16 * 1024 * 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
ops::BitXor,
};

use crate::validator_network::{Data, PublicKey};
use crate::network::{clique::PublicKey, Data};

/// Data about peers we know and whether we should connect to them or they to us. For the former
/// case also keeps the peers' addresses.
Expand Down Expand Up @@ -85,7 +85,7 @@ impl<PK: PublicKey, A: Data> DirectedPeers<PK, A> {
#[cfg(test)]
mod tests {
use super::DirectedPeers;
use crate::validator_network::mock::{key, MockPublicKey};
use crate::network::clique::mock::{key, MockPublicKey};

type Address = String;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ use std::{

use futures::channel::mpsc;

use crate::{
network::PeerId,
validator_network::{
use crate::network::{
clique::{
manager::{AddResult, SendError},
Data, PublicKey,
PublicKey,
},
Data, PeerId,
};

/// Network component responsible for holding the list of peers that we
Expand Down Expand Up @@ -218,7 +218,7 @@ mod tests {
use futures::{channel::mpsc, StreamExt};

use super::{AddResult::*, Manager, SendError};
use crate::validator_network::mock::{key, MockPublicKey};
use crate::network::clique::mock::{key, MockPublicKey};

type Data = String;
type Address = String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ use std::{

use futures::channel::mpsc;

use crate::{
network::PeerId,
validator_network::{Data, PublicKey},
};
use crate::network::{clique::PublicKey, Data, PeerId};

mod direction;
mod legacy;
Expand Down Expand Up @@ -242,7 +239,7 @@ mod tests {
use futures::{channel::mpsc, StreamExt};

use super::{AddResult::*, Manager, SendError};
use crate::validator_network::mock::{key, MockPublicKey};
use crate::network::clique::mock::{key, MockPublicKey};

type Data = String;
type Address = String;
Expand Down
Loading