Skip to content

Commit 7e2d60e

Browse files
committed
chore: Address PR comments from Aaron
1 parent d1ea60a commit 7e2d60e

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

stackslib/src/burnchains/bitcoin/indexer.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,34 +264,31 @@ impl BitcoinIndexer {
264264
match net::TcpStream::connect((self.config.peer_host.as_str(), self.config.peer_port)) {
265265
Ok(s) => {
266266
// Disable Nagle algorithm
267-
s.set_nodelay(true).map_err(|_e| {
268-
test_debug!("Failed to set TCP_NODELAY: {:?}", &_e);
267+
s.set_nodelay(true).map_err(|e| {
268+
test_debug!("Failed to set TCP_NODELAY: {e:?}");
269269
btc_error::ConnectionError
270270
})?;
271271

272272
// set timeout
273273
s.set_read_timeout(Some(Duration::from_secs(self.runtime.timeout)))
274-
.map_err(|_e| {
275-
test_debug!("Failed to set TCP read timeout: {:?}", &_e);
274+
.map_err(|e| {
275+
test_debug!("Failed to set TCP read timeout: {e:?}");
276276
btc_error::ConnectionError
277277
})?;
278278

279279
s.set_write_timeout(Some(Duration::from_secs(self.runtime.timeout)))
280-
.map_err(|_e| {
281-
test_debug!("Failed to set TCP write timeout: {:?}", &_e);
280+
.map_err(|e| {
281+
test_debug!("Failed to set TCP write timeout: {e:?}");
282282
btc_error::ConnectionError
283283
})?;
284284

285-
if let Some(s) = self.runtime.sock.take() {
286-
let _ = s.shutdown(Shutdown::Both);
285+
if let Some(s_old) = self.runtime.sock.replace(s) {
286+
let _ = s_old.shutdown(Shutdown::Both);
287287
}
288-
289-
self.runtime.sock = Some(s);
290288
Ok(())
291289
}
292290
Err(_e) => {
293-
let s = self.runtime.sock.take();
294-
if let Some(s) = s {
291+
if let Some(s) = self.runtime.sock.take() {
295292
let _ = s.shutdown(Shutdown::Both);
296293
}
297294
Err(btc_error::ConnectionError)

stackslib/src/burnchains/tests/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,8 @@ impl TestBurnchainBlock {
579579
pub fn patch_from_chain_tip(&mut self, parent_snapshot: &BlockSnapshot) {
580580
assert_eq!(parent_snapshot.block_height + 1, self.block_height);
581581

582-
for i in 0..self.txs.len() {
583-
if let BlockstackOperationType::LeaderKeyRegister(ref mut data) = self.txs[i] {
582+
for tx in self.txs.iter_mut() {
583+
if let BlockstackOperationType::LeaderKeyRegister(ref mut data) = tx {
584584
assert_eq!(data.block_height, self.block_height);
585585
data.consensus_hash = parent_snapshot.consensus_hash.clone();
586586
}

0 commit comments

Comments
 (0)