SendTransactionServices now exit their thread on channel drop instead of by a flag

This commit is contained in:
Michael Vines
2020-09-18 09:17:04 -07:00
committed by mergify[bot]
parent 75c3690ccd
commit c4913e3c9e
5 changed files with 52 additions and 74 deletions

View File

@@ -218,7 +218,7 @@ impl JsonRpcRequestProcessor {
let cluster_info = Arc::new(ClusterInfo::default());
let tpu_address = cluster_info.my_contact_info().tpu;
let (sender, receiver) = channel();
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
SendTransactionService::new(tpu_address, &bank_forks, None, receiver);
Self {
config: JsonRpcConfig::default(),
@@ -2686,7 +2686,7 @@ pub mod tests {
&runtime::Runtime::new().unwrap(),
None,
);
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
SendTransactionService::new(tpu_address, &bank_forks, None, receiver);
cluster_info.insert_info(ContactInfo::new_with_pubkey_socketaddr(
&leader_pubkey,
@@ -3998,7 +3998,7 @@ pub mod tests {
&runtime::Runtime::new().unwrap(),
None,
);
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
SendTransactionService::new(tpu_address, &bank_forks, None, receiver);
let req = r#"{"jsonrpc":"2.0","id":1,"method":"sendTransaction","params":["37u9WtQpcm6ULa3Vmu7ySnANv"]}"#;
let res = io.handle_request_sync(req, meta);
@@ -4039,7 +4039,7 @@ pub mod tests {
&runtime::Runtime::new().unwrap(),
None,
);
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
SendTransactionService::new(tpu_address, &bank_forks, None, receiver);
let mut bad_transaction =
system_transaction::transfer(&mint_keypair, &Pubkey::new_rand(), 42, Hash::default());
@@ -4221,7 +4221,7 @@ pub mod tests {
&runtime::Runtime::new().unwrap(),
None,
);
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
SendTransactionService::new(tpu_address, &bank_forks, None, receiver);
assert_eq!(request_processor.validator_exit(), false);
assert_eq!(exit.load(Ordering::Relaxed), false);
}
@@ -4250,7 +4250,7 @@ pub mod tests {
&runtime::Runtime::new().unwrap(),
None,
);
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
SendTransactionService::new(tpu_address, &bank_forks, None, receiver);
assert_eq!(request_processor.validator_exit(), true);
assert_eq!(exit.load(Ordering::Relaxed), true);
}
@@ -4336,7 +4336,7 @@ pub mod tests {
&runtime::Runtime::new().unwrap(),
None,
);
SendTransactionService::new(tpu_address, &bank_forks, None, &exit, receiver);
SendTransactionService::new(tpu_address, &bank_forks, None, receiver);
assert_eq!(
request_processor.get_block_commitment(0),
RpcBlockCommitment {