Skip to content

Commit

Permalink
remove duplicate definitions of MARGINAL_FEE
Browse files Browse the repository at this point in the history
  • Loading branch information
zancas committed Apr 3, 2024
1 parent 90df703 commit 3a6fd74
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
2 changes: 0 additions & 2 deletions zingolib/src/lightclient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ use zingoconfig::ZingoConfig;

static LOG_INIT: std::sync::Once = std::sync::Once::new();

const MARGINAL_FEE: u64 = 5_000; // From ZIP-317

#[derive(Clone, Debug, Default)]
pub struct WalletStatus {
pub is_syncing: bool,
Expand Down
17 changes: 8 additions & 9 deletions zingolib/src/lightclient/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use serde::Serialize;
use std::collections::HashMap;
use tokio::runtime::Runtime;
use zcash_address::ZcashAddress;
use zingoconfig::margin_fee;

use zcash_client_backend::encoding::encode_payment_address;
use zcash_primitives::{
Expand All @@ -30,8 +31,6 @@ use super::LightClient;

static LOG_INIT: std::sync::Once = std::sync::Once::new();

const MARGINAL_FEE: u64 = 5_000; // From ZIP-317

#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct AccountBackupInfo {
#[serde(rename = "seed")]
Expand Down Expand Up @@ -201,7 +200,7 @@ impl LightClient {
change += value;
change_note_count += 1;
} else if incoming {
if value > MARGINAL_FEE {
if value > margin_fee() {
useful_value += value;
inbound_note_count_nodust += 1;
} else {
Expand All @@ -219,7 +218,7 @@ impl LightClient {
change += value;
change_note_count += 1;
} else if incoming {
if value > MARGINAL_FEE {
if value > margin_fee() {
useful_value += value;
inbound_note_count_nodust += 1;
} else {
Expand All @@ -234,7 +233,7 @@ impl LightClient {
.for_each(|n| {
// UTXOs are never 'change', as change would have been shielded.
if incoming {
if n.value > MARGINAL_FEE {
if n.value > margin_fee() {
utxo_value += n.value;
inbound_utxo_count_nodust += 1;
} else {
Expand All @@ -244,15 +243,15 @@ impl LightClient {
});

// The fee field only tracks mature income and change.
balances.minimum_fees += change_note_count * MARGINAL_FEE;
balances.minimum_fees += change_note_count * margin_fee();
if mature {
balances.minimum_fees += inbound_note_count_nodust * MARGINAL_FEE;
balances.minimum_fees += inbound_note_count_nodust * margin_fee();
}

// If auto-shielding, UTXOs are considered immature and do not fall into any of the buckets that
// the fee balance covers.
if !auto_shielding {
balances.minimum_fees += inbound_utxo_count_nodust * MARGINAL_FEE;
balances.minimum_fees += inbound_utxo_count_nodust * margin_fee();
}

if auto_shielding {
Expand Down Expand Up @@ -286,7 +285,7 @@ impl LightClient {
// Add the minimum fee for the receiving note,
// but only if there exists notes to spend in the buckets that are covered by the minimum_fee.
if balances.minimum_fees > 0 {
balances.minimum_fees += MARGINAL_FEE; // The receiving note.
balances.minimum_fees += margin_fee(); // The receiving note.
}

Ok(balances)
Expand Down
2 changes: 0 additions & 2 deletions zingolib/src/lightclient/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ use super::LightClient;

static LOG_INIT: std::sync::Once = std::sync::Once::new();

const MARGINAL_FEE: u64 = 5_000; // From ZIP-317

pub(super) struct ZingoSaveBuffer {
pub buffer: Arc<RwLock<Vec<u8>>>,
}
Expand Down
2 changes: 0 additions & 2 deletions zingolib/src/lightclient/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ use super::LightClient;

static LOG_INIT: std::sync::Once = std::sync::Once::new();

const MARGINAL_FEE: u64 = 5_000; // From ZIP-317

#[derive(Debug, Clone)]
pub struct LightWalletSendProgress {
pub progress: SendProgress,
Expand Down
2 changes: 0 additions & 2 deletions zingolib/src/lightclient/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ use super::LightClient;

static LOG_INIT: std::sync::Once = std::sync::Once::new();

const MARGINAL_FEE: u64 = 5_000; // From ZIP-317

#[derive(Clone, Debug, Default)]
pub struct SyncResult {
pub success: bool,
Expand Down

0 comments on commit 3a6fd74

Please sign in to comment.