Skip to content

Commit

Permalink
chore: improve code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kantai committed Jul 2, 2024
1 parent c5c223d commit e400ddc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions stacks-signer/src/client/stackerdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
2 changes: 1 addition & 1 deletion stackslib/src/net/api/postblock_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl HttpResponse for RPCPostBlockRequestHandler {
body: &[u8],
) -> Result<HttpResponsePayload, Error> {
let accepted: StacksBlockAcceptedData = parse_json(preamble, body)?;
Ok(HttpResponsePayload::try_from_json(accepted)?)
HttpResponsePayload::try_from_json(accepted)
}
}

Expand Down
10 changes: 6 additions & 4 deletions testnet/stacks-node/src/nakamoto_node/sign_coordinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ impl SignCoordinator {
.expect("FATAL: tried to initialize WSTS coordinator before first burn block height")
}

fn send_signers_message<M: StacksMessageCodec>(
/// Send a message over the miners contract using a `Scalar` private key
fn send_miners_message_scalar<M: StacksMessageCodec>(
message_key: &Scalar,
sortdb: &SortitionDB,
tip: &BlockSnapshot,
Expand All @@ -355,6 +356,7 @@ impl SignCoordinator {
)
}

/// Send a message over the miners contract using a `StacksPrivateKey`
pub fn send_miners_message<M: StacksMessageCodec>(
miner_sk: &StacksPrivateKey,
sortdb: &SortitionDB,
Expand Down Expand Up @@ -439,7 +441,7 @@ impl SignCoordinator {
"Failed to start signing round in FIRE coordinator: {e:?}"
))
})?;
Self::send_signers_message::<SignerMessageV1>(
Self::send_miners_message_scalar::<SignerMessageV1>(
&self.message_key,
sortdb,
burn_tip,
Expand Down Expand Up @@ -591,7 +593,7 @@ impl SignCoordinator {
}
}
for msg in outbound_msgs {
match Self::send_signers_message::<SignerMessageV1>(
match Self::send_miners_message_scalar::<SignerMessageV1>(
&self.message_key,
sortdb,
burn_tip,
Expand Down Expand Up @@ -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::<SignerMessageV0>(
Self::send_miners_message_scalar::<SignerMessageV0>(
&self.message_key,
sortdb,
burn_tip,
Expand Down

0 comments on commit e400ddc

Please sign in to comment.