Fix various clippy lints
The remainder will be fixed after the refactor PRs are merged.
This commit is contained in:
parent
9d9c0579f8
commit
38f7a0330c
|
@ -138,10 +138,10 @@ impl TransactionRequest {
|
|||
///
|
||||
/// Returns None if the payment request is empty.
|
||||
pub fn to_uri<P: consensus::Parameters>(&self, params: &P) -> Option<String> {
|
||||
fn payment_params<'a>(
|
||||
payment: &'a Payment,
|
||||
fn payment_params(
|
||||
payment: &Payment,
|
||||
payment_index: Option<usize>,
|
||||
) -> impl IntoIterator<Item = String> + 'a {
|
||||
) -> impl IntoIterator<Item = String> + '_ {
|
||||
std::iter::empty()
|
||||
.chain(render::amount_param(payment.amount, payment_index))
|
||||
.chain(
|
||||
|
@ -447,31 +447,34 @@ mod parse {
|
|||
}
|
||||
|
||||
/// Parses and consumes the leading "zcash:\[address\]" from a ZIP 321 URI.
|
||||
pub fn lead_addr<'a, P: consensus::Parameters>(
|
||||
params: &'a P,
|
||||
) -> impl Fn(&str) -> IResult<&str, Option<IndexedParam>> + 'a {
|
||||
pub fn lead_addr<P: consensus::Parameters>(
|
||||
params: &P,
|
||||
) -> impl Fn(&str) -> IResult<&str, Option<IndexedParam>> + '_ {
|
||||
move |input: &str| {
|
||||
map_opt(preceded(tag("zcash:"), take_until("?")), |addr_str| {
|
||||
if addr_str == "" {
|
||||
Some(None) // no address is ok, so wrap in `Some`
|
||||
} else {
|
||||
// `decode` returns `None` on error, which we want to
|
||||
// then cause `map_opt` to fail.
|
||||
RecipientAddress::decode(params, addr_str).map(|a| {
|
||||
Some(IndexedParam {
|
||||
param: Param::Addr(a),
|
||||
payment_index: 0,
|
||||
map_opt(
|
||||
preceded(tag("zcash:"), take_until("?")),
|
||||
|addr_str: &str| {
|
||||
if addr_str.is_empty() {
|
||||
Some(None) // no address is ok, so wrap in `Some`
|
||||
} else {
|
||||
// `decode` returns `None` on error, which we want to
|
||||
// then cause `map_opt` to fail.
|
||||
RecipientAddress::decode(params, addr_str).map(|a| {
|
||||
Some(IndexedParam {
|
||||
param: Param::Addr(a),
|
||||
payment_index: 0,
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})(input)
|
||||
}
|
||||
},
|
||||
)(input)
|
||||
}
|
||||
}
|
||||
|
||||
/// The primary parser for <name>=<value> query-string parameter pair.
|
||||
pub fn zcashparam<'a, P: consensus::Parameters>(
|
||||
params: &'a P,
|
||||
) -> impl Fn(&str) -> IResult<&str, IndexedParam> + 'a {
|
||||
pub fn zcashparam<P: consensus::Parameters>(
|
||||
params: &P,
|
||||
) -> impl Fn(&str) -> IResult<&str, IndexedParam> + '_ {
|
||||
move |input| {
|
||||
map_res(
|
||||
separated_pair(indexed_name, char('='), recognize(qchars)),
|
||||
|
@ -519,7 +522,7 @@ mod parse {
|
|||
}
|
||||
|
||||
/// Parses a value in decimal ZEC.
|
||||
pub fn parse_amount<'a>(input: &'a str) -> IResult<&'a str, Amount> {
|
||||
pub fn parse_amount(input: &str) -> IResult<&str, Amount> {
|
||||
map_res(
|
||||
tuple((
|
||||
digit1,
|
||||
|
@ -583,7 +586,7 @@ mod parse {
|
|||
.map_err(|e| e.to_string()),
|
||||
|
||||
"memo" => memo_from_base64(value)
|
||||
.map(|m| Param::Memo(m))
|
||||
.map(Param::Memo)
|
||||
.map_err(|e| format!("Decoded memo was invalid: {:?}", e)),
|
||||
|
||||
other if other.starts_with("req-") => {
|
||||
|
|
|
@ -758,8 +758,8 @@ pub fn insert_witness<'a, P>(
|
|||
}
|
||||
|
||||
/// Removes old incremental witnesses up to the given block height.
|
||||
pub fn prune_witnesses<'a, P>(
|
||||
stmts: &mut DataConnStmtCache<'a, P>,
|
||||
pub fn prune_witnesses<P>(
|
||||
stmts: &mut DataConnStmtCache<'_, P>,
|
||||
below_height: BlockHeight,
|
||||
) -> Result<(), SqliteClientError> {
|
||||
stmts
|
||||
|
@ -770,8 +770,8 @@ pub fn prune_witnesses<'a, P>(
|
|||
|
||||
/// Marks notes that have not been mined in transactions
|
||||
/// as expired, up to the given block height.
|
||||
pub fn update_expired_notes<'a, P>(
|
||||
stmts: &mut DataConnStmtCache<'a, P>,
|
||||
pub fn update_expired_notes<P>(
|
||||
stmts: &mut DataConnStmtCache<'_, P>,
|
||||
height: BlockHeight,
|
||||
) -> Result<(), SqliteClientError> {
|
||||
stmts.stmt_update_expired.execute(&[u32::from(height)])?;
|
||||
|
|
|
@ -155,8 +155,10 @@ impl NodeData {
|
|||
|
||||
/// Read from the byte representation.
|
||||
pub fn read<R: std::io::Read>(consensus_branch_id: u32, r: &mut R) -> std::io::Result<Self> {
|
||||
let mut data = Self::default();
|
||||
data.consensus_branch_id = consensus_branch_id;
|
||||
let mut data = NodeData {
|
||||
consensus_branch_id,
|
||||
..Default::default()
|
||||
};
|
||||
r.read_exact(&mut data.subtree_commitment)?;
|
||||
data.start_time = r.read_u32::<LittleEndian>()?;
|
||||
data.end_time = r.read_u32::<LittleEndian>()?;
|
||||
|
|
|
@ -138,14 +138,12 @@ impl Tree {
|
|||
pub fn append_leaf(&mut self, new_leaf: NodeData) -> Result<Vec<EntryLink>, Error> {
|
||||
let root = self.root;
|
||||
let new_leaf_link = self.push(new_leaf.into());
|
||||
let mut appended = Vec::new();
|
||||
appended.push(new_leaf_link);
|
||||
let mut appended = vec![new_leaf_link];
|
||||
|
||||
let mut peaks = Vec::new();
|
||||
self.get_peaks(root, &mut peaks)?;
|
||||
|
||||
let mut merge_stack = Vec::new();
|
||||
merge_stack.push(new_leaf_link);
|
||||
let mut merge_stack = vec![new_leaf_link];
|
||||
|
||||
// Scan the peaks right-to-left, merging together equal-sized adjacent
|
||||
// complete subtrees. After this, merge_stack only contains peaks of
|
||||
|
|
|
@ -19,15 +19,16 @@ where
|
|||
assert_eq!(rho.len(), 256);
|
||||
assert_eq!(r.len(), 256);
|
||||
|
||||
let mut image = vec![];
|
||||
image.push(Boolean::constant(true));
|
||||
image.push(Boolean::constant(false));
|
||||
image.push(Boolean::constant(true));
|
||||
image.push(Boolean::constant(true));
|
||||
image.push(Boolean::constant(false));
|
||||
image.push(Boolean::constant(false));
|
||||
image.push(Boolean::constant(false));
|
||||
image.push(Boolean::constant(false));
|
||||
let mut image = vec![
|
||||
Boolean::constant(true),
|
||||
Boolean::constant(false),
|
||||
Boolean::constant(true),
|
||||
Boolean::constant(true),
|
||||
Boolean::constant(false),
|
||||
Boolean::constant(false),
|
||||
Boolean::constant(false),
|
||||
Boolean::constant(false),
|
||||
];
|
||||
image.extend(a_pk.iter().cloned());
|
||||
image.extend(value.iter().cloned());
|
||||
image.extend(rho.iter().cloned());
|
||||
|
|
|
@ -20,11 +20,12 @@ where
|
|||
assert_eq!(x.len(), 252);
|
||||
assert_eq!(y.len(), 256);
|
||||
|
||||
let mut image = vec![];
|
||||
image.push(Boolean::constant(a));
|
||||
image.push(Boolean::constant(b));
|
||||
image.push(Boolean::constant(c));
|
||||
image.push(Boolean::constant(d));
|
||||
let mut image = vec![
|
||||
Boolean::constant(a),
|
||||
Boolean::constant(b),
|
||||
Boolean::constant(c),
|
||||
Boolean::constant(d),
|
||||
];
|
||||
image.extend(x.iter().cloned());
|
||||
image.extend(y.iter().cloned());
|
||||
|
||||
|
|
Loading…
Reference in New Issue