Skip to content

Commit

Permalink
fix building issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jianlinjiang committed Jun 18, 2024
1 parent b354436 commit 080bdd8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions hotstuff/network/src/simple_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ use crate::error::NetworkError;
use bytes::Bytes;
use futures::sink::SinkExt as _;
use futures::stream::StreamExt as _;
use log::{warn, debug};
use log::{warn, debug, info};
use rand::prelude::SliceRandom as _;
use rand::rngs::SmallRng;
use rand::SeedableRng as _;
use std::collections::HashMap;
use std::net::SocketAddr;
use tokio::net::TcpStream;
use tokio::sync::mpsc::{Receiver};
use tokio::sync::mpsc::Receiver;
use tokio::sync::RwLock;
use tokio::time::{sleep, Duration};
use tokio_util::codec::{Framed, LengthDelimitedCodec};
Expand Down Expand Up @@ -67,9 +67,9 @@ impl SimpleSender {
}

/// Helper function to spawn a new connection.
fn spawn_connection(address: SocketAddr) -> MonitoredSender<Command> {
fn spawn_connection(address: SocketAddr, exit: exit_future::Exit ) -> MonitoredSender<Command> {
let (tx, rx) = MonitoredChannel::new(CHANNEL_CAPACITY, format!("simple-{}", address), "debug");
Connection::spawn(address, rx);
Connection::spawn(address, rx, exit);
tx
}

Expand All @@ -83,7 +83,7 @@ impl SimpleSender {

debug!("[Simple] Openning a new connection to {}", address);
// Otherwise make a new connection.
let tx = Self::spawn_connection(address);
let tx = Self::spawn_connection(address, self.exit.clone());
if tx.send(cmd).await.is_ok() {
self.connections.write().await.insert(address, tx);
}
Expand Down Expand Up @@ -170,12 +170,14 @@ struct Connection {
address: SocketAddr,
/// Channel from which the connection receives its commands.
receiver: Receiver<Command>,

exit: exit_future::Exit,
}

impl Connection {
fn spawn(address: SocketAddr, receiver: Receiver<Command>) {
fn spawn(address: SocketAddr, receiver: Receiver<Command>, exit: exit_future::Exit) {
tokio::spawn(async move {
Self { address, receiver }.run().await;
Self { address, receiver, exit }.run().await;
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/node/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ lazy_static! {
threshold_map.insert(7, 5);
threshold_map
};
static ref ALLOWED_COMMITTEE_SIZE: HashSet<u64> = { HashSet::from([4, 7]) };
static ref ALLOWED_COMMITTEE_SIZE: HashSet<u64> = HashSet::from([4, 7]);
}
#[derive(Debug)]
pub enum ContractError {
Expand Down

0 comments on commit 080bdd8

Please sign in to comment.