8000 Fix too many args in Tvu::new by MarkJr94 · Pull Request #2114 · solana-labs/solana · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jan 22, 2025. It is now read-only.

Fix too many args in Tvu::new #2114

Merged
merged 2 commits into from
Dec 13, 2018
Merged
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
2 changes: 1 addition & 1 deletion src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub struct ClusterInfo {
/// The network
pub gossip: CrdsGossip,
/// set the keypair that will be used to sign crds values generated. It is unset only in tests.
keypair: Arc<Keypair>,
pub(crate) keypair: Arc<Keypair>,
}

#[derive(Debug, Deserialize, Serialize)]
Expand Down
65 changes: 39 additions & 26 deletions src/fullnode.rs
8000
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::rpc_pubsub::PubSubService;
use crate::service::Service;
use crate::tpu::{Tpu, TpuReturnType};
use crate::tpu_forwarder::TpuForwarder;
use crate::tvu::{Tvu, TvuReturnType};
use crate::tvu::{Sockets, Tvu, TvuReturnType};
use crate::window::{new_window, SharedWindow};
use solana_sdk::hash::Hash;
use solana_sdk::signature::{Keypair, KeypairUtil};
Expand Down Expand Up @@ -269,26 +269,33 @@ impl Fullnode {

let node_role = if scheduled_leader != keypair.pubkey() {
// Start in validator mode.
let tvu = Tvu::new(
keypair.clone(),
vote_account_keypair.clone(),
&bank,
entry_height,
*last_entry_id,
cluster_info.clone(),
node.sockets
.tvu
.iter()
.map(|s| s.try_clone().expect("Failed to clone TVU sockets"))
.collect(),
node.sockets
let sockets = Sockets {
repair: node
.sockets
.repair
.try_clone()
.expect("Failed to clone repair socket"),
node.sockets
retransmit: node
.sockets
.retransmit
.try_clone()
.expect("Failed to clone retransmit socket"),
fetch: node
.sockets
.tvu
.iter()
.map(|s| s.try_clone().expect("Failed to clone TVU Sockets"))
.collect(),
};

let tvu = Tvu::new(
// keypair.clone(),
vote_account_keypair.clone(),
&bank,
entry_height,
*last_entry_id,
cluster_info.clone(),
sockets,
Some(ledger_path),
db_ledger.clone(),
);
Expand Down Expand Up @@ -428,23 +435,29 @@ impl Fullnode {
self.validator_to_leader(tick_height, entry_height, last_entry_id);
Ok(())
} else {
let sockets = Sockets {
repair: self
.repair_socket
.try_clone()
.expect("Failed to clone repair socket"),
retransmit: self
.retransmit_socket
.try_clone()
.expect("Failed to clone retransmit socket"),
fetch: self
.tvu_sockets
.iter()
.map(|s| s.try_clone().expect("Failed to clone TVU Sockets"))
.collect(),
};

let tvu = Tvu::new(
self.keypair.clone(),
self.vote_account_keypair.clone(),
&self.bank,
entry_height,
last_entry_id,
self.cluster_info.clone(),
self.tvu_sockets
.iter()
.map(|s| s.try_clone().expect("Failed to clone TVU sockets"))
.collect(),
self.repair_socket
.try_clone()
.expect("Failed to clone repair socket"),
self.retransmit_socket
.try_clone()
.expect("Failed to clone retransmit socket"),
sockets,
Some(&self.ledger_path),
self.db_ledger.clone(),
);
Expand Down
46 changes: 30 additions & 16 deletions src/tvu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,35 +44,46 @@ pub struct Tvu {
exit: Arc<AtomicBool>,
}

pub struct Sockets {
pub fetch: Vec<UdpSocket>,
pub repair: UdpSocket,
pub retransmit: UdpSocket,
}

impl Tvu {
/// This service receives messages from a leader in the network and processes the transactions
/// on the bank state.
/// # Arguments
/// * `bank` - The bank state.
/// * `keypair` - Node's key pair for signing
/// * `vote_account_keypair` - Vote key pair
/// * `bank` - The bank state.
/// * `entry_height` - Initial ledger height
/// * `last_entry_id` - Hash of the last entry
/// * `cluster_info` - The cluster_info state.
/// * `window` - The window state.
/// * `fetch_sockets` - my fetch sockets
/// * `repair_socket` - my repair socket
/// * `retransmit_socket` - my retransmit socket
/// * `sockets` - My fetch, repair, and restransmit sockets
/// * `ledger_path` - path to the ledger file
#[allow(clippy::too_many_arguments)]
/// * `db_ledger` - the ledger itself
pub fn new(
keypair: Arc<Keypair>,
vote_account_keypair: Arc<Keypair>,
bank: &Arc<Bank>,
entry_height: u64,
last_entry_id: Hash,
cluster_info: Arc<RwLock<ClusterInfo>>,
fetch_sockets: Vec<UdpSocket>,
repair_socket: UdpSocket,
retransmit_socket: UdpSocket,
sockets: Sockets,
ledger_path: Option<&str>,
db_ledger: Arc<RwLock<DbLedger>>,
) -> Self {
let exit = Arc::new(AtomicBool::new(false));
let keypair: Arc<Keypair> = cluster_info
.read()
.expect("Unable to read from cluster_info during Tvu creation")
.keypair
.clone();

let Sockets {
repair: repair_socket,
fetch: fetch_sockets,
retransmit: retransmit_socket,
} = sockets;

let repair_socket = Arc::new(repair_socket);
let mut blob_sockets: Vec<Arc<UdpSocket>> =
Expand Down Expand Up @@ -179,7 +190,7 @@ pub mod tests {
use crate::packet::SharedBlob;
use crate::service::Service;
use crate::streamer;
use crate::tvu::Tvu;
use crate::tvu::{Sockets, Tvu};
use crate::window::{self, SharedWindow};
use bincode::serialize;
use rocksdb::{Options, DB};
Expand Down Expand Up @@ -270,15 +281,18 @@ pub mod tests {
let db_ledger =
DbLedger::open(&db_ledger_path).expect("Expected to successfully open ledger");
let tvu = Tvu::new(
Arc::new(target1_keypair),
vote_account_keypair,
&bank,
0,
cur_hash,
cref1,
target1.sockets.tvu,
target1.sockets.repair,
target1.sockets.retransmit,
{
Sockets {
repair: target1.sockets.repair,
retransmit: target1.sockets.retransmit,
fetch: target1.sockets.tvu,
}
},
None,
Arc::new(RwLock::new(db_ledger)),
);
Expand Down
0