Skip to content

Commit 30751e6

Browse files
committed
crc: code improvements from pr feedback
1 parent 3f4a052 commit 30751e6

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

libsigner/src/v0/signer_state.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl GlobalStateEvaluator {
136136
burn_block,
137137
burn_block_height,
138138
current_miner,
139-
ReplayTransactionSet::new(vec![]),
139+
ReplayTransactionSet::none(),
140140
),
141141
StateMachineUpdateContent::V1 {
142142
burn_block,
@@ -207,16 +207,8 @@ impl ReplayTransactionSet {
207207
self.0.is_empty()
208208
}
209209

210-
/// Unwrap the `ReplayTransactionSet`. Panics if the set is empty.
211-
pub fn unwrap(self) -> Vec<StacksTransaction> {
212-
if self.is_empty() {
213-
panic!("Called `unwrap` on an empty `ReplayTransactionSet`");
214-
}
215-
self.0
216-
}
217-
218210
/// Map into an optional, returning `None` if the set is empty
219-
pub fn into_optional(&self) -> Option<Vec<StacksTransaction>> {
211+
pub fn clone_as_optional(&self) -> Option<Vec<StacksTransaction>> {
220212
if self.is_empty() {
221213
None
222214
} else {
@@ -229,7 +221,7 @@ impl ReplayTransactionSet {
229221
if self.is_empty() {
230222
vec![]
231223
} else {
232-
self.unwrap()
224+
self.0
233225
}
234226
}
235227

stacks-signer/src/v0/signer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ impl Signer {
16411641
self.global_state_evaluator
16421642
.get_global_tx_replay_set()
16431643
.unwrap_or_default()
1644-
.into_optional()
1644+
.clone_as_optional()
16451645
} else {
16461646
None
16471647
},

stacks-signer/src/v0/signer_state.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ impl LocalStateMachine {
384384
};
385385

386386
if let Some(replay_set_hash) = NakamotoBlockProposal::tx_replay_hash(
387-
&prior_state_machine.tx_replay_set.into_optional(),
387+
&prior_state_machine.tx_replay_set.clone_as_optional(),
388388
) {
389389
match db.get_was_block_validated_by_replay_tx(signer_signature_hash, replay_set_hash) {
390390
Ok(Some(BlockValidatedByReplaySet {
@@ -674,7 +674,7 @@ impl LocalStateMachine {
674674
burn_block_height: *burn_block_height,
675675
current_miner: current_miner.into(),
676676
active_signer_protocol_version,
677-
tx_replay_set: tx_replay_set.clone(),
677+
tx_replay_set,
678678
});
679679
// Because we updated our active signer protocol version, update local_update so its included in the subsequent evaluations
680680
let Ok(update) =
@@ -877,7 +877,7 @@ impl LocalStateMachine {
877877
let Self::Initialized(state) = self else {
878878
return None;
879879
};
880-
state.tx_replay_set.into_optional()
880+
state.tx_replay_set.clone_as_optional()
881881
}
882882

883883
/// Handle a possible bitcoin fork. If a fork is detetected,

stackslib/src/net/api/postblock_proposal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ pub struct BlockValidateOk {
176176
pub size: u64,
177177
pub validation_time_ms: u64,
178178
/// If a block was validated by a transaction replay set,
179-
/// then this return Some with the hash of the replay set.
179+
/// then this returns `Some` with the hash of the replay set.
180180
pub replay_tx_hash: Option<u64>,
181181
/// If a block was validated by a transaction replay set,
182182
/// then this is true if this block exhausted the set of transactions.

0 commit comments

Comments
 (0)