Skip to content

Commit

Permalink
chore: revert change moving request creation out of loop
Browse files Browse the repository at this point in the history
This avoids a clone in the happy case (where no retry is needed).
  • Loading branch information
obycode committed Oct 18, 2024
1 parent 334cf0f commit 2b36268
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions testnet/stacks-node/src/event_dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,16 +434,16 @@ impl EventObserver {
// Cap the backoff at 3x the timeout
let max_backoff = timeout.saturating_mul(3);

let mut request = StacksHttpRequest::new_for_peer(
peerhost.clone(),
"POST".into(),
url.path().into(),
HttpRequestContents::new().payload_json(payload.clone()),
)
.unwrap_or_else(|_| panic!("FATAL: failed to encode infallible data as HTTP request"));
request.add_header("Connection".into(), "close".into());
loop {
match send_http_request(host, port, request.clone(), timeout) {
let mut request = StacksHttpRequest::new_for_peer(
peerhost.clone(),
"POST".into(),
url.path().into(),
HttpRequestContents::new().payload_json(payload.clone()),
)
.unwrap_or_else(|_| panic!("FATAL: failed to encode infallible data as HTTP request"));
request.add_header("Connection".into(), "close".into());
match send_http_request(host, port, request, timeout) {
Ok(response) => {
if response.preamble().status_code == 200 {
debug!(
Expand Down

0 comments on commit 2b36268

Please sign in to comment.