Skip to content

Commit 629d032

Browse files
authored
Merge branch 'develop' into fix/5159
2 parents 9ad8852 + dd3f094 commit 629d032

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

stacks-signer/src/client/stacks_client.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,16 @@ impl StacksClient {
439439
chosen_parent: &ConsensusHash,
440440
last_sortition: &ConsensusHash,
441441
) -> Result<VecDeque<TenureForkingInfo>, ClientError> {
442+
let path = self.tenure_forking_info_path(chosen_parent, last_sortition);
443+
let timer = crate::monitoring::new_rpc_call_timer(&path, &self.http_origin);
442444
let send_request = || {
443445
self.stacks_node_client
444-
.get(self.tenure_forking_info_path(chosen_parent, last_sortition))
446+
.get(&path)
445447
.send()
446448
.map_err(backoff::Error::transient)
447449
};
448450
let response = retry_with_exponential_backoff(send_request)?;
451+
timer.stop_and_record();
449452
if !response.status().is_success() {
450453
return Err(ClientError::RequestFailure(response.status()));
451454
}
@@ -456,16 +459,16 @@ impl StacksClient {
456459

457460
/// Get the sortition information for the latest sortition
458461
pub fn get_latest_sortition(&self) -> Result<SortitionInfo, ClientError> {
462+
let path = self.sortition_info_path();
463+
let timer = crate::monitoring::new_rpc_call_timer(&path, &self.http_origin);
459464
let send_request = || {
460-
self.stacks_node_client
461-
.get(self.sortition_info_path())
462-
.send()
463-
.map_err(|e| {
464-
warn!("Signer failed to request latest sortition"; "err" => ?e);
465-
e
466-
})
465+
self.stacks_node_client.get(&path).send().map_err(|e| {
466+
warn!("Signer failed to request latest sortition"; "err" => ?e);
467+
e
468+
})
467469
};
468470
let response = send_request()?;
471+
timer.stop_and_record();
469472
if !response.status().is_success() {
470473
return Err(ClientError::RequestFailure(response.status()));
471474
}
@@ -475,16 +478,16 @@ impl StacksClient {
475478

476479
/// Get the sortition information for a given sortition
477480
pub fn get_sortition(&self, ch: &ConsensusHash) -> Result<SortitionInfo, ClientError> {
481+
let path = format!("{}/consensus/{}", self.sortition_info_path(), ch.to_hex());
482+
let timer = crate::monitoring::new_rpc_call_timer(&path, &self.http_origin);
478483
let send_request = || {
479-
self.stacks_node_client
480-
.get(format!("{}/consensus/{}", self.sortition_info_path(), ch.to_hex()))
481-
.send()
482-
.map_err(|e| {
483-
warn!("Signer failed to request sortition"; "consensus_hash" => %ch, "err" => ?e);
484-
e
485-
})
484+
self.stacks_node_client.get(&path).send().map_err(|e| {
485+
warn!("Signer failed to request sortition"; "consensus_hash" => %ch, "err" => ?e);
486+
e
487+
})
486488
};
487489
let response = send_request()?;
490+
timer.stop_and_record();
488491
if !response.status().is_success() {
489492
return Err(ClientError::RequestFailure(response.status()));
490493
}
@@ -582,7 +585,6 @@ impl StacksClient {
582585
/// Retrieve the current pox data from the stacks node
583586
pub fn get_pox_data(&self) -> Result<RPCPoxInfoData, ClientError> {
584587
debug!("Getting pox data...");
585-
#[cfg(feature = "monitoring_prom")]
586588
let timer = crate::monitoring::new_rpc_call_timer(&self.pox_path(), &self.http_origin);
587589
let send_request = || {
588590
self.stacks_node_client
@@ -591,7 +593,6 @@ impl StacksClient {
591593
.map_err(backoff::Error::transient)
592594
};
593595
let response = retry_with_exponential_backoff(send_request)?;
594-
#[cfg(feature = "monitoring_prom")]
595596
timer.stop_and_record();
596597
if !response.status().is_success() {
597598
return Err(ClientError::RequestFailure(response.status()));
@@ -706,13 +707,11 @@ impl StacksClient {
706707
/// Returns `true` if the block was accepted or `false` if the block
707708
/// was rejected.
708709
pub fn post_block(&self, block: &NakamotoBlock) -> Result<bool, ClientError> {
710+
let path = format!("{}{}?broadcast=1", self.http_origin, postblock_v3::PATH);
711+
let timer = crate::monitoring::new_rpc_call_timer(&path, &self.http_origin);
709712
let send_request = || {
710713
self.stacks_node_client
711-
.post(format!(
712-
"{}{}?broadcast=1",
713-
self.http_origin,
714-
postblock_v3::PATH
715-
))
714+
.post(&path)
716715
.header("Content-Type", "application/octet-stream")
717716
.header(AUTHORIZATION, self.auth_password.clone())
718717
.body(block.serialize_to_vec())
@@ -723,6 +722,7 @@ impl StacksClient {
723722
})
724723
};
725724
let response = retry_with_exponential_backoff(send_request)?;
725+
timer.stop_and_record();
726726
if !response.status().is_success() {
727727
return Err(ClientError::RequestFailure(response.status()));
728728
}

0 commit comments

Comments
 (0)