Move thin_client RPC requests into rpc_request; de-mut thin_client
This commit is contained in:
@ -28,7 +28,7 @@ pub fn spend_and_verify_all_nodes(
|
||||
assert!(cluster_nodes.len() >= nodes);
|
||||
for ingress_node in &cluster_nodes {
|
||||
let random_keypair = Keypair::new();
|
||||
let mut client = create_client(ingress_node.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
let client = create_client(ingress_node.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
let bal = client
|
||||
.poll_get_balance(&funding_keypair.pubkey())
|
||||
.expect("balance in source");
|
||||
@ -44,14 +44,14 @@ pub fn spend_and_verify_all_nodes(
|
||||
.retry_transfer(&funding_keypair, &mut transaction, 5)
|
||||
.unwrap();
|
||||
for validator in &cluster_nodes {
|
||||
let mut client = create_client(validator.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
let client = create_client(validator.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
client.poll_for_signature(&sig).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send_many_transactions(node: &ContactInfo, funding_keypair: &Keypair, num_txs: u64) {
|
||||
let mut client = create_client(node.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
let client = create_client(node.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
for _ in 0..num_txs {
|
||||
let random_keypair = Keypair::new();
|
||||
let bal = client
|
||||
@ -75,12 +75,12 @@ pub fn fullnode_exit(entry_point_info: &ContactInfo, nodes: usize) {
|
||||
let cluster_nodes = discover(&entry_point_info.gossip, nodes).unwrap();
|
||||
assert!(cluster_nodes.len() >= nodes);
|
||||
for node in &cluster_nodes {
|
||||
let mut client = create_client(node.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
let client = create_client(node.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
assert!(client.fullnode_exit().unwrap());
|
||||
}
|
||||
sleep(Duration::from_millis(SLOT_MILLIS));
|
||||
for node in &cluster_nodes {
|
||||
let mut client = create_client(node.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
let client = create_client(node.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
assert!(client.fullnode_exit().is_err());
|
||||
}
|
||||
}
|
||||
@ -126,7 +126,7 @@ pub fn kill_entry_and_spend_and_verify_rest(
|
||||
solana_logger::setup();
|
||||
let cluster_nodes = discover(&entry_point_info.gossip, nodes).unwrap();
|
||||
assert!(cluster_nodes.len() >= nodes);
|
||||
let mut client = create_client(entry_point_info.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
let client = create_client(entry_point_info.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
info!("sleeping for an epoch");
|
||||
sleep(Duration::from_millis(SLOT_MILLIS * DEFAULT_SLOTS_PER_EPOCH));
|
||||
info!("done sleeping for an epoch");
|
||||
@ -140,7 +140,7 @@ pub fn kill_entry_and_spend_and_verify_rest(
|
||||
continue;
|
||||
}
|
||||
|
||||
let mut client = create_client(ingress_node.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
let client = create_client(ingress_node.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
let bal = client
|
||||
.poll_get_balance(&funding_keypair.pubkey())
|
||||
.expect("balance in source");
|
||||
@ -195,7 +195,7 @@ fn poll_all_nodes_for_signature(
|
||||
if validator.id == entry_point_info.id {
|
||||
continue;
|
||||
}
|
||||
let mut client = create_client(validator.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
let client = create_client(validator.client_facing_addr(), FULLNODE_PORT_RANGE);
|
||||
client.poll_for_signature(&sig)?;
|
||||
}
|
||||
|
||||
|
@ -115,7 +115,7 @@ impl LocalCluster {
|
||||
}
|
||||
|
||||
fn add_validator(&mut self, fullnode_config: &FullnodeConfig, stake: u64) {
|
||||
let mut client = create_client(
|
||||
let client = create_client(
|
||||
self.entry_point_info.client_facing_addr(),
|
||||
FULLNODE_PORT_RANGE,
|
||||
);
|
||||
@ -131,19 +131,14 @@ impl LocalCluster {
|
||||
|
||||
// Send each validator some lamports to vote
|
||||
let validator_balance =
|
||||
Self::transfer(&mut client, &self.funding_keypair, &validator_pubkey, stake);
|
||||
Self::transfer(&client, &self.funding_keypair, &validator_pubkey, stake);
|
||||
info!(
|
||||
"validator {} balance {}",
|
||||
validator_pubkey, validator_balance
|
||||
);
|
||||
|
||||
Self::create_and_fund_vote_account(
|
||||
&mut client,
|
||||
&voting_keypair,
|
||||
&validator_keypair,
|
||||
stake - 1,
|
||||
)
|
||||
.unwrap();
|
||||
Self::create_and_fund_vote_account(&client, &voting_keypair, &validator_keypair, stake - 1)
|
||||
.unwrap();
|
||||
|
||||
let validator_server = Fullnode::new(
|
||||
validator_node,
|
||||
@ -160,13 +155,13 @@ impl LocalCluster {
|
||||
|
||||
fn add_replicator(&mut self) {
|
||||
let replicator_keypair = Arc::new(Keypair::new());
|
||||
let mut client = create_client(
|
||||
let client = create_client(
|
||||
self.entry_point_info.client_facing_addr(),
|
||||
FULLNODE_PORT_RANGE,
|
||||
);
|
||||
|
||||
Self::transfer(
|
||||
&mut client,
|
||||
&client,
|
||||
&self.funding_keypair,
|
||||
&replicator_keypair.pubkey(),
|
||||
1,
|
||||
@ -196,7 +191,7 @@ impl LocalCluster {
|
||||
}
|
||||
|
||||
fn transfer(
|
||||
client: &mut ThinClient,
|
||||
client: &ThinClient,
|
||||
source_keypair: &Keypair,
|
||||
dest_pubkey: &Pubkey,
|
||||
lamports: u64,
|
||||
@ -218,7 +213,7 @@ impl LocalCluster {
|
||||
}
|
||||
|
||||
fn create_and_fund_vote_account(
|
||||
client: &mut ThinClient,
|
||||
client: &ThinClient,
|
||||
vote_account: &Keypair,
|
||||
from_account: &Arc<Keypair>,
|
||||
amount: u64,
|
||||
|
@ -310,11 +310,11 @@ impl Replicator {
|
||||
}
|
||||
|
||||
fn submit_mining_proof(&self) {
|
||||
let mut client = create_client(
|
||||
let client = create_client(
|
||||
self.cluster_entrypoint.client_facing_addr(),
|
||||
FULLNODE_PORT_RANGE,
|
||||
);
|
||||
Self::get_airdrop_lamports(&mut client, &self.keypair, &self.cluster_entrypoint);
|
||||
Self::get_airdrop_lamports(&client, &self.keypair, &self.cluster_entrypoint);
|
||||
|
||||
let blockhash = client.get_recent_blockhash();
|
||||
let mut tx = StorageTransaction::new_mining_proof(
|
||||
@ -378,7 +378,7 @@ impl Replicator {
|
||||
}
|
||||
|
||||
fn get_airdrop_lamports(
|
||||
client: &mut ThinClient,
|
||||
client: &ThinClient,
|
||||
keypair: &Keypair,
|
||||
cluster_entrypoint: &ContactInfo,
|
||||
) {
|
||||
|
@ -228,7 +228,7 @@ impl StorageStage {
|
||||
account_to_create: Option<Pubkey>,
|
||||
) -> io::Result<()> {
|
||||
let contact_info = cluster_info.read().unwrap().my_data();
|
||||
let mut client = create_client_with_timeout(
|
||||
let client = create_client_with_timeout(
|
||||
contact_info.client_facing_addr(),
|
||||
FULLNODE_PORT_RANGE,
|
||||
Duration::from_secs(5),
|
||||
|
Reference in New Issue
Block a user