Skip to content

Commit 1947fc6

Browse files
committed
chore: cargo fmt
1 parent 987bdc6 commit 1947fc6

File tree

2 files changed

+47
-15
lines changed

2 files changed

+47
-15
lines changed

stackslib/src/net/download/nakamoto/tenure_downloader.rs

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,10 @@ impl NakamotoTenureDownloader {
168168
start_signer_keys,
169169
end_signer_keys,
170170
idle: false,
171-
state: NakamotoTenureDownloadState::GetTenureStartBlock(tenure_start_block_id.clone(), get_epoch_time_ms()),
171+
state: NakamotoTenureDownloadState::GetTenureStartBlock(
172+
tenure_start_block_id.clone(),
173+
get_epoch_time_ms(),
174+
),
172175
tenure_start_block: None,
173176
tenure_end_block: None,
174177
tenure_blocks: None,
@@ -236,8 +239,10 @@ impl NakamotoTenureDownloader {
236239
self.try_accept_tenure_end_block(&tenure_end_block)?;
237240
} else {
238241
// need to get tenure_end_block.
239-
self.state =
240-
NakamotoTenureDownloadState::GetTenureEndBlock(self.tenure_end_block_id.clone(), get_epoch_time_ms());
242+
self.state = NakamotoTenureDownloadState::GetTenureEndBlock(
243+
self.tenure_end_block_id.clone(),
244+
get_epoch_time_ms(),
245+
);
241246
}
242247
Ok(())
243248
}
@@ -328,7 +333,7 @@ impl NakamotoTenureDownloader {
328333
self.tenure_end_block = Some(tenure_end_block.clone());
329334
self.state = NakamotoTenureDownloadState::GetTenureBlocks(
330335
tenure_end_block.header.parent_block_id.clone(),
331-
get_epoch_time_ms()
336+
get_epoch_time_ms(),
332337
);
333338
Ok(())
334339
}
@@ -364,7 +369,9 @@ impl NakamotoTenureDownloader {
364369
&mut self,
365370
mut tenure_blocks: Vec<NakamotoBlock>,
366371
) -> Result<Option<Vec<NakamotoBlock>>, NetError> {
367-
let NakamotoTenureDownloadState::GetTenureBlocks(block_cursor, start_request_time) = &self.state else {
372+
let NakamotoTenureDownloadState::GetTenureBlocks(block_cursor, start_request_time) =
373+
&self.state
374+
else {
368375
warn!("Invalid state for this method";
369376
"state" => %self.state);
370377
return Err(NetError::InvalidState);
@@ -464,7 +471,8 @@ impl NakamotoTenureDownloader {
464471
&earliest_block.block_id(),
465472
&next_block_id
466473
);
467-
self.state = NakamotoTenureDownloadState::GetTenureBlocks(next_block_id, *start_request_time);
474+
self.state =
475+
NakamotoTenureDownloadState::GetTenureBlocks(next_block_id, *start_request_time);
468476
return Ok(None);
469477
}
470478

@@ -489,16 +497,28 @@ impl NakamotoTenureDownloader {
489497
peerhost: PeerHost,
490498
) -> Result<Option<StacksHttpRequest>, ()> {
491499
let request = match self.state {
492-
NakamotoTenureDownloadState::GetTenureStartBlock(start_block_id, start_request_time) => {
493-
debug!("Request tenure-start block {} at {}", &start_block_id, start_request_time);
500+
NakamotoTenureDownloadState::GetTenureStartBlock(
501+
start_block_id,
502+
start_request_time,
503+
) => {
504+
debug!(
505+
"Request tenure-start block {} at {}",
506+
&start_block_id, start_request_time
507+
);
494508
StacksHttpRequest::new_get_nakamoto_block(peerhost, start_block_id.clone())
495509
}
496510
NakamotoTenureDownloadState::GetTenureEndBlock(end_block_id, start_request_time) => {
497-
debug!("Request tenure-end block {} at {}", &end_block_id, start_request_time);
511+
debug!(
512+
"Request tenure-end block {} at {}",
513+
&end_block_id, start_request_time
514+
);
498515
StacksHttpRequest::new_get_nakamoto_block(peerhost, end_block_id.clone())
499516
}
500517
NakamotoTenureDownloadState::GetTenureBlocks(end_block_id, start_request_time) => {
501-
debug!("Downloading tenure ending at {} at {}", &end_block_id, start_request_time);
518+
debug!(
519+
"Downloading tenure ending at {} at {}",
520+
&end_block_id, start_request_time
521+
);
502522
StacksHttpRequest::new_get_nakamoto_tenure(peerhost, end_block_id.clone(), None)
503523
}
504524
NakamotoTenureDownloadState::Done => {
@@ -564,7 +584,8 @@ impl NakamotoTenureDownloader {
564584
NakamotoTenureDownloadState::GetTenureStartBlock(_block_id, _start_request_time) => {
565585
debug!(
566586
"Got download response for tenure-start block {} in {}ms",
567-
&_block_id, get_epoch_time_ms().saturating_sub(_start_request_time)
587+
&_block_id,
588+
get_epoch_time_ms().saturating_sub(_start_request_time)
568589
);
569590
let block = response.decode_nakamoto_block().map_err(|e| {
570591
warn!("Failed to decode response for a Nakamoto block: {:?}", &e);
@@ -574,7 +595,11 @@ impl NakamotoTenureDownloader {
574595
Ok(None)
575596
}
576597
NakamotoTenureDownloadState::GetTenureEndBlock(_block_id, _start_request_time) => {
577-
debug!("Got download response to tenure-end block {} in {}ms", &_block_id, get_epoch_time_ms().saturating_sub(_start_request_time));
598+
debug!(
599+
"Got download response to tenure-end block {} in {}ms",
600+
&_block_id,
601+
get_epoch_time_ms().saturating_sub(_start_request_time)
602+
);
578603
let block = response.decode_nakamoto_block().map_err(|e| {
579604
warn!("Failed to decode response for a Nakamoto block: {:?}", &e);
580605
e
@@ -585,7 +610,8 @@ impl NakamotoTenureDownloader {
585610
NakamotoTenureDownloadState::GetTenureBlocks(_end_block_id, _start_request_time) => {
586611
debug!(
587612
"Got download response for tenure blocks ending at {} in {}ms",
588-
&_end_block_id, get_epoch_time_ms().saturating_sub(_start_request_time)
613+
&_end_block_id,
614+
get_epoch_time_ms().saturating_sub(_start_request_time)
589615
);
590616
let blocks = response.decode_nakamoto_tenure().map_err(|e| {
591617
warn!("Failed to decode response for a Nakamoto tenure: {:?}", &e);

stackslib/src/net/download/nakamoto/tenure_downloader_set.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,10 @@ impl NakamotoTenureDownloaderSet {
461461
continue;
462462
};
463463
if downloader.is_done() {
464-
debug!("Downloader for {} on tenure {} is finished", &naddr, &downloader.tenure_id_consensus_hash);
464+
debug!(
465+
"Downloader for {} on tenure {} is finished",
466+
&naddr, &downloader.tenure_id_consensus_hash
467+
);
465468
finished.push(naddr.clone());
466469
finished_tenures.push(downloader.tenure_id_consensus_hash.clone());
467470
continue;
@@ -532,7 +535,10 @@ impl NakamotoTenureDownloaderSet {
532535
);
533536
new_blocks.insert(downloader.tenure_id_consensus_hash.clone(), blocks);
534537
if downloader.is_done() {
535-
debug!("Downloader for {} on tenure {} is finished", &naddr, &downloader.tenure_id_consensus_hash);
538+
debug!(
539+
"Downloader for {} on tenure {} is finished",
540+
&naddr, &downloader.tenure_id_consensus_hash
541+
);
536542
finished.push(naddr.clone());
537543
finished_tenures.push(downloader.tenure_id_consensus_hash.clone());
538544
continue;

0 commit comments

Comments
 (0)