From 6d56f8a9efae71ba50f1b9f87c9d3bfd2bc70d94 Mon Sep 17 00:00:00 2001 From: Hanh Date: Thu, 24 Nov 2022 12:47:34 +0800 Subject: [PATCH] Reformat --- src/note_selection.rs | 2 +- src/note_selection/builder.rs | 7 ++++--- src/note_selection/optimize.rs | 2 +- src/note_selection/ua.rs | 11 +++++++---- src/prices.rs | 5 +++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/note_selection.rs b/src/note_selection.rs index 09b7aae..98f33f4 100644 --- a/src/note_selection.rs +++ b/src/note_selection.rs @@ -11,8 +11,8 @@ pub use utxo::fetch_utxos; use crate::api::recipient::Recipient; use thiserror::Error; -use zcash_primitives::consensus::Network; use ua::decode; +use zcash_primitives::consensus::Network; use zcash_primitives::memo::Memo; #[derive(Error, Debug)] diff --git a/src/note_selection/builder.rs b/src/note_selection/builder.rs index 4298f2b..6b3d51c 100644 --- a/src/note_selection/builder.rs +++ b/src/note_selection/builder.rs @@ -26,7 +26,7 @@ use zcash_primitives::sapling::prover::TxProver; use zcash_primitives::sapling::{Diversifier, Node, PaymentAddress, Rseed}; use zcash_primitives::transaction::builder::Builder; use zcash_primitives::transaction::components::{Amount, OutPoint, TxOut}; -use zcash_primitives::transaction::sighash::{SignableInput, signature_hash}; +use zcash_primitives::transaction::sighash::{signature_hash, SignableInput}; use zcash_primitives::transaction::txid::TxIdDigester; use zcash_primitives::transaction::{Transaction, TransactionData, TxVersion}; use zcash_primitives::zip32::{ExtendedFullViewingKey, ExtendedSpendingKey}; @@ -56,8 +56,9 @@ impl TxBuilderContext { let TreeCheckpoint { tree, .. } = db.get_tree_by_name(height, "orchard")?; let hasher = OrchardHasher::new(); Some(tree.root(32, &ORCHARD_ROOTS, &hasher)) - } - else { None }; + } else { + None + }; let context = TxBuilderContext { height, sapling_anchor, diff --git a/src/note_selection/optimize.rs b/src/note_selection/optimize.rs index 56dcaac..5aedf5b 100644 --- a/src/note_selection/optimize.rs +++ b/src/note_selection/optimize.rs @@ -1,10 +1,10 @@ -use zcash_primitives::consensus::Network; use super::{types::*, Result}; use crate::note_selection::fee::FeeCalculator; use crate::note_selection::ua::decode; use crate::note_selection::TransactionBuilderError::TxTooComplex; use crate::note_selection::{TransactionBuilderError, MAX_ATTEMPTS}; use crate::Hash; +use zcash_primitives::consensus::Network; use zcash_primitives::memo::MemoBytes; pub fn sum_utxos(utxos: &[UTXO]) -> Result { diff --git a/src/note_selection/ua.rs b/src/note_selection/ua.rs index 8636fd1..8b9cf40 100644 --- a/src/note_selection/ua.rs +++ b/src/note_selection/ua.rs @@ -10,12 +10,15 @@ pub fn decode(network: &Network, address: &str) -> anyhow::Result<[Option {} AddressKind::Sapling(data) => { diff --git a/src/prices.rs b/src/prices.rs index e390a0a..5fddbf2 100644 --- a/src/prices.rs +++ b/src/prices.rs @@ -1,5 +1,5 @@ -use anyhow::anyhow; use crate::DbAdapter; +use anyhow::anyhow; use chrono::NaiveDateTime; use zcash_params::coin::get_coin_chain; @@ -55,7 +55,8 @@ pub async fn fetch_historical_prices( // rounded to daily let date = NaiveDateTime::from_timestamp_opt(ts, 0) .ok_or(anyhow!("Invalid Date"))? - .date().and_hms_opt(0, 0, 0) + .date() + .and_hms_opt(0, 0, 0) .ok_or(anyhow!("Invalid Date"))?; let timestamp = date.timestamp(); if timestamp != prev_timestamp {