From 6ac2fe2a8cd57349a16382a981f08957d5c0645e Mon Sep 17 00:00:00 2001 From: Ignotus Peverell Date: Tue, 14 Nov 2017 20:14:07 -0500 Subject: [PATCH] Major fee bump to come to more reasonable values Starting on the higher side for testnet to see how it goes in practice. Introduced constants for each smaller unit. --- core/src/consensus.rs | 8 +++++++- pool/src/pool.rs | 7 +++---- pool/src/types.rs | 3 ++- wallet/src/types.rs | 3 ++- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/core/src/consensus.rs b/core/src/consensus.rs index 1624f61c6..ee3e36b7a 100644 --- a/core/src/consensus.rs +++ b/core/src/consensus.rs @@ -25,8 +25,14 @@ use std::cmp::max; use ser; use core::target::Difficulty; -/// A grin is divisible to 10^9, a nanogrin +/// A grin is divisible to 10^9, following the SI prefixes pub const GRIN_BASE: u64 = 1_000_000_000; +/// Milligrin, a thousand of a grin +pub const MILLI_GRIN: u64 = GRIN_BASE / 1_000; +/// Microgrin, a thousand of a milligrin +pub const MICRO_GRIN: u64 = MILLI_GRIN / 1_000; +/// Nanogrin, smallest unit, takes a billion to make a grin +pub const NANO_GRIN: u64 = 1; /// The block subsidy amount pub const REWARD: u64 = 50 * GRIN_BASE; diff --git a/pool/src/pool.rs b/pool/src/pool.rs index a6bd121dd..adbb25663 100644 --- a/pool/src/pool.rs +++ b/pool/src/pool.rs @@ -582,10 +582,9 @@ where return Err(PoolError::OverCapacity); } - // for a basic transaction (1 input, 2 outputs) - - // (-1 * 1) + (4 * 2) + 1 = 8 - // 8 * 10 = 80 - // + // for a basic transaction (1 input, 2 outputs) - + // (-1 * 1) + (4 * 2) + 1 = 8 + // 8 * 10 = 80 if self.config.accept_fee_base > 0 { let mut tx_weight = -1 * (tx.inputs.len() as i32) + (4 * tx.outputs.len() as i32) + 1; if tx_weight < 1 { diff --git a/pool/src/types.rs b/pool/src/types.rs index 19460aa2c..a0cfc2535 100644 --- a/pool/src/types.rs +++ b/pool/src/types.rs @@ -24,6 +24,7 @@ use util::secp::pedersen::Commitment; pub use graph; +use core::consensus; use core::core::block; use core::core::transaction; use core::core::hash; @@ -52,7 +53,7 @@ impl Default for PoolConfig { } fn default_accept_fee_base() -> u64 { - 10 + consensus::MILLI_GRIN } fn default_max_pool_size() -> usize { 50_000 diff --git a/wallet/src/types.rs b/wallet/src/types.rs index d87b49f20..b0e872b5f 100644 --- a/wallet/src/types.rs +++ b/wallet/src/types.rs @@ -32,6 +32,7 @@ use tokio_retry::strategy::FibonacciBackoff; use api; +use core::consensus; use core::core::{transaction, Transaction}; use core::ser; use keychain; @@ -42,7 +43,7 @@ const DAT_FILE: &'static str = "wallet.dat"; const LOCK_FILE: &'static str = "wallet.lock"; const SEED_FILE: &'static str = "wallet.seed"; -const DEFAULT_BASE_FEE: u64 = 10; +const DEFAULT_BASE_FEE: u64 = consensus::MILLI_GRIN; /// Transaction fee calculation pub fn tx_fee(input_len: usize, output_len: usize, base_fee: Option) -> u64 {