From a24f4454225c2082d0f8db5ee67a386fdaa3f28b Mon Sep 17 00:00:00 2001 From: Jacinta Ferrant Date: Mon, 30 Dec 2024 14:20:28 -0500 Subject: [PATCH] Fix all redundant_field_name warnings in stackslib Signed-off-by: Jacinta Ferrant --- stackslib/src/burnchains/bitcoin/address.rs | 12 ++-- stackslib/src/burnchains/bitcoin/bits.rs | 6 +- stackslib/src/burnchains/bitcoin/blocks.rs | 24 +++---- stackslib/src/burnchains/bitcoin/indexer.rs | 4 +- stackslib/src/burnchains/bitcoin/mod.rs | 4 +- stackslib/src/burnchains/bitcoin/network.rs | 4 +- stackslib/src/burnchains/bitcoin/spv.rs | 12 ++-- stackslib/src/burnchains/db.rs | 4 +- stackslib/src/burnchains/tests/affirmation.rs | 4 +- stackslib/src/burnchains/tests/db.rs | 2 +- stackslib/src/burnchains/tests/mod.rs | 8 +-- stackslib/src/chainstate/burn/db/sortdb.rs | 40 +++++------ .../burn/operations/leader_block_commit.rs | 20 +++--- .../burn/operations/leader_key_register.rs | 12 ++-- .../chainstate/burn/operations/stack_stx.rs | 4 +- stackslib/src/chainstate/burn/sortition.rs | 4 +- .../src/chainstate/nakamoto/tests/mod.rs | 2 +- stackslib/src/chainstate/stacks/address.rs | 2 +- stackslib/src/chainstate/stacks/auth.rs | 16 ++--- stackslib/src/chainstate/stacks/block.rs | 23 ++----- .../src/chainstate/stacks/db/accounts.rs | 4 +- stackslib/src/chainstate/stacks/db/blocks.rs | 19 +++--- stackslib/src/chainstate/stacks/db/mod.rs | 12 ++-- .../src/chainstate/stacks/db/transactions.rs | 14 ++-- .../src/chainstate/stacks/db/unconfirmed.rs | 2 +- stackslib/src/chainstate/stacks/index/marf.rs | 2 +- stackslib/src/chainstate/stacks/index/node.rs | 20 +++--- .../src/chainstate/stacks/index/storage.rs | 20 +++--- stackslib/src/chainstate/stacks/miner.rs | 8 +-- stackslib/src/chainstate/stacks/mod.rs | 4 +- stackslib/src/chainstate/stacks/tests/mod.rs | 14 ++-- .../src/chainstate/stacks/transaction.rs | 8 +-- stackslib/src/clarity_cli.rs | 4 +- stackslib/src/clarity_vm/clarity.rs | 2 +- stackslib/src/net/api/getheaders.rs | 2 +- .../src/net/api/getmicroblocks_indexed.rs | 4 +- .../src/net/api/gettransaction_unconfirmed.rs | 2 +- stackslib/src/net/asn.rs | 6 +- stackslib/src/net/atlas/mod.rs | 2 +- stackslib/src/net/chat.rs | 18 ++--- stackslib/src/net/codec.rs | 35 +++++----- stackslib/src/net/connection.rs | 12 ++-- stackslib/src/net/db.rs | 67 ++++++++----------- stackslib/src/net/dns.rs | 15 ++--- stackslib/src/net/download/epoch2x.rs | 22 +++--- stackslib/src/net/http/request.rs | 20 +++--- stackslib/src/net/http/response.rs | 20 +++--- stackslib/src/net/inv/epoch2x.rs | 24 +++---- stackslib/src/net/mod.rs | 22 +++--- stackslib/src/net/neighbors/neighbor.rs | 2 +- stackslib/src/net/poll.rs | 6 +- stackslib/src/net/relay.rs | 2 +- stackslib/src/net/tests/relay/epoch2x.rs | 4 +- stackslib/src/util_lib/bloom.rs | 2 +- stackslib/src/util_lib/db.rs | 2 +- 55 files changed, 300 insertions(+), 329 deletions(-) diff --git a/stackslib/src/burnchains/bitcoin/address.rs b/stackslib/src/burnchains/bitcoin/address.rs index bc5ab4b459..e69ede63c3 100644 --- a/stackslib/src/burnchains/bitcoin/address.rs +++ b/stackslib/src/burnchains/bitcoin/address.rs @@ -234,8 +234,8 @@ impl LegacyBitcoinAddress { payload_bytes.copy_from_slice(b); Ok(LegacyBitcoinAddress { - network_id: network_id, - addrtype: addrtype, + network_id, + addrtype, bytes: Hash160(payload_bytes), }) } @@ -436,8 +436,8 @@ impl BitcoinAddress { my_bytes.copy_from_slice(b); Ok(BitcoinAddress::Legacy(LegacyBitcoinAddress { - network_id: network_id, - addrtype: addrtype, + network_id, + addrtype, bytes: Hash160(my_bytes), })) } @@ -478,7 +478,7 @@ impl BitcoinAddress { my_bytes.copy_from_slice(b); Some(BitcoinAddress::Legacy(LegacyBitcoinAddress { - network_id: network_id, + network_id, addrtype: LegacyBitcoinAddressType::PublicKeyHash, bytes: Hash160(my_bytes), })) @@ -492,7 +492,7 @@ impl BitcoinAddress { my_bytes.copy_from_slice(b); Some(BitcoinAddress::Legacy(LegacyBitcoinAddress { - network_id: network_id, + network_id, addrtype: LegacyBitcoinAddressType::ScriptHash, bytes: Hash160(my_bytes), })) diff --git a/stackslib/src/burnchains/bitcoin/bits.rs b/stackslib/src/burnchains/bitcoin/bits.rs index afeaefc0dc..fad0132235 100644 --- a/stackslib/src/burnchains/bitcoin/bits.rs +++ b/stackslib/src/burnchains/bitcoin/bits.rs @@ -136,7 +136,7 @@ impl BitcoinTxInputStructured { Some(BitcoinTxInputStructured { tx_ref: input_txid, - keys: keys, + keys, num_required: num_sigs, in_type: if segwit { BitcoinInputType::SegwitP2SH @@ -184,7 +184,7 @@ impl BitcoinTxInputStructured { let tx_input = BitcoinTxInputStructured { tx_ref: input_txid, - keys: keys, + keys, num_required: num_sigs, in_type: BitcoinInputType::SegwitP2SH, }; @@ -498,7 +498,7 @@ impl BitcoinTxInputRaw { ) -> BitcoinTxInputRaw { BitcoinTxInputRaw { scriptSig: script_sig.clone().into_bytes(), - witness: witness, + witness, tx_ref: input_txid, } } diff --git a/stackslib/src/burnchains/bitcoin/blocks.rs b/stackslib/src/burnchains/bitcoin/blocks.rs index 0cee9e60e6..b4b5dc24e4 100644 --- a/stackslib/src/burnchains/bitcoin/blocks.rs +++ b/stackslib/src/burnchains/bitcoin/blocks.rs @@ -231,7 +231,7 @@ impl BitcoinBlockParser { /// New block parser pub fn new(network_id: BitcoinNetworkType, magic_bytes: MagicBytes) -> BitcoinBlockParser { BitcoinBlockParser { - network_id: network_id, + network_id, magic_bytes: magic_bytes.clone(), } } @@ -478,7 +478,7 @@ impl BitcoinBlockParser { } BitcoinBlock { - block_height: block_height, + block_height, block_hash: BurnchainHeaderHash::from_bitcoin_hash(&block.bitcoin_hash()), parent_block_hash: BurnchainHeaderHash::from_bitcoin_hash(&block.header.prev_blockhash), txs: accepted_txs, @@ -596,7 +596,7 @@ mod tests { let header = deserialize(&header_bin.to_vec()).map_err(|_e| "failed to deserialize header")?; Ok(LoneBlockHeader { - header: header, + header, tx_count: VarInt(0), }) } @@ -655,7 +655,7 @@ mod tests { result: Some(BitcoinTransaction { data_amt: 0, txid: to_txid(&hex_bytes("185c112401590b11acdfea6bb26d2a8e37cb31f24a0c89dbb8cc14b3d6271fb1").unwrap()), - vtxindex: vtxindex, + vtxindex, opcode: '+' as u8, data: hex_bytes("fae543ff5672fb607fe15e16b1c3ef38737c631c7c5d911c6617993c21fba731363f1cfe").unwrap(), inputs: vec![ @@ -702,7 +702,7 @@ mod tests { result: Some(BitcoinTransaction { data_amt: 0, txid: to_txid(&hex_bytes("eb2e84a45cf411e528185a98cd5fb45ed349843a83d39fd4dff2de47adad8c8f").unwrap()), - vtxindex: vtxindex, + vtxindex, opcode: '~' as u8, data: hex_bytes("7061747269636b7374616e6c6579322e6964").unwrap(), inputs: vec![ @@ -745,7 +745,7 @@ mod tests { result: Some(BitcoinTransaction { data_amt: 0, txid: to_txid(&hex_bytes("b908952b30ccfdfa59985dc1ffdd2a22ef054d20fa253510d2af7797dddee459").unwrap()), - vtxindex: vtxindex, + vtxindex, opcode: ':' as u8, data: hex_bytes("666f6f2e74657374").unwrap(), inputs: vec![ @@ -776,7 +776,7 @@ mod tests { result: Some(BitcoinTransaction { data_amt: 0, txid: to_txid(&hex_bytes("16751ca54407b922e3072830cf4be58c5562a6dc350f6703192b673c4cc86182").unwrap()), - vtxindex: vtxindex, + vtxindex, opcode: '?' as u8, data: hex_bytes("9fab7f294936ddb6524a48feff691ecbd0ca9e8f107d845c417a5438d1cb441e827c5126").unwrap(), inputs: vec![ @@ -826,7 +826,7 @@ mod tests { result: Some(BitcoinTransaction { data_amt: 0, txid: to_txid(&hex_bytes("185c112401590b11acdfea6bb26d2a8e37cb31f24a0c89dbb8cc14b3d6271fb1").unwrap()), - vtxindex: vtxindex, + vtxindex, opcode: '+' as u8, data: hex_bytes("fae543ff5672fb607fe15e16b1c3ef38737c631c7c5d911c6617993c21fba731363f1cfe").unwrap(), inputs: vec![ @@ -864,7 +864,7 @@ mod tests { result: Some(BitcoinTransaction { data_amt: 0, txid: to_txid(&hex_bytes("eb2e84a45cf411e528185a98cd5fb45ed349843a83d39fd4dff2de47adad8c8f").unwrap()), - vtxindex: vtxindex, + vtxindex, opcode: '~' as u8, data: hex_bytes("7061747269636b7374616e6c6579322e6964").unwrap(), inputs: vec![ @@ -897,7 +897,7 @@ mod tests { result: Some(BitcoinTransaction { data_amt: 0, txid: to_txid(&hex_bytes("b908952b30ccfdfa59985dc1ffdd2a22ef054d20fa253510d2af7797dddee459").unwrap()), - vtxindex: vtxindex, + vtxindex, opcode: ':' as u8, data: hex_bytes("666f6f2e74657374").unwrap(), inputs: vec![ @@ -928,7 +928,7 @@ mod tests { result: Some(BitcoinTransaction { data_amt: 0, txid: to_txid(&hex_bytes("16751ca54407b922e3072830cf4be58c5562a6dc350f6703192b673c4cc86182").unwrap()), - vtxindex: vtxindex, + vtxindex, opcode: '?' as u8, data: hex_bytes("9fab7f294936ddb6524a48feff691ecbd0ca9e8f107d845c417a5438d1cb441e827c5126").unwrap(), inputs: vec![ @@ -961,7 +961,7 @@ mod tests { result: Some(BitcoinTransaction { data_amt: 0, txid: to_txid(&hex_bytes("8b8a12909d48fd86c06e92270133d320498fb36caa0fdcb3292a8bba99669ebd").unwrap()), - vtxindex: vtxindex, + vtxindex, opcode: '&' as u8, data: hex_bytes("0000cd73fa046543210000000000aa000174657374").unwrap(), inputs: vec![ diff --git a/stackslib/src/burnchains/bitcoin/indexer.rs b/stackslib/src/burnchains/bitcoin/indexer.rs index 3361301675..f7160cf83a 100644 --- a/stackslib/src/burnchains/bitcoin/indexer.rs +++ b/stackslib/src/burnchains/bitcoin/indexer.rs @@ -160,7 +160,7 @@ impl BitcoinIndexerConfig { username: Some("blockstack".to_string()), password: Some("blockstacksystem".to_string()), timeout: 30, - spv_headers_path: spv_headers_path, + spv_headers_path, first_block: 0, magic_bytes: BLOCKSTACK_MAGIC_MAINNET.clone(), epochs: None, @@ -193,7 +193,7 @@ impl BitcoinIndexerRuntime { services: 0, user_agent: USER_AGENT.to_owned(), version_nonce: rng.gen(), - network_id: network_id, + network_id, block_height: 0, last_getdata_send_time: 0, last_getheaders_send_time: 0, diff --git a/stackslib/src/burnchains/bitcoin/mod.rs b/stackslib/src/burnchains/bitcoin/mod.rs index d273b1f5f8..6ba66f524b 100644 --- a/stackslib/src/burnchains/bitcoin/mod.rs +++ b/stackslib/src/burnchains/bitcoin/mod.rs @@ -239,8 +239,8 @@ impl BitcoinBlock { block_height: height, block_hash: hash.clone(), parent_block_hash: parent.clone(), - txs: txs, - timestamp: timestamp, + txs, + timestamp, } } } diff --git a/stackslib/src/burnchains/bitcoin/network.rs b/stackslib/src/burnchains/bitcoin/network.rs index 3e8bf9340c..3411885ddb 100644 --- a/stackslib/src/burnchains/bitcoin/network.rs +++ b/stackslib/src/burnchains/bitcoin/network.rs @@ -45,7 +45,7 @@ impl BitcoinIndexer { pub fn send_message(&mut self, payload: btc_message::NetworkMessage) -> Result<(), btc_error> { let message = btc_message::RawNetworkMessage { magic: network_id_to_bytes(self.runtime.network_id), - payload: payload, + payload, }; self.with_socket(|ref mut sock| { @@ -245,7 +245,7 @@ impl BitcoinIndexer { let payload = btc_message_network::VersionMessage { version: btc_constants::PROTOCOL_VERSION, services: 0, - timestamp: timestamp, + timestamp, receiver: remote_address, sender: sender_address, nonce: self.runtime.version_nonce, diff --git a/stackslib/src/burnchains/bitcoin/spv.rs b/stackslib/src/burnchains/bitcoin/spv.rs index 82cbb7b7f6..f60f90d9e8 100644 --- a/stackslib/src/burnchains/bitcoin/spv.rs +++ b/stackslib/src/burnchains/bitcoin/spv.rs @@ -167,9 +167,9 @@ impl SpvClient { start_block_height: start_block, end_block_height: end_block, cur_block_height: start_block, - network_id: network_id, - readwrite: readwrite, - reverse_order: reverse_order, + network_id, + readwrite, + reverse_order, headers_db: conn, check_txcount: true, }; @@ -197,9 +197,9 @@ impl SpvClient { start_block_height: start_block, end_block_height: end_block, cur_block_height: start_block, - network_id: network_id, - readwrite: readwrite, - reverse_order: reverse_order, + network_id, + readwrite, + reverse_order, headers_db: conn, check_txcount: true, }; diff --git a/stackslib/src/burnchains/db.rs b/stackslib/src/burnchains/db.rs index d5f1e18804..bd300f290e 100644 --- a/stackslib/src/burnchains/db.rs +++ b/stackslib/src/burnchains/db.rs @@ -132,7 +132,7 @@ impl FromRow for BlockCommitMetadata { block_height, vtxindex, affirmation_id, - anchor_block: anchor_block, + anchor_block, anchor_block_descendant, }) } @@ -1106,7 +1106,7 @@ impl BurnchainDB { pub fn tx_begin<'a>(&'a mut self) -> Result, BurnchainError> { let sql_tx = tx_begin_immediate(&mut self.conn)?; - Ok(BurnchainDBTransaction { sql_tx: sql_tx }) + Ok(BurnchainDBTransaction { sql_tx }) } fn inner_get_canonical_chain_tip( diff --git a/stackslib/src/burnchains/tests/affirmation.rs b/stackslib/src/burnchains/tests/affirmation.rs index 8876f3d1aa..12cfd1aac9 100644 --- a/stackslib/src/burnchains/tests/affirmation.rs +++ b/stackslib/src/burnchains/tests/affirmation.rs @@ -249,8 +249,8 @@ pub fn make_simple_key_register( memo: vec![01, 02, 03, 04, 05], txid: next_txid(), - vtxindex: vtxindex, - block_height: block_height, + vtxindex, + block_height, burn_header_hash: burn_header_hash.clone(), } } diff --git a/stackslib/src/burnchains/tests/db.rs b/stackslib/src/burnchains/tests/db.rs index f14243d049..6c474bba44 100644 --- a/stackslib/src/burnchains/tests/db.rs +++ b/stackslib/src/burnchains/tests/db.rs @@ -545,7 +545,7 @@ pub fn make_simple_block_commit( txid: next_txid(), vtxindex: 0, - block_height: block_height, + block_height, burn_parent_modulus: ((block_height - 1) % BURN_BLOCK_MINED_AT_MODULUS) as u8, burn_header_hash: burn_header.block_hash.clone(), }; diff --git a/stackslib/src/burnchains/tests/mod.rs b/stackslib/src/burnchains/tests/mod.rs index c8543b1142..0beb8e5a9d 100644 --- a/stackslib/src/burnchains/tests/mod.rs +++ b/stackslib/src/burnchains/tests/mod.rs @@ -74,9 +74,9 @@ impl BurnchainBlockHeader { ) -> BurnchainBlockHeader { BurnchainBlockHeader { block_height: parent_sn.block_height + 1, - block_hash: block_hash, + block_hash, parent_block_hash: parent_sn.burn_header_hash.clone(), - num_txs: num_txs, + num_txs, timestamp: get_epoch_time_secs(), } } @@ -375,7 +375,7 @@ impl TestBurnchainBlock { burn_header_hash, }), ], - fork_id: fork_id, + fork_id, timestamp: get_epoch_time_secs(), } } @@ -724,7 +724,7 @@ impl TestBurnchainFork { tip_index_root: start_index_root.clone(), blocks: vec![], pending_blocks: vec![], - fork_id: fork_id, + fork_id, } } diff --git a/stackslib/src/chainstate/burn/db/sortdb.rs b/stackslib/src/chainstate/burn/db/sortdb.rs index e399121e07..8dcf30b325 100644 --- a/stackslib/src/chainstate/burn/db/sortdb.rs +++ b/stackslib/src/chainstate/burn/db/sortdb.rs @@ -225,14 +225,14 @@ impl FromRow for LeaderKeyRegisterOp { let memo = memo_bytes.to_vec(); let leader_key_row = LeaderKeyRegisterOp { - txid: txid, - vtxindex: vtxindex, - block_height: block_height, - burn_header_hash: burn_header_hash, - - consensus_hash: consensus_hash, - public_key: public_key, - memo: memo, + txid, + vtxindex, + block_height, + burn_header_hash, + + consensus_hash, + public_key, + memo, }; Ok(leader_key_row) @@ -4536,8 +4536,8 @@ impl SortitionDB { burn_block_height: chain_tip.block_height, burn_block_hash: chain_tip.burn_header_hash, burn_stable_block_height: stable_block_height, - burn_stable_block_hash: burn_stable_block_hash, - last_burn_block_hashes: last_burn_block_hashes, + burn_stable_block_hash, + last_burn_block_hashes, rc_consensus_hash: chain_tip.canonical_stacks_tip_consensus_hash, }) } @@ -7073,7 +7073,7 @@ pub mod tests { .unwrap(), ) .unwrap(), - vtxindex: vtxindex, + vtxindex, block_height: block_height + 1, burn_header_hash: BurnchainHeaderHash([0x01; 32]), }; @@ -7152,7 +7152,7 @@ pub mod tests { .unwrap(), ) .unwrap(), - vtxindex: vtxindex, + vtxindex, block_height: block_height + 1, burn_header_hash: BurnchainHeaderHash([0x01; 32]), }; @@ -7192,7 +7192,7 @@ pub mod tests { .unwrap(), ) .unwrap(), - vtxindex: vtxindex, + vtxindex, block_height: block_height + 2, burn_parent_modulus: ((block_height + 1) % BURN_BLOCK_MINED_AT_MODULUS) as u8, burn_header_hash: BurnchainHeaderHash([0x03; 32]), @@ -7376,7 +7376,7 @@ pub mod tests { .unwrap(), ) .unwrap(), - vtxindex: vtxindex, + vtxindex, block_height: block_height + 2, burn_header_hash: BurnchainHeaderHash([0x03; 32]), }; @@ -7871,7 +7871,7 @@ pub mod tests { .unwrap(), ) .unwrap(), - vtxindex: vtxindex, + vtxindex, block_height: block_height + 1, burn_header_hash: BurnchainHeaderHash([0x01; 32]), }; @@ -7911,7 +7911,7 @@ pub mod tests { .unwrap(), ) .unwrap(), - vtxindex: vtxindex, + vtxindex, block_height: block_height + 2, burn_parent_modulus: ((block_height + 1) % BURN_BLOCK_MINED_AT_MODULUS) as u8, burn_header_hash: BurnchainHeaderHash([0x03; 32]), @@ -7995,7 +7995,7 @@ pub mod tests { let mut snapshot_with_sortition = BlockSnapshot { accumulated_coinbase_ustx: 0, pox_valid: true, - block_height: block_height, + block_height, burn_header_timestamp: get_epoch_time_secs(), burn_header_hash: BurnchainHeaderHash::from_bytes(&[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -8719,7 +8719,7 @@ pub mod tests { 0, 0, 0, 0, 0, 0, 0, i as u8, ]) .unwrap(), - total_burn: total_burn, + total_burn, sortition: false, sortition_hash: SortitionHash([(i as u8); 32]), winning_block_txid: Txid([(i as u8); 32]), @@ -8796,7 +8796,7 @@ pub mod tests { 0, 0, 0, 0, 0, 0, 0, i as u8, ]) .unwrap(), - total_burn: total_burn, + total_burn, sortition: true, sortition_hash: SortitionHash([(i as u8); 32]), winning_block_txid: Txid([(i as u8); 32]), @@ -10087,7 +10087,7 @@ pub mod tests { .unwrap(), ) .unwrap(), - vtxindex: vtxindex, + vtxindex, block_height: block_height + 1, burn_header_hash: BurnchainHeaderHash([0x01; 32]), }; diff --git a/stackslib/src/chainstate/burn/operations/leader_block_commit.rs b/stackslib/src/chainstate/burn/operations/leader_block_commit.rs index a752131668..cf85a02829 100644 --- a/stackslib/src/chainstate/burn/operations/leader_block_commit.rs +++ b/stackslib/src/chainstate/burn/operations/leader_block_commit.rs @@ -102,7 +102,7 @@ impl LeaderBlockCommitOp { ) -> LeaderBlockCommitOp { LeaderBlockCommitOp { sunset_burn: 0, - block_height: block_height, + block_height, burn_parent_modulus: if block_height > 0 { u8::try_from((block_height - 1) % BURN_BLOCK_MINED_AT_MODULUS) .expect("FATAL: unreachable: unable to form u8 from 3-bit number") @@ -117,7 +117,7 @@ impl LeaderBlockCommitOp { parent_block_ptr: 0, parent_vtxindex: 0, memo: vec![0x00], - burn_fee: burn_fee, + burn_fee, input: input.clone(), block_header_hash: block_header_hash.clone(), commit_outs: vec![], @@ -147,12 +147,12 @@ impl LeaderBlockCommitOp { LeaderBlockCommitOp { sunset_burn: 0, new_seed: new_seed.clone(), - key_block_ptr: key_block_ptr, - key_vtxindex: key_vtxindex, + key_block_ptr, + key_vtxindex, parent_block_ptr: parent_block_height, - parent_vtxindex: parent_vtxindex, + parent_vtxindex, memo: vec![], - burn_fee: burn_fee, + burn_fee, input: input.clone(), block_header_hash: block_header_hash.clone(), commit_outs: vec![], @@ -458,7 +458,7 @@ impl LeaderBlockCommitOp { treatment: Vec::new(), txid: tx.txid(), vtxindex: tx.vtxindex(), - block_height: block_height, + block_height, burn_header_hash: block_hash.clone(), }) } @@ -1777,10 +1777,10 @@ mod tests { apparent_sender: BurnchainSigner("mgbpit8FvkVJ9kuXY8QSM5P7eibnhcEMBk".to_string()), txid: Txid::from_hex("502f3e5756de7e1bdba8c713cd2daab44adb5337d14ff668fdc57cc27d67f0d4").unwrap(), - vtxindex: vtxindex, - block_height: block_height, + vtxindex, + block_height, burn_parent_modulus: ((block_height - 1) % BURN_BLOCK_MINED_AT_MODULUS) as u8, - burn_header_hash: burn_header_hash, + burn_header_hash, treatment: vec![], }) }, OpFixture { diff --git a/stackslib/src/chainstate/burn/operations/leader_key_register.rs b/stackslib/src/chainstate/burn/operations/leader_key_register.rs index 5608b6739d..a0406544f1 100644 --- a/stackslib/src/chainstate/burn/operations/leader_key_register.rs +++ b/stackslib/src/chainstate/burn/operations/leader_key_register.rs @@ -163,7 +163,7 @@ impl LeaderKeyRegisterOp { txid: tx.txid(), vtxindex: tx.vtxindex(), - block_height: block_height, + block_height, burn_header_hash: block_hash.clone(), }) } @@ -287,8 +287,8 @@ pub mod tests { memo: vec![01, 02, 03, 04, 05], txid: Txid::from_bytes_be(&hex_bytes("1bfa831b5fc56c858198acb8e77e5863c1e9d8ac26d49ddb914e24d8d4083562").unwrap()).unwrap(), - vtxindex: vtxindex, - block_height: block_height, + vtxindex, + block_height, burn_header_hash: burn_header_hash.clone(), }) }, @@ -301,9 +301,9 @@ pub mod tests { memo: vec![], txid: Txid::from_bytes_be(&hex_bytes("2fbf8d5be32dce49790d203ba59acbb0929d5243413174ff5d26a5c6f23dea65").unwrap()).unwrap(), - vtxindex: vtxindex, - block_height: block_height, - burn_header_hash: burn_header_hash, + vtxindex, + block_height, + burn_header_hash, }) }, OpFixture { diff --git a/stackslib/src/chainstate/burn/operations/stack_stx.rs b/stackslib/src/chainstate/burn/operations/stack_stx.rs index c4c54b9737..67de678659 100644 --- a/stackslib/src/chainstate/burn/operations/stack_stx.rs +++ b/stackslib/src/chainstate/burn/operations/stack_stx.rs @@ -145,7 +145,7 @@ impl PreStxOp { } Ok(PreStxOp { - output: output, + output, txid: tx.txid(), vtxindex: tx.vtxindex(), block_height, @@ -689,7 +689,7 @@ mod tests { txid: Txid([0; 32]), vtxindex: 0, opcode: Opcodes::StackStx as u8, - data: data, + data, data_amt: 0, inputs: vec![BitcoinTxInputStructured { keys: vec![], diff --git a/stackslib/src/chainstate/burn/sortition.rs b/stackslib/src/chainstate/burn/sortition.rs index ff71b0cf10..2187cb736c 100644 --- a/stackslib/src/chainstate/burn/sortition.rs +++ b/stackslib/src/chainstate/burn/sortition.rs @@ -254,12 +254,12 @@ impl BlockSnapshot { debug!("SORTITION({}): NO BLOCK CHOSEN", block_height); Ok(BlockSnapshot { - block_height: block_height, + block_height, burn_header_hash: block_hash, burn_header_timestamp: block_header.timestamp, parent_burn_header_hash: parent_block_hash, consensus_hash: ch, - ops_hash: ops_hash, + ops_hash, total_burn: burn_total, sortition: false, sortition_hash: sortition_hash.clone(), diff --git a/stackslib/src/chainstate/nakamoto/tests/mod.rs b/stackslib/src/chainstate/nakamoto/tests/mod.rs index 94ef81c077..3f107ed1cf 100644 --- a/stackslib/src/chainstate/nakamoto/tests/mod.rs +++ b/stackslib/src/chainstate/nakamoto/tests/mod.rs @@ -2586,7 +2586,7 @@ fn valid_vote_transaction() { post_conditions: vec![], payload: TransactionPayload::ContractCall(TransactionContractCall { address: contract_addr, - contract_name: contract_name, + contract_name, function_name: SIGNERS_VOTING_FUNCTION_NAME.into(), function_args: valid_function_args, }), diff --git a/stackslib/src/chainstate/stacks/address.rs b/stackslib/src/chainstate/stacks/address.rs index c3706a2565..438dd17b9b 100644 --- a/stackslib/src/chainstate/stacks/address.rs +++ b/stackslib/src/chainstate/stacks/address.rs @@ -525,7 +525,7 @@ impl StacksAddressExtensions for StacksAddress { let version = to_c32_version_byte(btc_version) .expect("Failed to decode Bitcoin version byte to Stacks version byte"); StacksAddress { - version: version, + version, bytes: addr.bytes.clone(), } } diff --git a/stackslib/src/chainstate/stacks/auth.rs b/stackslib/src/chainstate/stacks/auth.rs index 06cf64d037..58bd2ea9f4 100644 --- a/stackslib/src/chainstate/stacks/auth.rs +++ b/stackslib/src/chainstate/stacks/auth.rs @@ -558,12 +558,12 @@ impl StacksMessageCodec for SinglesigSpendingCondition { } Ok(SinglesigSpendingCondition { - signer: signer, - nonce: nonce, - tx_fee: tx_fee, - hash_mode: hash_mode, - key_encoding: key_encoding, - signature: signature, + signer, + nonce, + tx_fee, + hash_mode, + key_encoding, + signature, }) } } @@ -593,7 +593,7 @@ impl SinglesigSpendingCondition { SinglesigHashMode::P2WPKH => C32_ADDRESS_VERSION_MAINNET_MULTISIG, }; StacksAddress { - version: version, + version, bytes: self.signer.clone(), } } @@ -604,7 +604,7 @@ impl SinglesigSpendingCondition { SinglesigHashMode::P2WPKH => C32_ADDRESS_VERSION_TESTNET_MULTISIG, }; StacksAddress { - version: version, + version, bytes: self.signer.clone(), } } diff --git a/stackslib/src/chainstate/stacks/block.rs b/stackslib/src/chainstate/stacks/block.rs index 85bfcc5576..8a1b337734 100644 --- a/stackslib/src/chainstate/stacks/block.rs +++ b/stackslib/src/chainstate/stacks/block.rs @@ -156,8 +156,8 @@ impl StacksBlockHeader { total_work: total_work.clone(), proof: proof.clone(), parent_block: parent_header_hash, - parent_microblock: parent_microblock, - parent_microblock_sequence: parent_microblock_sequence, + parent_microblock, + parent_microblock_sequence, tx_merkle_root: tx_merkle_root.clone(), state_index_root: state_index_root.clone(), microblock_pubkey_hash: microblock_pubkey_hash.clone(), @@ -887,10 +887,7 @@ impl StacksMicroblock { let merkle_tree = MerkleTree::::new(&txids); let tx_merkle_root = merkle_tree.root(); let header = StacksMicroblockHeader::first_unsigned(parent_block_hash, &tx_merkle_root); - StacksMicroblock { - header: header, - txs: txs, - } + StacksMicroblock { header, txs } } pub fn from_parent_unsigned( @@ -911,10 +908,7 @@ impl StacksMicroblock { } }; - Some(StacksMicroblock { - header: header, - txs: txs, - }) + Some(StacksMicroblock { header, txs }) } pub fn sign(&mut self, privk: &StacksPrivateKey) -> Result<(), net_error> { @@ -1005,7 +999,7 @@ mod test { burn: 123, work: 456, }, - proof: proof, + proof, parent_block: FIRST_STACKS_BLOCK_HASH.clone(), parent_microblock: BlockHeaderHash([1u8; 32]), parent_microblock_sequence: 3, @@ -1183,7 +1177,7 @@ mod test { version: 0x12, sequence: 0x34, prev_block: EMPTY_MICROBLOCK_PARENT_HASH.clone(), - tx_merkle_root: tx_merkle_root, + tx_merkle_root, signature: MessageSignature([ 0x00, 0x35, 0x44, 0x45, 0xa1, 0xdc, 0x98, 0xa1, 0xbd, 0x27, 0x98, 0x4d, 0xbe, 0x69, 0x97, 0x9a, 0x5c, 0xd7, 0x78, 0x86, 0xb4, 0xd9, 0x13, 0x4a, 0xf5, 0xc4, @@ -1216,10 +1210,7 @@ mod test { txs.consensus_serialize(&mut tx_bytes).unwrap(); block_bytes.append(&mut tx_bytes); - let mblock = StacksMicroblock { - header: header, - txs: txs, - }; + let mblock = StacksMicroblock { header, txs }; check_codec_and_corruption::(&mblock, &block_bytes); } diff --git a/stackslib/src/chainstate/stacks/db/accounts.rs b/stackslib/src/chainstate/stacks/db/accounts.rs index bf84cc1362..42682ea7c8 100644 --- a/stackslib/src/chainstate/stacks/db/accounts.rs +++ b/stackslib/src/chainstate/stacks/db/accounts.rs @@ -976,9 +976,9 @@ impl StacksChainState { address: child_address, recipient: child_recipient, coinbase: coinbase_reward, - tx_fees_anchored: tx_fees_anchored, + tx_fees_anchored, tx_fees_streamed_produced: 0, - tx_fees_streamed_confirmed: tx_fees_streamed_confirmed, + tx_fees_streamed_confirmed, vtxindex: participant.vtxindex, }; diff --git a/stackslib/src/chainstate/stacks/db/blocks.rs b/stackslib/src/chainstate/stacks/db/blocks.rs index 233a9d5978..968c587cd1 100644 --- a/stackslib/src/chainstate/stacks/db/blocks.rs +++ b/stackslib/src/chainstate/stacks/db/blocks.rs @@ -2007,8 +2007,8 @@ impl StacksChainState { Ok(BlocksInvData { bitlen: u16::try_from(block_bits.len()) .expect("FATAL: unreachable: more than 2^16 block bits"), - block_bitvec: block_bitvec, - microblocks_bitvec: microblocks_bitvec, + block_bitvec, + microblocks_bitvec, }) } @@ -2130,8 +2130,8 @@ impl StacksChainState { Ok(BlocksInvData { bitlen: u16::try_from(block_bits.len()) .expect("FATAL: block bits has more than 2^16 members"), - block_bitvec: block_bitvec, - microblocks_bitvec: microblocks_bitvec, + block_bitvec, + microblocks_bitvec, }) } @@ -2917,7 +2917,7 @@ impl StacksChainState { let extended_header = ExtendedStacksHeader { consensus_hash: header_info.consensus_hash, - header: header, + header, parent_block_id: parent_index_block_hash, }; Ok(extended_header) @@ -7180,15 +7180,12 @@ pub mod test { let header = StacksMicroblockHeader { version: 0x12, sequence: initial_seq + (i as u16), - prev_block: prev_block, - tx_merkle_root: tx_merkle_root, + prev_block, + tx_merkle_root, signature: MessageSignature([0u8; 65]), }; - let mut mblock = StacksMicroblock { - header: header, - txs: txs, - }; + let mut mblock = StacksMicroblock { header, txs }; mblock.sign(privk).unwrap(); microblocks.push(mblock); diff --git a/stackslib/src/chainstate/stacks/db/mod.rs b/stackslib/src/chainstate/stacks/db/mod.rs index ffdea5a7dd..b64815ed62 100644 --- a/stackslib/src/chainstate/stacks/db/mod.rs +++ b/stackslib/src/chainstate/stacks/db/mod.rs @@ -1869,18 +1869,18 @@ impl StacksChainState { let clarity_state = ClarityInstance::new(mainnet, chain_id, vm_state); let mut chainstate = StacksChainState { - mainnet: mainnet, - chain_id: chain_id, - clarity_state: clarity_state, + mainnet, + chain_id, + clarity_state, nakamoto_staging_blocks_conn, - state_index: state_index, + state_index, blocks_path: blocks_path_root, clarity_state_index_path: clarity_state_index_marf, - clarity_state_index_root: clarity_state_index_root, + clarity_state_index_root, root_path: path_str.to_string(), unconfirmed_state: None, fault_injection: StacksChainStateFaults::new(), - marf_opts: marf_opts, + marf_opts, }; let mut receipts = vec![]; diff --git a/stackslib/src/chainstate/stacks/db/transactions.rs b/stackslib/src/chainstate/stacks/db/transactions.rs index 3df99ea886..143cb5524f 100644 --- a/stackslib/src/chainstate/stacks/db/transactions.rs +++ b/stackslib/src/chainstate/stacks/db/transactions.rs @@ -250,7 +250,7 @@ impl StacksTransactionReceipt { transaction: tx.into(), events: vec![], post_condition_aborted: false, - result: result, + result, stx_burned: 0, contract_analysis: None, execution_cost: cost, @@ -449,10 +449,10 @@ impl StacksChainState { txid: tx.txid(), principal: payer_account.principal.clone(), is_origin: false, - quiet: quiet, + quiet, }; if !quiet { - warn!("{}", &e); + warn!("{e}"); } return Err((e, (origin_account, payer_account))); } @@ -470,10 +470,10 @@ impl StacksChainState { txid: tx.txid(), principal: origin_account.principal.clone(), is_origin: true, - quiet: quiet, + quiet, }; if !quiet { - warn!("{}", &e); + warn!("{e}"); } return Err((e, (origin_account, payer_account))); } @@ -8247,10 +8247,10 @@ pub mod test { version: 0x12, sequence: seq, prev_block: parent_block, - tx_merkle_root: tx_merkle_root, + tx_merkle_root, signature: MessageSignature([0u8; 65]), }, - txs: txs, + txs, }; mblock.sign(block_privk).unwrap(); mblock diff --git a/stackslib/src/chainstate/stacks/db/unconfirmed.rs b/stackslib/src/chainstate/stacks/db/unconfirmed.rs index 6f7a9fe9ea..a871b98944 100644 --- a/stackslib/src/chainstate/stacks/db/unconfirmed.rs +++ b/stackslib/src/chainstate/stacks/db/unconfirmed.rs @@ -189,7 +189,7 @@ impl UnconfirmedState { unconfirmed_chain_tip: unconfirmed_tip, clarity_inst: clarity_instance, mined_txs: UnconfirmedTxMap::new(), - cost_so_far: cost_so_far, + cost_so_far, bytes_so_far: 0, last_mblock: None, diff --git a/stackslib/src/chainstate/stacks/index/marf.rs b/stackslib/src/chainstate/stacks/index/marf.rs index a4082627fd..14e8643819 100644 --- a/stackslib/src/chainstate/stacks/index/marf.rs +++ b/stackslib/src/chainstate/stacks/index/marf.rs @@ -1145,7 +1145,7 @@ impl MARF { /// Instantiate the MARF from a TrieFileStorage instance pub fn from_storage(storage: TrieFileStorage) -> MARF { MARF { - storage: storage, + storage, open_chain_tip: None, } } diff --git a/stackslib/src/chainstate/stacks/index/node.rs b/stackslib/src/chainstate/stacks/index/node.rs index da9fc8bbd2..33580f2e2e 100644 --- a/stackslib/src/chainstate/stacks/index/node.rs +++ b/stackslib/src/chainstate/stacks/index/node.rs @@ -231,9 +231,9 @@ impl TriePtr { #[inline] pub fn new(id: u8, chr: u8, ptr: u32) -> TriePtr { TriePtr { - id: id, - chr: chr, - ptr: ptr, + id, + chr, + ptr, back_block: 0, } } @@ -308,10 +308,10 @@ impl TriePtr { let back_block = u32::from_be_bytes([bytes[6], bytes[7], bytes[8], bytes[9]]); TriePtr { - id: id, - chr: chr, - ptr: ptr, - back_block: back_block, + id, + chr, + ptr, + back_block, } } } @@ -781,7 +781,7 @@ impl TrieNode256 { } TrieNode256 { path: node4.path.clone(), - ptrs: ptrs, + ptrs, } } @@ -794,7 +794,7 @@ impl TrieNode256 { } TrieNode256 { path: node48.path.clone(), - ptrs: ptrs, + ptrs, } } } @@ -1191,7 +1191,7 @@ impl TrieNode for TrieLeaf { } Ok(TrieLeaf { - path: path, + path, data: MARFValue(leaf_data), }) } diff --git a/stackslib/src/chainstate/stacks/index/storage.rs b/stackslib/src/chainstate/stacks/index/storage.rs index 6e7ca815c9..d4a9bbe86c 100644 --- a/stackslib/src/chainstate/stacks/index/storage.rs +++ b/stackslib/src/chainstate/stacks/index/storage.rs @@ -422,8 +422,8 @@ impl TrieRAM { /// Inner method to instantiate a TrieRAM from existing Trie data. fn from_data(block_header: T, data: Vec<(TrieNodeType, TrieHash)>, parent: T) -> TrieRAM { TrieRAM { - data: data, - block_header: block_header, + data, + block_header, readonly: false, read_count: 0, @@ -439,7 +439,7 @@ impl TrieRAM { is_moved: false, - parent: parent, + parent, } } @@ -1469,8 +1469,8 @@ impl TrieFileStorage { trie_ancestor_hash_bytes_cache: None, - readonly: readonly, - unconfirmed: unconfirmed, + readonly, + unconfirmed, }, // used in testing in order to short-circuit block-height lookups @@ -1536,9 +1536,9 @@ impl TrieFileStorage { // TODO: borrow self.uncommitted_writes; don't copy them let ret = TrieFileStorage { db_path: self.db_path.clone(), - db: db, + db, blobs, - cache: cache, + cache, bench: TrieBenchmark::new(), hash_calculation_mode: self.hash_calculation_mode, @@ -1605,9 +1605,9 @@ impl<'a, T: MarfTrieId> TrieStorageTransaction<'a, T> { // TODO: borrow self.uncommitted_writes; don't copy them let ret = TrieFileStorage { db_path: self.db_path.to_string(), - db: db, - blobs: blobs, - cache: cache, + db, + blobs, + cache, bench: TrieBenchmark::new(), hash_calculation_mode: self.hash_calculation_mode, diff --git a/stackslib/src/chainstate/stacks/miner.rs b/stackslib/src/chainstate/stacks/miner.rs index 082e9c374c..014c9be53f 100644 --- a/stackslib/src/chainstate/stacks/miner.rs +++ b/stackslib/src/chainstate/stacks/miner.rs @@ -903,7 +903,7 @@ impl<'a> StacksMicroblockBuilder<'a> { next_microblock_header.verify(&miner_pubkey_hash).unwrap(); Ok(StacksMicroblock { header: next_microblock_header, - txs: txs, + txs, }) } @@ -1509,11 +1509,11 @@ impl StacksBlockBuilder { total_anchored_fees: 0, total_confirmed_streamed_fees: 0, total_streamed_fees: 0, - bytes_so_far: bytes_so_far, + bytes_so_far, anchored_done: false, parent_consensus_hash: parent_chain_tip.consensus_hash.clone(), parent_header_hash: header.parent_block.clone(), - header: header, + header, parent_microblock_hash: parent_chain_tip .microblock_tail .as_ref() @@ -1524,7 +1524,7 @@ impl StacksBlockBuilder { ), // will be updated miner_privkey: StacksPrivateKey::new(), // caller should overwrite this, or refrain from mining microblocks miner_payouts: None, - miner_id: miner_id, + miner_id, } } diff --git a/stackslib/src/chainstate/stacks/mod.rs b/stackslib/src/chainstate/stacks/mod.rs index fd370a8b12..c23f293082 100644 --- a/stackslib/src/chainstate/stacks/mod.rs +++ b/stackslib/src/chainstate/stacks/mod.rs @@ -1626,7 +1626,7 @@ pub mod test { parent_block: BlockHeaderHash([5u8; 32]), parent_microblock: BlockHeaderHash([6u8; 32]), parent_microblock_sequence: 4, - tx_merkle_root: tx_merkle_root, + tx_merkle_root, state_index_root: TrieHash([8u8; 32]), microblock_pubkey_hash: Hash160([9u8; 20]), }; @@ -1736,7 +1736,7 @@ pub mod test { header.sign(&privk).unwrap(); StacksMicroblock { - header: header, + header, txs: txs_mblock, } } diff --git a/stackslib/src/chainstate/stacks/tests/mod.rs b/stackslib/src/chainstate/stacks/tests/mod.rs index 9a6a84507e..148f37edf2 100644 --- a/stackslib/src/chainstate/stacks/tests/mod.rs +++ b/stackslib/src/chainstate/stacks/tests/mod.rs @@ -203,9 +203,9 @@ impl TestMinerTrace { points: Vec, ) -> TestMinerTrace { TestMinerTrace { - points: points, - burn_node: burn_node, - miners: miners, + points, + burn_node, + miners, } } @@ -288,7 +288,7 @@ impl TestStacksNode { let chainstate = instantiate_chainstate_with_balances(mainnet, chain_id, test_name, initial_balances); TestStacksNode { - chainstate: chainstate, + chainstate, prev_keys: vec![], key_ops: HashMap::new(), anchored_blocks: vec![], @@ -304,7 +304,7 @@ impl TestStacksNode { pub fn open(mainnet: bool, chain_id: u32, test_name: &str) -> TestStacksNode { let chainstate = open_chainstate(mainnet, chain_id, test_name); TestStacksNode { - chainstate: chainstate, + chainstate, prev_keys: vec![], key_ops: HashMap::new(), anchored_blocks: vec![], @@ -319,7 +319,7 @@ impl TestStacksNode { pub fn from_chainstate(chainstate: StacksChainState) -> TestStacksNode { TestStacksNode { - chainstate: chainstate, + chainstate, prev_keys: vec![], key_ops: HashMap::new(), anchored_blocks: vec![], @@ -356,7 +356,7 @@ impl TestStacksNode { new_test_name, ); TestStacksNode { - chainstate: chainstate, + chainstate, prev_keys: self.prev_keys.clone(), key_ops: self.key_ops.clone(), anchored_blocks: self.anchored_blocks.clone(), diff --git a/stackslib/src/chainstate/stacks/transaction.rs b/stackslib/src/chainstate/stacks/transaction.rs index c45b212b68..b1ad0a1d33 100644 --- a/stackslib/src/chainstate/stacks/transaction.rs +++ b/stackslib/src/chainstate/stacks/transaction.rs @@ -722,13 +722,13 @@ impl StacksTransaction { }; StacksTransaction { - version: version, + version, chain_id: 0, - auth: auth, - anchor_mode: anchor_mode, + auth, + anchor_mode, post_condition_mode: TransactionPostConditionMode::Deny, post_conditions: vec![], - payload: payload, + payload, } } diff --git a/stackslib/src/clarity_cli.rs b/stackslib/src/clarity_cli.rs index f23be191ff..a9880ea858 100644 --- a/stackslib/src/clarity_cli.rs +++ b/stackslib/src/clarity_cli.rs @@ -547,7 +547,7 @@ impl CLIHeadersDB { let conn = create_or_open_db(&cli_db_path); let mut db = CLIHeadersDB { db_path: db_path.to_string(), - conn: conn, + conn, }; if instantiate { @@ -567,7 +567,7 @@ impl CLIHeadersDB { let conn = create_or_open_db(&cli_db_path); let db = CLIHeadersDB { db_path: db_path.to_string(), - conn: conn, + conn, }; Ok(db) diff --git a/stackslib/src/clarity_vm/clarity.rs b/stackslib/src/clarity_vm/clarity.rs index a5497cea24..e4856e803e 100644 --- a/stackslib/src/clarity_vm/clarity.rs +++ b/stackslib/src/clarity_vm/clarity.rs @@ -190,7 +190,7 @@ impl<'a, 'b> ClarityBlockConnection<'a, 'b> { cost_track: Some(LimitedCostTracker::new_free()), mainnet: false, chain_id: CHAIN_ID_TESTNET, - epoch: epoch, + epoch, } } diff --git a/stackslib/src/net/api/getheaders.rs b/stackslib/src/net/api/getheaders.rs index fc585fd2e9..d0ae36a0bb 100644 --- a/stackslib/src/net/api/getheaders.rs +++ b/stackslib/src/net/api/getheaders.rs @@ -90,7 +90,7 @@ impl StacksHeaderStream { index_block_hash: tip.clone(), offset: 0, total_bytes: 0, - num_headers: num_headers, + num_headers, end_of_stream: false, corked: false, chainstate_db: db, diff --git a/stackslib/src/net/api/getmicroblocks_indexed.rs b/stackslib/src/net/api/getmicroblocks_indexed.rs index 43a3a73e04..4a1b310ae0 100644 --- a/stackslib/src/net/api/getmicroblocks_indexed.rs +++ b/stackslib/src/net/api/getmicroblocks_indexed.rs @@ -94,8 +94,8 @@ impl StacksIndexedMicroblockStream { Ok(StacksIndexedMicroblockStream { microblock_hash: mblock_info.microblock_hash, - parent_index_block_hash: parent_index_block_hash, - num_items_buf: num_items_buf, + parent_index_block_hash, + num_items_buf, num_items_ptr: 0, chainstate_db: chainstate.reopen_db()?, }) diff --git a/stackslib/src/net/api/gettransaction_unconfirmed.rs b/stackslib/src/net/api/gettransaction_unconfirmed.rs index 9a76ee002b..9628817b40 100644 --- a/stackslib/src/net/api/gettransaction_unconfirmed.rs +++ b/stackslib/src/net/api/gettransaction_unconfirmed.rs @@ -130,7 +130,7 @@ impl RPCRequestHandler for RPCGetTransactionUnconfirmedRequestHandler { return Ok(UnconfirmedTransactionResponse { status: UnconfirmedTransactionStatus::Microblock { block_hash: mblock_hash, - seq: seq, + seq, }, tx: to_hex(&transaction.serialize_to_vec()), }); diff --git a/stackslib/src/net/asn.rs b/stackslib/src/net/asn.rs index f38c6c54d4..c28e82484b 100644 --- a/stackslib/src/net/asn.rs +++ b/stackslib/src/net/asn.rs @@ -214,9 +214,9 @@ impl ASEntry4 { let asn = asn_opt.unwrap(); Ok(Some(ASEntry4 { - prefix: prefix, - mask: mask, - asn: asn, + prefix, + mask, + asn, org: 0, // TODO })) } diff --git a/stackslib/src/net/atlas/mod.rs b/stackslib/src/net/atlas/mod.rs index 45100d984b..c382aa618d 100644 --- a/stackslib/src/net/atlas/mod.rs +++ b/stackslib/src/net/atlas/mod.rs @@ -229,7 +229,7 @@ impl AttachmentInstance { metadata, contract_id: contract_id.clone(), tx_id, - canonical_stacks_tip_height: canonical_stacks_tip_height, + canonical_stacks_tip_height, }; return Some(instance); } diff --git a/stackslib/src/net/chat.rs b/stackslib/src/net/chat.rs index 1d8e5d10d2..8601700ff5 100644 --- a/stackslib/src/net/chat.rs +++ b/stackslib/src/net/chat.rs @@ -136,7 +136,7 @@ pub struct NeighborStats { impl NeighborStats { pub fn new(outbound: bool) -> NeighborStats { NeighborStats { - outbound: outbound, + outbound, first_contact_time: 0, last_contact_time: 0, last_send_time: 0, @@ -164,7 +164,7 @@ impl NeighborStats { /// message, or failed to do so (indicated by `success`). pub fn add_healthpoint(&mut self, success: bool) -> () { let hp = NeighborHealthPoint { - success: success, + success, time: get_epoch_time_secs(), }; self.healthpoints.push_back(hp); @@ -236,7 +236,7 @@ impl NeighborStats { } else { let info = RelayStats { num_messages: 1, - num_bytes: num_bytes, + num_bytes, last_seen: get_epoch_time_secs(), }; self.relayed_messages.insert(addr.clone(), info); @@ -427,8 +427,8 @@ impl NeighborKey { handshake_data: &HandshakeData, ) -> NeighborKey { NeighborKey { - peer_version: peer_version, - network_id: network_id, + peer_version, + network_id, addrbytes: handshake_data.addrbytes.clone(), port: handshake_data.port, } @@ -436,8 +436,8 @@ impl NeighborKey { pub fn from_socketaddr(peer_version: u32, network_id: u32, addr: &SocketAddr) -> NeighborKey { NeighborKey { - peer_version: peer_version, - network_id: network_id, + peer_version, + network_id, addrbytes: PeerAddress::from_socketaddr(addr), port: addr.port(), } @@ -1202,7 +1202,7 @@ impl ConversationP2P { let natpunch_data = NatPunchData { addrbytes: self.peer_addrbytes.clone(), port: self.peer_port, - nonce: nonce, + nonce, }; let msg = StacksMessage::from_chain_view( self.version, @@ -3347,7 +3347,7 @@ mod test { network_id: 0, chain_name: "bitcoin".to_string(), network_name: "testnet".to_string(), - working_dir: format!("/tmp/stacks-test-databases-{}", test_name), + working_dir: format!("/tmp/stacks-test-databases-{test_name}"), consensus_hash_lifetime: 24, stable_confirmations: 7, first_block_height: 12300, diff --git a/stackslib/src/net/codec.rs b/stackslib/src/net/codec.rs index bd8154e414..c3dd63b1d0 100644 --- a/stackslib/src/net/codec.rs +++ b/stackslib/src/net/codec.rs @@ -65,8 +65,8 @@ impl Preamble { payload_len: u32, ) -> Preamble { Preamble { - peer_version: peer_version, - network_id: network_id, + peer_version, + network_id, seq: 0, burn_block_height: block_height, burn_block_hash: burn_block_hash.clone(), @@ -74,7 +74,7 @@ impl Preamble { burn_stable_block_hash: stable_burn_block_hash.clone(), additional_data: 0, signature: MessageSignature::empty(), - payload_len: payload_len, + payload_len, } } @@ -234,8 +234,8 @@ impl StacksMessageCodec for GetBlocksInv { } Ok(GetBlocksInv { - consensus_hash: consensus_hash, - num_blocks: num_blocks, + consensus_hash, + num_blocks, }) } } @@ -435,10 +435,7 @@ impl StacksMessageCodec for PoxInvData { } let pox_bitvec: Vec = read_next_exact::<_, u8>(fd, bitvec_len(bitlen).into())?; - Ok(PoxInvData { - bitlen: bitlen, - pox_bitvec: pox_bitvec, - }) + Ok(PoxInvData { bitlen, pox_bitvec }) } } @@ -454,9 +451,7 @@ impl StacksMessageCodec for BlocksAvailableData { fd, BLOCKS_AVAILABLE_MAX_LEN, )?; - Ok(BlocksAvailableData { - available: available, - }) + Ok(BlocksAvailableData { available }) } } @@ -624,14 +619,14 @@ impl HandshakeData { }; HandshakeData { - addrbytes: addrbytes, - port: port, + addrbytes, + port, services: local_peer.services, node_public_key: StacksPublicKeyBuffer::from_public_key( &Secp256k1PublicKey::from_private(&local_peer.private_key), ), expire_block_height: local_peer.private_key_expire, - data_url: data_url, + data_url, } } } @@ -675,7 +670,7 @@ impl HandshakeAcceptData { pub fn new(local_peer: &LocalPeer, heartbeat_interval: u32) -> HandshakeAcceptData { HandshakeAcceptData { handshake: HandshakeData::from_local_peer(local_peer), - heartbeat_interval: heartbeat_interval, + heartbeat_interval, } } } @@ -1384,7 +1379,7 @@ impl StacksMessage { 0, ); StacksMessage { - preamble: preamble, + preamble, relayers: vec![], payload: message, } @@ -1414,7 +1409,7 @@ impl StacksMessage { peer_version: self.preamble.peer_version, network_id: self.preamble.network_id, addrbytes: addrbytes.clone(), - port: port, + port, } } @@ -1573,8 +1568,8 @@ impl ProtocolFamily for StacksP2P { let (relayers, payload) = StacksMessage::deserialize_body(&mut cursor)?; let message = StacksMessage { preamble: preamble.clone(), - relayers: relayers, - payload: payload, + relayers, + payload, }; Ok((message, cursor.position() as usize)) } diff --git a/stackslib/src/net/connection.rs b/stackslib/src/net/connection.rs index 0e58adb36e..ac86240e48 100644 --- a/stackslib/src/net/connection.rs +++ b/stackslib/src/net/connection.rs @@ -63,7 +63,7 @@ impl ReceiverNotify

{ ReceiverNotify { expected_seq: seq, receiver_input: input, - ttl: ttl, + ttl, } } @@ -104,7 +104,7 @@ impl NetworkReplyHandle

{ receiver_output: Some(output), request_pipe_write: Some(write), deadline: 0, - socket_event_id: socket_event_id, + socket_event_id, } } @@ -113,7 +113,7 @@ impl NetworkReplyHandle

{ receiver_output: None, request_pipe_write: Some(write), deadline: 0, - socket_event_id: socket_event_id, + socket_event_id, } } @@ -1084,7 +1084,7 @@ impl ConnectionOutbox

{ pub fn new(outbox_maxlen: usize) -> ConnectionOutbox

{ ConnectionOutbox { outbox: VecDeque::with_capacity(outbox_maxlen), - outbox_maxlen: outbox_maxlen, + outbox_maxlen, pending_message_fd: None, socket_out_buf: vec![], socket_out_ptr: 0, @@ -1301,7 +1301,7 @@ impl NetworkConnection

{ public_key_opt: Option, ) -> NetworkConnection

{ NetworkConnection { - protocol: protocol, + protocol, options: (*options).clone(), inbox: ConnectionInbox::new(options.inbox_maxlen, public_key_opt), @@ -1867,7 +1867,7 @@ mod test { &BurnchainHeaderHash([0x11; 32]), 12339, &BurnchainHeaderHash([0x22; 32]), - StacksMessageType::Ping(PingData { nonce: nonce }), + StacksMessageType::Ping(PingData { nonce }), ); let privkey = Secp256k1PrivateKey::new(); ping.sign(request_id, &privkey).unwrap(); diff --git a/stackslib/src/net/db.rs b/stackslib/src/net/db.rs index ff6b5a9a05..3eecd7cbc9 100644 --- a/stackslib/src/net/db.rs +++ b/stackslib/src/net/db.rs @@ -162,15 +162,15 @@ impl LocalPeer { ); LocalPeer { - network_id: network_id, - parent_network_id: parent_network_id, + network_id, + parent_network_id, nonce: my_nonce, private_key: pkey, private_key_expire: key_expire, addrbytes: addr, - port: port, - services: services as u16, - data_url: data_url, + port, + services, + data_url, public_ip_address: None, stacker_dbs, } @@ -237,15 +237,15 @@ impl FromRow for LocalPeer { }; Ok(LocalPeer { - network_id: network_id, - parent_network_id: parent_network_id, + network_id, + parent_network_id, private_key: privkey, nonce: nonce_buf, private_key_expire: privkey_expire, - addrbytes: addrbytes, - port: port, - services: services, - data_url: data_url, + addrbytes, + port, + services, + data_url, public_ip_address: None, stacker_dbs, }) @@ -289,20 +289,20 @@ impl FromRow for Neighbor { Ok(Neighbor { addr: NeighborKey { - peer_version: peer_version, - network_id: network_id, - addrbytes: addrbytes, - port: port, + peer_version, + network_id, + addrbytes, + port, }, - public_key: public_key, + public_key, expire_block: expire_block_height, - last_contact_time: last_contact_time, - asn: asn, - org: org, - allowed: allowed, - denied: denied, - in_degree: in_degree, - out_degree: out_degree, + last_contact_time, + asn, + org, + allowed, + denied, + in_degree, + out_degree, }) } } @@ -668,10 +668,7 @@ impl PeerDB { let conn = sqlite_open(path, open_flags, false)?; - let mut db = PeerDB { - conn: conn, - readwrite: readwrite, - }; + let mut db = PeerDB { conn, readwrite }; if create_flag { // instantiate! @@ -753,10 +750,7 @@ impl PeerDB { let conn = sqlite_open(path, open_flags, true)?; - let db = PeerDB { - conn: conn, - readwrite: readwrite, - }; + let db = PeerDB { conn, readwrite }; Ok(db) } @@ -773,10 +767,7 @@ impl PeerDB { }; let conn = sqlite_open(path, open_flags, true)?; - let db = PeerDB { - conn: conn, - readwrite: readwrite, - }; + let db = PeerDB { conn, readwrite }; Ok(db) } @@ -794,7 +785,7 @@ impl PeerDB { let conn = Connection::open_in_memory().map_err(|e| db_error::SqliteError(e))?; let mut db = PeerDB { - conn: conn, + conn, readwrite: true, }; @@ -1246,7 +1237,7 @@ impl PeerDB { // we're preemptively allowing let nk = NeighborKey { peer_version: 0, - network_id: network_id, + network_id, addrbytes: peer_addr.clone(), port: peer_port, }; @@ -1292,7 +1283,7 @@ impl PeerDB { // we're preemptively denying let nk = NeighborKey { peer_version: 0, - network_id: network_id, + network_id, addrbytes: peer_addr.clone(), port: peer_port, }; diff --git a/stackslib/src/net/dns.rs b/stackslib/src/net/dns.rs index aedb73bd62..b07413ea27 100644 --- a/stackslib/src/net/dns.rs +++ b/stackslib/src/net/dns.rs @@ -43,9 +43,9 @@ pub struct DNSRequest { impl DNSRequest { pub fn new(host: String, port: u16, timeout: u128) -> DNSRequest { DNSRequest { - host: host, - port: port, - timeout: timeout, + host, + port, + timeout, } } @@ -76,15 +76,12 @@ pub struct DNSResponse { impl DNSResponse { pub fn new(request: DNSRequest, result: Result, String>) -> DNSResponse { - DNSResponse { - request: request, - result: result, - } + DNSResponse { request, result } } pub fn error(request: DNSRequest, errstr: String) -> DNSResponse { DNSResponse { - request: request, + request, result: Err(errstr), } } @@ -122,7 +119,7 @@ impl DNSResolver { queries: VecDeque::new(), inbound: socket_chan_rx, outbound: dns_chan_tx, - max_inflight: max_inflight, + max_inflight, hardcoded: HashMap::new(), }; (resolver, client) diff --git a/stackslib/src/net/download/epoch2x.rs b/stackslib/src/net/download/epoch2x.rs index c57d9d19bc..a4387cbc92 100644 --- a/stackslib/src/net/download/epoch2x.rs +++ b/stackslib/src/net/download/epoch2x.rs @@ -112,14 +112,14 @@ impl BlockRequestKey { canonical_stacks_tip_height: u64, ) -> BlockRequestKey { BlockRequestKey { - neighbor: neighbor, - data_url: data_url, - consensus_hash: consensus_hash, - anchor_block_hash: anchor_block_hash, - index_block_hash: index_block_hash, - parent_block_header: parent_block_header, - parent_consensus_hash: parent_consensus_hash, - sortition_height: sortition_height, + neighbor, + data_url, + consensus_hash, + anchor_block_hash, + index_block_hash, + parent_block_header, + parent_consensus_hash, + sortition_height, download_start: get_epoch_time_secs(), kind, canonical_stacks_tip_height, @@ -267,13 +267,13 @@ impl BlockDownloader { finished_scan_at: 0, last_inv_update_at: 0, - max_inflight_requests: max_inflight_requests, + max_inflight_requests, blocks_to_try: HashMap::new(), microblocks_to_try: HashMap::new(), parsed_urls: HashMap::new(), dns_lookups: HashMap::new(), - dns_timeout: dns_timeout, + dns_timeout, getblock_requests: HashMap::new(), getmicroblocks_requests: HashMap::new(), @@ -285,7 +285,7 @@ impl BlockDownloader { broken_neighbors: vec![], blocked_urls: HashMap::new(), - download_interval: download_interval, + download_interval, requested_blocks: HashMap::new(), requested_microblocks: HashMap::new(), } diff --git a/stackslib/src/net/http/request.rs b/stackslib/src/net/http/request.rs index 9231071e18..6535f4a14a 100644 --- a/stackslib/src/net/http/request.rs +++ b/stackslib/src/net/http/request.rs @@ -66,13 +66,13 @@ impl HttpRequestPreamble { keep_alive: bool, ) -> HttpRequestPreamble { HttpRequestPreamble { - version: version, - verb: verb, + version, + verb, path_and_query_str, host: PeerHost::from_host_port(hostname, port), content_type: None, content_length: None, - keep_alive: keep_alive, + keep_alive, headers: BTreeMap::new(), } } @@ -98,7 +98,7 @@ impl HttpRequestPreamble { ) -> HttpRequestPreamble { HttpRequestPreamble { version: HttpVersion::Http11, - verb: verb, + verb, path_and_query_str, host: peerhost, content_type: None, @@ -443,14 +443,14 @@ impl StacksMessageCodec for HttpRequestPreamble { }; Ok(HttpRequestPreamble { - version: version, - verb: verb, + version, + verb, path_and_query_str, host: peerhost.unwrap(), - content_type: content_type, - content_length: content_length, - keep_alive: keep_alive, - headers: headers, + content_type, + content_length, + keep_alive, + headers, }) } } diff --git a/stackslib/src/net/http/response.rs b/stackslib/src/net/http/response.rs index 77bcaa730f..c23097398b 100644 --- a/stackslib/src/net/http/response.rs +++ b/stackslib/src/net/http/response.rs @@ -159,12 +159,12 @@ impl HttpResponsePreamble { keep_alive: bool, ) -> HttpResponsePreamble { HttpResponsePreamble { - client_http_version: client_http_version, - status_code: status_code, - reason: reason, - keep_alive: keep_alive, + client_http_version, + status_code, + reason, + keep_alive, content_length: content_length_opt, - content_type: content_type, + content_type, headers: BTreeMap::new(), } } @@ -590,12 +590,12 @@ impl StacksMessageCodec for HttpResponsePreamble { Ok(HttpResponsePreamble { client_http_version, - status_code: status_code, - reason: reason, - keep_alive: keep_alive, + status_code, + reason, + keep_alive, content_type: content_type.unwrap_or(HttpContentType::Bytes), // per the RFC - content_length: content_length, - headers: headers, + content_length, + headers, }) } } diff --git a/stackslib/src/net/inv/epoch2x.rs b/stackslib/src/net/inv/epoch2x.rs index bbdd8f68ae..f1393a34c4 100644 --- a/stackslib/src/net/inv/epoch2x.rs +++ b/stackslib/src/net/inv/epoch2x.rs @@ -82,7 +82,7 @@ impl PeerBlocksInv { num_sortitions: 0, num_reward_cycles: 0, last_updated_at: 0, - first_block_height: first_block_height, + first_block_height, } } @@ -96,13 +96,13 @@ impl PeerBlocksInv { ) -> PeerBlocksInv { assert_eq!(block_inv.len(), microblocks_inv.len()); PeerBlocksInv { - block_inv: block_inv, - microblocks_inv: microblocks_inv, - num_sortitions: num_sortitions, - num_reward_cycles: num_reward_cycles, - pox_inv: pox_inv, + block_inv, + microblocks_inv, + num_sortitions, + num_reward_cycles, + pox_inv, last_updated_at: get_epoch_time_secs(), - first_block_height: first_block_height, + first_block_height, } } @@ -541,7 +541,7 @@ impl NeighborBlockStats { is_bootstrap_peer: bool, ) -> NeighborBlockStats { NeighborBlockStats { - nk: nk, + nk, inv: PeerBlocksInv::empty(first_block_height), pox_reward_cycle: 0, block_reward_cycle: 0, @@ -558,7 +558,7 @@ impl NeighborBlockStats { learned_data: false, learned_data_height: u64::MAX, scans: 0, - is_bootstrap_peer: is_bootstrap_peer, + is_bootstrap_peer, } } @@ -983,11 +983,11 @@ impl InvState { InvState { block_stats: HashMap::new(), - request_timeout: request_timeout, - first_block_height: first_block_height, + request_timeout, + first_block_height, last_change_at: 0, - sync_interval: sync_interval, + sync_interval, hint_learned_data: false, hint_learned_data_height: u64::MAX, diff --git a/stackslib/src/net/mod.rs b/stackslib/src/net/mod.rs index 4af4d2a397..4cca6fc4bb 100644 --- a/stackslib/src/net/mod.rs +++ b/stackslib/src/net/mod.rs @@ -1384,8 +1384,8 @@ impl NeighborKey { na: &NeighborAddress, ) -> NeighborKey { NeighborKey { - peer_version: peer_version, - network_id: network_id, + peer_version, + network_id, addrbytes: na.addrbytes.clone(), port: na.port, } @@ -1558,9 +1558,9 @@ impl NetworkResult { attachments: vec![], synced_transactions: vec![], stacker_db_sync_results: vec![], - num_state_machine_passes: num_state_machine_passes, - num_inv_sync_passes: num_inv_sync_passes, - num_download_passes: num_download_passes, + num_state_machine_passes, + num_inv_sync_passes, + num_download_passes, num_connected_peers, burn_height, coinbase_height, @@ -2639,7 +2639,7 @@ pub mod test { private_key_expire: start_block + conn_opts.private_key_lifetime, initial_neighbors: vec![], asn4_entries: vec![], - burnchain: burnchain, + burnchain, connection_opts: conn_opts, server_port: 32000, http_port: 32001, @@ -2651,7 +2651,7 @@ pub mod test { test_name: "".into(), initial_balances: vec![], initial_lockups: vec![], - spending_account: spending_account, + spending_account, setup_code: "".into(), epochs: None, check_pox_invariants: None, @@ -3204,15 +3204,15 @@ pub mod test { peer_network.local_peer = local_peer; TestPeer { - config: config, + config, network: peer_network, sortdb: Some(sortdb), miner, stacks_node: Some(stacks_node), - relayer: relayer, + relayer, mempool: Some(mempool), - chainstate_path: chainstate_path, - coord: coord, + chainstate_path, + coord, indexer: Some(indexer), malleablized_blocks: vec![], mine_malleablized_blocks: true, diff --git a/stackslib/src/net/neighbors/neighbor.rs b/stackslib/src/net/neighbors/neighbor.rs index 617860063e..4a8b7baf18 100644 --- a/stackslib/src/net/neighbors/neighbor.rs +++ b/stackslib/src/net/neighbors/neighbor.rs @@ -35,7 +35,7 @@ impl Neighbor { Neighbor { addr: key.clone(), public_key: pubk.clone(), - expire_block: expire_block, + expire_block, last_contact_time: 0, allowed: 0, denied: 0, diff --git a/stackslib/src/net/poll.rs b/stackslib/src/net/poll.rs index 0362745f90..a4c2c46465 100644 --- a/stackslib/src/net/poll.rs +++ b/stackslib/src/net/poll.rs @@ -74,9 +74,9 @@ impl NetworkState { let events = mio::Events::with_capacity(event_capacity); Ok(NetworkState { - poll: poll, - events: events, - event_capacity: event_capacity, + poll, + events, + event_capacity, servers: vec![], count: 1, event_map: HashMap::new(), diff --git a/stackslib/src/net/relay.rs b/stackslib/src/net/relay.rs index b93171916c..c8fecd9515 100644 --- a/stackslib/src/net/relay.rs +++ b/stackslib/src/net/relay.rs @@ -3208,7 +3208,7 @@ impl PeerNetwork { let idx_bhh = index_block_hash.clone(); let payload = MicroblocksData { index_anchor_block: index_block_hash, - microblocks: microblocks, + microblocks, }; let message = match self.sign_for_neighbor(recipient, StacksMessageType::Microblocks(payload)) { diff --git a/stackslib/src/net/tests/relay/epoch2x.rs b/stackslib/src/net/tests/relay/epoch2x.rs index f4fc8d9eb8..13e9f928d8 100644 --- a/stackslib/src/net/tests/relay/epoch2x.rs +++ b/stackslib/src/net/tests/relay/epoch2x.rs @@ -934,7 +934,7 @@ fn push_microblocks( ); let msg = StacksMessageType::Microblocks(MicroblocksData { index_anchor_block: StacksBlockHeader::make_index_block_hash(&consensus_hash, &block_hash), - microblocks: microblocks, + microblocks, }); push_message(peer, dest, relay_hints, msg) } @@ -955,7 +955,7 @@ fn broadcast_microblocks( ); let msg = StacksMessageType::Microblocks(MicroblocksData { index_anchor_block: StacksBlockHeader::make_index_block_hash(&consensus_hash, &block_hash), - microblocks: microblocks, + microblocks, }); broadcast_message(peer, relay_hints, msg) } diff --git a/stackslib/src/util_lib/bloom.rs b/stackslib/src/util_lib/bloom.rs index d1632f0b14..bd9706fd59 100644 --- a/stackslib/src/util_lib/bloom.rs +++ b/stackslib/src/util_lib/bloom.rs @@ -373,7 +373,7 @@ impl BloomCounter { Ok(BloomCounter { hasher, table_name: table_name.to_string(), - num_bins: num_bins, + num_bins, num_hashes, counts_rowid: counts_rowid as u32, }) diff --git a/stackslib/src/util_lib/db.rs b/stackslib/src/util_lib/db.rs index 53f597daa2..6c1306afcf 100644 --- a/stackslib/src/util_lib/db.rs +++ b/stackslib/src/util_lib/db.rs @@ -804,7 +804,7 @@ impl<'a, C: Clone, T: MarfTrieId> IndexDBTx<'a, C, T> { IndexDBTx { _index: Some(tx), block_linkage: None, - context: context, + context, } }