Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all redundant_field_name warnings in stackslib #5627

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions stackslib/src/burnchains/bitcoin/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
}
Expand Down Expand Up @@ -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),
}))
}
Expand Down Expand Up @@ -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),
}))
Expand All @@ -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),
}))
Expand Down
6 changes: 3 additions & 3 deletions stackslib/src/burnchains/bitcoin/bits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
};
Expand Down Expand Up @@ -498,7 +498,7 @@ impl BitcoinTxInputRaw {
) -> BitcoinTxInputRaw {
BitcoinTxInputRaw {
scriptSig: script_sig.clone().into_bytes(),
witness: witness,
witness,
tx_ref: input_txid,
}
}
Expand Down
24 changes: 12 additions & 12 deletions stackslib/src/burnchains/bitcoin/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
})
}
Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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![
Expand Down Expand Up @@ -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![
Expand Down
4 changes: 2 additions & 2 deletions stackslib/src/burnchains/bitcoin/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions stackslib/src/burnchains/bitcoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ impl BitcoinBlock {
block_height: height,
block_hash: hash.clone(),
parent_block_hash: parent.clone(),
txs: txs,
timestamp: timestamp,
txs,
timestamp,
}
}
}
4 changes: 2 additions & 2 deletions stackslib/src/burnchains/bitcoin/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions stackslib/src/burnchains/bitcoin/spv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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,
};
Expand Down
4 changes: 2 additions & 2 deletions stackslib/src/burnchains/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl FromRow<BlockCommitMetadata> for BlockCommitMetadata {
block_height,
vtxindex,
affirmation_id,
anchor_block: anchor_block,
anchor_block,
anchor_block_descendant,
})
}
Expand Down Expand Up @@ -1106,7 +1106,7 @@ impl BurnchainDB {

pub fn tx_begin<'a>(&'a mut self) -> Result<BurnchainDBTransaction<'a>, 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(
Expand Down
4 changes: 2 additions & 2 deletions stackslib/src/burnchains/tests/affirmation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/burnchains/tests/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down
8 changes: 4 additions & 4 deletions stackslib/src/burnchains/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}
}
Expand Down Expand Up @@ -375,7 +375,7 @@ impl TestBurnchainBlock {
burn_header_hash,
}),
],
fork_id: fork_id,
fork_id,
timestamp: get_epoch_time_secs(),
}
}
Expand Down Expand Up @@ -724,7 +724,7 @@ impl TestBurnchainFork {
tip_index_root: start_index_root.clone(),
blocks: vec![],
pending_blocks: vec![],
fork_id: fork_id,
fork_id,
}
}

Expand Down
Loading
Loading