Skip to content

Commit af6b2f4

Browse files
committed
fixed .into() issues, added expected Option for txindex
1 parent 2fdeb87 commit af6b2f4

File tree

12 files changed

+23
-23
lines changed

12 files changed

+23
-23
lines changed

stackslib/src/burnchains/affirmation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ fn inner_find_heaviest_block_commit_ptr(
896896
// consider ancestor candidates in _highest_-first order
897897
for ((height, vtxindex), (block_set, burnt)) in ancestor_confirmations.iter().rev() {
898898
let confs = block_set.len() as u64;
899-
if confs < anchor_threshold.into() {
899+
if confs < u64::from(anchor_threshold) {
900900
continue;
901901
}
902902

stackslib/src/chainstate/coordinator/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,7 @@ fn missed_block_commits_2_1() {
15531553
// did we have a bad missed commit in this window?
15541554
// bad missed commits land in the prepare phase.
15551555
let have_bad_missed_commit = b.is_in_prepare_phase(last_bad_op_height)
1556-
&& ix >= MINING_COMMITMENT_WINDOW.into()
1556+
&& ix >= usize::from(MINING_COMMITMENT_WINDOW)
15571557
&& last_bad_op_height + (MINING_COMMITMENT_WINDOW as u64) > tip.block_height;
15581558
if have_bad_missed_commit {
15591559
// bad commit breaks the chain if its PoX outputs are invalid
@@ -5164,7 +5164,7 @@ fn test_epoch_verify_active_pox_contract() {
51645164

51655165
let active_pox_contract = b.pox_constants.active_pox_contract(burn_block_height);
51665166

5167-
if burn_block_height <= pox_v1_unlock_ht.into() {
5167+
if burn_block_height <= u64::from(pox_v1_unlock_ht) {
51685168
assert_eq!(active_pox_contract, POX_1_NAME);
51695169
if curr_reward_cycle == 1 {
51705170
// This is a result of the first stack stx sent.

stackslib/src/chainstate/nakamoto/miner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ impl BlockBuilder for NakamotoBlockBuilder {
692692
limit_behavior: &BlockLimitFunction,
693693
ast_rules: ASTRules,
694694
) -> TransactionResult {
695-
if self.bytes_so_far + tx_len >= MAX_EPOCH_SIZE.into() {
695+
if self.bytes_so_far + tx_len >= u64::from(MAX_EPOCH_SIZE) {
696696
return TransactionResult::skipped_due_to_error(tx, Error::BlockTooBigError);
697697
}
698698

stackslib/src/chainstate/nakamoto/signer_set.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ impl NakamotoSigners {
414414
let cycle_number = value.expect_u128()?;
415415
// if the cycle_number is less than `cycle_of_prepare_phase`, we need to update
416416
// the .signers state.
417-
Ok(cycle_number < cycle_of_prepare_phase.into())
417+
Ok(cycle_number < u128::from(cycle_of_prepare_phase))
418418
});
419419

420420
if !needs_update? {

stackslib/src/chainstate/stacks/boot/pox_2_tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3797,7 +3797,7 @@ fn test_get_pox_addrs() {
37973797
assert!(opdata.all_outputs_burn());
37983798
assert!(opdata.burn_fee > 0);
37993799

3800-
if tenure_id > 1 && cur_reward_cycle > lockup_reward_cycle.into() {
3800+
if tenure_id > 1 && cur_reward_cycle > u128::from(lockup_reward_cycle) {
38013801
prepared = true;
38023802
}
38033803
}
@@ -3807,7 +3807,7 @@ fn test_get_pox_addrs() {
38073807
for op in burn_ops.iter() {
38083808
if let BlockstackOperationType::LeaderBlockCommit(ref opdata) = &op {
38093809
eprintln!("reward phase {}: {:?}", burn_height, opdata);
3810-
if tenure_id > 1 && cur_reward_cycle == (lockup_reward_cycle + 1).into() {
3810+
if tenure_id > 1 && cur_reward_cycle == u128::from(lockup_reward_cycle + 1) {
38113811
assert!(!opdata.all_outputs_burn());
38123812
rewarded = true;
38133813
} else {
@@ -3874,7 +3874,7 @@ fn test_get_pox_addrs() {
38743874
eprintln!("ntotal_liquid_ustx: {total_liquid_ustx}");
38753875
eprintln!("total-stacked: {total_stacked}");
38763876

3877-
if cur_reward_cycle == lockup_reward_cycle.into() {
3877+
if cur_reward_cycle == u128::from(lockup_reward_cycle) {
38783878
assert_eq!(reward_addrs.len(), 4);
38793879
all_reward_addrs = reward_addrs;
38803880
}
@@ -4095,7 +4095,7 @@ fn test_stack_with_segwit() {
40954095
assert!(opdata.all_outputs_burn());
40964096
assert!(opdata.burn_fee > 0);
40974097

4098-
if tenure_id > 1 && cur_reward_cycle > lockup_reward_cycle.into() {
4098+
if tenure_id > 1 && cur_reward_cycle > u128::from(lockup_reward_cycle) {
40994099
prepared = true;
41004100
}
41014101
}
@@ -4105,7 +4105,7 @@ fn test_stack_with_segwit() {
41054105
for op in burn_ops.iter() {
41064106
if let BlockstackOperationType::LeaderBlockCommit(ref opdata) = &op {
41074107
eprintln!("reward phase {}: {:?}", burn_height, opdata);
4108-
if tenure_id > 1 && cur_reward_cycle == (lockup_reward_cycle + 1).into() {
4108+
if tenure_id > 1 && cur_reward_cycle == u128::from(lockup_reward_cycle + 1) {
41094109
assert!(!opdata.all_outputs_burn());
41104110
rewarded = true;
41114111
} else {
@@ -4172,7 +4172,7 @@ fn test_stack_with_segwit() {
41724172
eprintln!("total_liquid_ustx: {total_liquid_ustx}");
41734173
eprintln!("total-stacked: {total_stacked}");
41744174

4175-
if cur_reward_cycle == lockup_reward_cycle.into() {
4175+
if cur_reward_cycle == u128::from(lockup_reward_cycle) {
41764176
assert_eq!(reward_addrs.len(), 4);
41774177
all_reward_addrs = reward_addrs;
41784178
}

stackslib/src/chainstate/stacks/miner.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ impl<'a> StacksMicroblockBuilder<'a> {
997997
));
998998
}
999999

1000-
if bytes_so_far + tx_len >= MAX_EPOCH_SIZE.into() {
1000+
if bytes_so_far + tx_len >= u64::from(MAX_EPOCH_SIZE) {
10011001
info!(
10021002
"Adding microblock tx {} would exceed epoch data size",
10031003
&tx.txid()
@@ -1675,7 +1675,7 @@ impl StacksBlockBuilder {
16751675
.map_err(Error::CodecError)?;
16761676
let tx_len = u64::try_from(tx_bytes.len()).expect("tx len exceeds 2^64 bytes");
16771677

1678-
if self.bytes_so_far + tx_len >= MAX_EPOCH_SIZE.into() {
1678+
if self.bytes_so_far + tx_len >= u64::from(MAX_EPOCH_SIZE) {
16791679
warn!(
16801680
"Epoch size is {} >= {}",
16811681
self.bytes_so_far + tx_len,
@@ -2733,7 +2733,7 @@ impl BlockBuilder for StacksBlockBuilder {
27332733
limit_behavior: &BlockLimitFunction,
27342734
ast_rules: ASTRules,
27352735
) -> TransactionResult {
2736-
if self.bytes_so_far + tx_len >= MAX_EPOCH_SIZE.into() {
2736+
if self.bytes_so_far + tx_len >= u64::from(MAX_EPOCH_SIZE) {
27372737
return TransactionResult::skipped_due_to_error(tx, Error::BlockTooBigError);
27382738
}
27392739

stackslib/src/config/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2477,8 +2477,8 @@ pub struct NodeConfigFile {
24772477
pub stacker_dbs: Option<Vec<String>>,
24782478
/// fault injection: fail to push blocks with this probability (0-100)
24792479
pub fault_injection_block_push_fail_probability: Option<u8>,
2480-
/// enable transactions indexing
2481-
pub txindex: bool,
2480+
/// enable transactions indexing, note this will require additional storage (in the order of gigabytes)
2481+
pub txindex: Option<bool>,
24822482
}
24832483

24842484
impl NodeConfigFile {
@@ -2578,7 +2578,7 @@ impl NodeConfigFile {
25782578
default_node_config.fault_injection_block_push_fail_probability
25792579
},
25802580

2581-
txindex: self.txindex,
2581+
txindex: self.txindex.unwrap_or(default_node_config.txindex),
25822582
};
25832583
Ok(node_config)
25842584
}

stackslib/src/core/mempool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ impl<'a> MemPoolTx<'a> {
947947
// the error rate at or below the target error rate
948948
let evict_txid = {
949949
let num_recents = MemPoolDB::get_num_recent_txs(dbtx)?;
950-
if num_recents >= MAX_BLOOM_COUNTER_TXS.into() {
950+
if num_recents >= u64::from(MAX_BLOOM_COUNTER_TXS) {
951951
// remove lowest-fee tx (they're paying the least, so replication is
952952
// deprioritized)
953953
let sql = "SELECT a.txid FROM mempool AS a LEFT OUTER JOIN removed_txids AS b ON a.txid = b.txid WHERE b.txid IS NULL AND a.height > ?1 ORDER BY a.tx_fee ASC LIMIT 1";
@@ -2761,7 +2761,7 @@ impl MemPoolDB {
27612761
/// Otherwise, use a MemPoolSyncData::BloomFilter variant
27622762
pub fn make_mempool_sync_data(&self) -> Result<MemPoolSyncData, db_error> {
27632763
let num_tags = MemPoolDB::get_num_recent_txs(self.conn())?;
2764-
if num_tags < self.max_tx_tags.into() {
2764+
if num_tags < u64::from(self.max_tx_tags) {
27652765
let seed = self.bloom_counter.get_seed().clone();
27662766
let tags = self.get_txtags(&seed)?;
27672767
Ok(MemPoolSyncData::TxTags(seed, tags))

stackslib/src/net/api/getmicroblocks_unconfirmed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl HttpRequest for RPCMicroblocksUnconfirmedRequestHandler {
128128
let parent_block_id = request::get_block_hash(captures, "parent_block_id")?;
129129
let start_sequence_u32 = request::get_u32(captures, "start_sequence")?;
130130

131-
if start_sequence_u32 > u16::MAX.into() {
131+
if start_sequence_u32 > u32::from(u16::MAX) {
132132
return Err(Error::DecodeError("`start_sequence` is too big".into()));
133133
}
134134

stackslib/src/net/api/gettenure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl NakamotoTenureStream {
132132
self.total_sent = self
133133
.total_sent
134134
.saturating_add(self.block_stream.total_bytes);
135-
if self.total_sent.saturating_add(parent_size) > MAX_PAYLOAD_LEN.into() {
135+
if self.total_sent.saturating_add(parent_size) > u64::from(MAX_PAYLOAD_LEN) {
136136
// out of space to send this
137137
return Ok(false);
138138
}

0 commit comments

Comments
 (0)