Don't offer two ways to specify a leader
This commit is contained in:
parent
cfac127e4c
commit
9c5e69bf3d
|
@ -83,11 +83,11 @@ fn main() -> () {
|
|||
let testnet_addr: SocketAddr = testnet_address_string.parse().unwrap();
|
||||
drone_addr.set_ip(testnet_addr.ip());
|
||||
|
||||
Fullnode::new(node, false, ledger_path, keypair, Some(testnet_addr))
|
||||
Fullnode::new(node, ledger_path, keypair, Some(testnet_addr))
|
||||
} else {
|
||||
node.data.leader_id = node.data.id;
|
||||
|
||||
Fullnode::new(node, true, ledger_path, keypair, None)
|
||||
Fullnode::new(node, ledger_path, keypair, None)
|
||||
};
|
||||
|
||||
let mut client = mk_client(&repl_clone);
|
||||
|
|
|
@ -51,14 +51,13 @@ impl Config {
|
|||
impl Fullnode {
|
||||
fn new_internal(
|
||||
node: TestNode,
|
||||
leader: bool,
|
||||
ledger_path: &str,
|
||||
keypair: Keypair,
|
||||
network_entry_for_validator: Option<SocketAddr>,
|
||||
leader_addr: Option<SocketAddr>,
|
||||
sigverify_disabled: bool,
|
||||
) -> Self {
|
||||
info!("creating bank...");
|
||||
let bank = Bank::new_default(leader);
|
||||
let bank = Bank::new_default(leader_addr.is_some());
|
||||
|
||||
let entries = read_ledger(ledger_path, true).expect("opening ledger");
|
||||
|
||||
|
@ -79,7 +78,6 @@ impl Fullnode {
|
|||
);
|
||||
let exit = Arc::new(AtomicBool::new(false));
|
||||
Self::new_with_bank(
|
||||
leader,
|
||||
keypair,
|
||||
bank,
|
||||
entry_height,
|
||||
|
@ -87,13 +85,12 @@ impl Fullnode {
|
|||
node,
|
||||
exit,
|
||||
ledger_path,
|
||||
network_entry_for_validator,
|
||||
sigverify_disabled,
|
||||
leader_addr,
|
||||
)
|
||||
}
|
||||
|
||||
fn new_with_bank(
|
||||
leader: bool,
|
||||
keypair: Keypair,
|
||||
bank: Bank,
|
||||
entry_height: u64,
|
||||
|
@ -101,79 +98,70 @@ impl Fullnode {
|
|||
mut node: TestNode,
|
||||
exit: Arc<AtomicBool>,
|
||||
ledger_path: &str,
|
||||
network_entry_for_validator: Option<SocketAddr>,
|
||||
sigverify_disabled: bool,
|
||||
leader_addr: Option<SocketAddr>,
|
||||
) -> Self {
|
||||
let local_requests_addr = node.sockets.requests.local_addr().unwrap();
|
||||
let requests_addr = node.data.contact_info.rpu;
|
||||
if !leader {
|
||||
let testnet_addr = network_entry_for_validator.expect("validator requires entry");
|
||||
|
||||
let network_entry_point = NodeInfo::new_entry_point(testnet_addr);
|
||||
let server = Self::new_validator(
|
||||
keypair,
|
||||
bank,
|
||||
entry_height,
|
||||
&ledger_tail,
|
||||
node,
|
||||
&network_entry_point,
|
||||
exit.clone(),
|
||||
Some(ledger_path),
|
||||
sigverify_disabled,
|
||||
);
|
||||
info!(
|
||||
match leader_addr {
|
||||
Some(leader_addr) => {
|
||||
let network_entry_point = NodeInfo::new_entry_point(leader_addr);
|
||||
let server = Self::new_validator(
|
||||
keypair,
|
||||
bank,
|
||||
entry_height,
|
||||
&ledger_tail,
|
||||
node,
|
||||
&network_entry_point,
|
||||
exit.clone(),
|
||||
Some(ledger_path),
|
||||
sigverify_disabled,
|
||||
);
|
||||
info!(
|
||||
"validator ready... local request address: {} (advertising {}) connected to: {}",
|
||||
local_requests_addr, requests_addr, testnet_addr
|
||||
local_requests_addr, requests_addr, leader_addr
|
||||
);
|
||||
server
|
||||
} else {
|
||||
node.data.leader_id = node.data.id;
|
||||
server
|
||||
}
|
||||
None => {
|
||||
node.data.leader_id = node.data.id;
|
||||
|
||||
let server = Self::new_leader(
|
||||
keypair,
|
||||
bank,
|
||||
entry_height,
|
||||
&ledger_tail,
|
||||
node,
|
||||
exit.clone(),
|
||||
ledger_path,
|
||||
sigverify_disabled,
|
||||
);
|
||||
info!(
|
||||
"leader ready... local request address: {} (advertising {})",
|
||||
local_requests_addr, requests_addr
|
||||
);
|
||||
server
|
||||
let server = Self::new_leader(
|
||||
keypair,
|
||||
bank,
|
||||
entry_height,
|
||||
&ledger_tail,
|
||||
node,
|
||||
exit.clone(),
|
||||
ledger_path,
|
||||
sigverify_disabled,
|
||||
);
|
||||
info!(
|
||||
"leader ready... local request address: {} (advertising {})",
|
||||
local_requests_addr, requests_addr
|
||||
);
|
||||
server
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(
|
||||
node: TestNode,
|
||||
leader: bool,
|
||||
ledger: &str,
|
||||
keypair: Keypair,
|
||||
network_entry_for_validator: Option<SocketAddr>,
|
||||
) -> Self {
|
||||
Self::new_internal(
|
||||
node,
|
||||
leader,
|
||||
ledger,
|
||||
keypair,
|
||||
network_entry_for_validator,
|
||||
false,
|
||||
)
|
||||
Self::new_internal(node, ledger, keypair, network_entry_for_validator, false)
|
||||
}
|
||||
|
||||
pub fn new_without_sigverify(
|
||||
node: TestNode,
|
||||
leader: bool,
|
||||
ledger_path: &str,
|
||||
keypair: Keypair,
|
||||
network_entry_for_validator: Option<SocketAddr>,
|
||||
) -> Self {
|
||||
Self::new_internal(
|
||||
node,
|
||||
leader,
|
||||
ledger_path,
|
||||
keypair,
|
||||
network_entry_for_validator,
|
||||
|
|
|
@ -145,7 +145,7 @@ fn test_multi_node_ledger_window() -> result::Result<()> {
|
|||
writer.write_entries(entries).unwrap();
|
||||
}
|
||||
|
||||
let leader = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None);
|
||||
let leader = Fullnode::new(leader, &leader_ledger_path, leader_keypair, None);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance =
|
||||
|
@ -159,7 +159,6 @@ fn test_multi_node_ledger_window() -> result::Result<()> {
|
|||
let validator_data = validator.data.clone();
|
||||
let validator = Fullnode::new(
|
||||
validator,
|
||||
false,
|
||||
&zero_ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
|
@ -218,7 +217,7 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
|
|||
);
|
||||
ledger_paths.push(zero_ledger_path.clone());
|
||||
|
||||
let server = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None);
|
||||
let server = Fullnode::new(leader, &leader_ledger_path, leader_keypair, None);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance =
|
||||
|
@ -237,7 +236,6 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
|
|||
|
||||
let mut val = Fullnode::new(
|
||||
validator,
|
||||
false,
|
||||
&ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
|
@ -272,7 +270,6 @@ fn test_multi_node_validator_catchup_from_zero() -> result::Result<()> {
|
|||
let validator = TestNode::new_localhost_with_pubkey(keypair.pubkey());
|
||||
let val = Fullnode::new(
|
||||
validator,
|
||||
false,
|
||||
&zero_ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
|
@ -335,7 +332,7 @@ fn test_multi_node_basic() {
|
|||
|
||||
let (alice, leader_ledger_path) = genesis("multi_node_basic", 10_000);
|
||||
ledger_paths.push(leader_ledger_path.clone());
|
||||
let server = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None);
|
||||
let server = Fullnode::new(leader, &leader_ledger_path, leader_keypair, None);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance =
|
||||
|
@ -350,7 +347,6 @@ fn test_multi_node_basic() {
|
|||
ledger_paths.push(ledger_path.clone());
|
||||
let val = Fullnode::new(
|
||||
validator,
|
||||
false,
|
||||
&ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
|
@ -396,7 +392,7 @@ fn test_boot_validator_from_file() -> result::Result<()> {
|
|||
ledger_paths.push(leader_ledger_path.clone());
|
||||
|
||||
let leader_data = leader.data.clone();
|
||||
let leader_fullnode = Fullnode::new(leader, true, &leader_ledger_path, leader_keypair, None);
|
||||
let leader_fullnode = Fullnode::new(leader, &leader_ledger_path, leader_keypair, None);
|
||||
let leader_balance =
|
||||
send_tx_and_retry_get_balance(&leader_data, &alice, &bob_pubkey, Some(500)).unwrap();
|
||||
assert_eq!(leader_balance, 500);
|
||||
|
@ -411,7 +407,6 @@ fn test_boot_validator_from_file() -> result::Result<()> {
|
|||
ledger_paths.push(ledger_path.clone());
|
||||
let val_fullnode = Fullnode::new(
|
||||
validator,
|
||||
false,
|
||||
&ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
|
@ -433,7 +428,7 @@ fn create_leader(ledger_path: &str) -> (NodeInfo, Fullnode) {
|
|||
let leader_keypair = Keypair::new();
|
||||
let leader = TestNode::new_localhost_with_pubkey(leader_keypair.pubkey());
|
||||
let leader_data = leader.data.clone();
|
||||
let leader_fullnode = Fullnode::new(leader, true, &ledger_path, leader_keypair, None);
|
||||
let leader_fullnode = Fullnode::new(leader, &ledger_path, leader_keypair, None);
|
||||
(leader_data, leader_fullnode)
|
||||
}
|
||||
|
||||
|
@ -480,7 +475,6 @@ fn test_leader_restart_validator_start_from_old_ledger() -> result::Result<()> {
|
|||
|
||||
let val_fullnode = Fullnode::new(
|
||||
validator,
|
||||
false,
|
||||
&stale_ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
|
@ -538,8 +532,7 @@ fn test_multi_node_dynamic_network() {
|
|||
let alice_arc = Arc::new(RwLock::new(alice));
|
||||
let leader_data = leader.data.clone();
|
||||
|
||||
let server =
|
||||
Fullnode::new_without_sigverify(leader, true, &leader_ledger_path, leader_keypair, None);
|
||||
let server = Fullnode::new_without_sigverify(leader, &leader_ledger_path, leader_keypair, None);
|
||||
|
||||
// Send leader some tokens to vote
|
||||
let leader_balance = send_tx_and_retry_get_balance(
|
||||
|
@ -609,7 +602,6 @@ fn test_multi_node_dynamic_network() {
|
|||
info!("starting {} {:x}", keypair.pubkey(), rd.debug_id());
|
||||
let val = Fullnode::new_without_sigverify(
|
||||
validator,
|
||||
false,
|
||||
&ledger_path,
|
||||
keypair,
|
||||
Some(leader_data.contact_info.ncp),
|
||||
|
|
Loading…
Reference in New Issue