apply clippy code suggestions
This commit is contained in:
parent
2a6a3ee518
commit
f14e577ea9
|
@ -53,30 +53,30 @@ fn multi_transaction_block(oversized: bool) -> Block {
|
||||||
let tx = Transaction::zcash_deserialize(&zebra_test::vectors::DUMMY_TX1[..]).unwrap();
|
let tx = Transaction::zcash_deserialize(&zebra_test::vectors::DUMMY_TX1[..]).unwrap();
|
||||||
|
|
||||||
// A block header
|
// A block header
|
||||||
let blockheader = block_header();
|
let header = block_header();
|
||||||
|
|
||||||
// Serialize header
|
// Serialize header
|
||||||
let mut data_header = Vec::new();
|
let mut data_header = Vec::new();
|
||||||
blockheader
|
header
|
||||||
.zcash_serialize(&mut data_header)
|
.zcash_serialize(&mut data_header)
|
||||||
.expect("Block header should serialize");
|
.expect("Block header should serialize");
|
||||||
|
|
||||||
// Calculate the number of transactions we need
|
// Calculate the number of transactions we need
|
||||||
let mut max_transactions_in_block =
|
let mut max_transactions_in_block =
|
||||||
(MAX_BLOCK_BYTES as usize - data_header.len()) / *&zebra_test::vectors::DUMMY_TX1[..].len();
|
(MAX_BLOCK_BYTES as usize - data_header.len()) / zebra_test::vectors::DUMMY_TX1[..].len();
|
||||||
if oversized {
|
if oversized {
|
||||||
max_transactions_in_block = max_transactions_in_block + 1;
|
max_transactions_in_block += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create transactions to be just below or just above the limit
|
// Create transactions to be just below or just above the limit
|
||||||
let many_transactions = std::iter::repeat(Arc::new(tx.clone()))
|
let transactions = std::iter::repeat(Arc::new(tx))
|
||||||
.take(max_transactions_in_block)
|
.take(max_transactions_in_block)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
// Add the transactions into a block
|
// Add the transactions into a block
|
||||||
Block {
|
Block {
|
||||||
header: blockheader,
|
header,
|
||||||
transactions: many_transactions,
|
transactions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,39 +89,39 @@ fn single_transaction_block(oversized: bool) -> Block {
|
||||||
TransparentOutput::zcash_deserialize(&zebra_test::vectors::DUMMY_OUTPUT1[..]).unwrap();
|
TransparentOutput::zcash_deserialize(&zebra_test::vectors::DUMMY_OUTPUT1[..]).unwrap();
|
||||||
|
|
||||||
// A block header
|
// A block header
|
||||||
let blockheader = block_header();
|
let header = block_header();
|
||||||
|
|
||||||
// Serialize header
|
// Serialize header
|
||||||
let mut data_header = Vec::new();
|
let mut data_header = Vec::new();
|
||||||
blockheader
|
header
|
||||||
.zcash_serialize(&mut data_header)
|
.zcash_serialize(&mut data_header)
|
||||||
.expect("Block header should serialize");
|
.expect("Block header should serialize");
|
||||||
|
|
||||||
// Serialize a LockTime
|
// Serialize a LockTime
|
||||||
let locktime = LockTime::Time(DateTime::<Utc>::from_utc(
|
let lock_time = LockTime::Time(DateTime::<Utc>::from_utc(
|
||||||
NaiveDateTime::from_timestamp(61, 0),
|
NaiveDateTime::from_timestamp(61, 0),
|
||||||
Utc,
|
Utc,
|
||||||
));
|
));
|
||||||
let mut data_locktime = Vec::new();
|
let mut data_locktime = Vec::new();
|
||||||
locktime
|
lock_time
|
||||||
.zcash_serialize(&mut data_locktime)
|
.zcash_serialize(&mut data_locktime)
|
||||||
.expect("LockTime should serialize");
|
.expect("LockTime should serialize");
|
||||||
|
|
||||||
// Calculate the number of inputs we need
|
// Calculate the number of inputs we need
|
||||||
let mut max_inputs_in_tx = (MAX_BLOCK_BYTES as usize
|
let mut max_inputs_in_tx = (MAX_BLOCK_BYTES as usize
|
||||||
- data_header.len()
|
- data_header.len()
|
||||||
- *&zebra_test::vectors::DUMMY_OUTPUT1[..].len()
|
- zebra_test::vectors::DUMMY_OUTPUT1[..].len()
|
||||||
- data_locktime.len())
|
- data_locktime.len())
|
||||||
/ (*&zebra_test::vectors::DUMMY_INPUT1[..].len() - 1);
|
/ (zebra_test::vectors::DUMMY_INPUT1[..].len() - 1);
|
||||||
|
|
||||||
if oversized {
|
if oversized {
|
||||||
max_inputs_in_tx = max_inputs_in_tx + 1;
|
max_inputs_in_tx += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut outputs = Vec::new();
|
let mut outputs = Vec::new();
|
||||||
|
|
||||||
// Create inputs to be just below the limit
|
// Create inputs to be just below the limit
|
||||||
let inputs = std::iter::repeat(input.clone())
|
let inputs = std::iter::repeat(input)
|
||||||
.take(max_inputs_in_tx)
|
.take(max_inputs_in_tx)
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
|
@ -130,15 +130,15 @@ fn single_transaction_block(oversized: bool) -> Block {
|
||||||
|
|
||||||
// Create a big transaction
|
// Create a big transaction
|
||||||
let big_transaction = Transaction::V1 {
|
let big_transaction = Transaction::V1 {
|
||||||
inputs: inputs.clone(),
|
inputs,
|
||||||
outputs: outputs.clone(),
|
outputs,
|
||||||
lock_time: locktime,
|
lock_time,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Put the big transaction into a block
|
// Put the big transaction into a block
|
||||||
let transactions = vec![Arc::new(big_transaction.clone())];
|
let transactions = vec![Arc::new(big_transaction)];
|
||||||
Block {
|
Block {
|
||||||
header: blockheader,
|
header,
|
||||||
transactions: transactions.clone(),
|
transactions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue