From e400ddc582a4f6f42d6500dbf6cdb710e29a74fa Mon Sep 17 00:00:00 2001 From: Aaron Blankstein Date: Tue, 2 Jul 2024 12:03:09 -0500 Subject: [PATCH] chore: improve code comments --- stacks-signer/src/client/stackerdb.rs | 5 +++-- stackslib/src/net/api/postblock_v3.rs | 2 +- .../stacks-node/src/nakamoto_node/sign_coordinator.rs | 10 ++++++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/stacks-signer/src/client/stackerdb.rs b/stacks-signer/src/client/stackerdb.rs index 499bdddd5f..7303d3f967 100644 --- a/stacks-signer/src/client/stackerdb.rs +++ b/stacks-signer/src/client/stackerdb.rs @@ -290,12 +290,13 @@ mod tests { }; let mock_server = mock_server_from_config(&config); debug!("Spawning msg sender"); - let h = spawn(move || stackerdb.send_message_with_retry(signer_message).unwrap()); + let sender_thread = + spawn(move || stackerdb.send_message_with_retry(signer_message).unwrap()); let mut response_bytes = b"HTTP/1.1 200 OK\n\n".to_vec(); let payload = serde_json::to_string(&ack).expect("Failed to serialize ack"); response_bytes.extend(payload.as_bytes()); std::thread::sleep(Duration::from_millis(500)); write_response(mock_server, response_bytes.as_slice()); - assert_eq!(ack, h.join().unwrap()); + assert_eq!(ack, sender_thread.join().unwrap()); } } diff --git a/stackslib/src/net/api/postblock_v3.rs b/stackslib/src/net/api/postblock_v3.rs index f7f595913a..2754d4dc56 100644 --- a/stackslib/src/net/api/postblock_v3.rs +++ b/stackslib/src/net/api/postblock_v3.rs @@ -167,7 +167,7 @@ impl HttpResponse for RPCPostBlockRequestHandler { body: &[u8], ) -> Result { let accepted: StacksBlockAcceptedData = parse_json(preamble, body)?; - Ok(HttpResponsePayload::try_from_json(accepted)?) + HttpResponsePayload::try_from_json(accepted) } } diff --git a/testnet/stacks-node/src/nakamoto_node/sign_coordinator.rs b/testnet/stacks-node/src/nakamoto_node/sign_coordinator.rs index 63f46a9557..8a6b5312b7 100644 --- a/testnet/stacks-node/src/nakamoto_node/sign_coordinator.rs +++ b/testnet/stacks-node/src/nakamoto_node/sign_coordinator.rs @@ -331,7 +331,8 @@ impl SignCoordinator { .expect("FATAL: tried to initialize WSTS coordinator before first burn block height") } - fn send_signers_message( + /// Send a message over the miners contract using a `Scalar` private key + fn send_miners_message_scalar( message_key: &Scalar, sortdb: &SortitionDB, tip: &BlockSnapshot, @@ -355,6 +356,7 @@ impl SignCoordinator { ) } + /// Send a message over the miners contract using a `StacksPrivateKey` pub fn send_miners_message( miner_sk: &StacksPrivateKey, sortdb: &SortitionDB, @@ -439,7 +441,7 @@ impl SignCoordinator { "Failed to start signing round in FIRE coordinator: {e:?}" )) })?; - Self::send_signers_message::( + Self::send_miners_message_scalar::( &self.message_key, sortdb, burn_tip, @@ -591,7 +593,7 @@ impl SignCoordinator { } } for msg in outbound_msgs { - match Self::send_signers_message::( + match Self::send_miners_message_scalar::( &self.message_key, sortdb, burn_tip, @@ -653,7 +655,7 @@ impl SignCoordinator { debug!("Sending block proposal message to signers"; "signer_signature_hash" => ?&block.header.signer_signature_hash().0, ); - Self::send_signers_message::( + Self::send_miners_message_scalar::( &self.message_key, sortdb, burn_tip,