Replace logging backend to log4rs and add log rotation (#1789)
* Replace logging backend to flexi-logger and add log rotation * Changed flexi_logger to log4rs * Disable logging level filtering in Root logger * Support different logging levels for file and stdout * Don't log messages from modules other than Grin-related * Fix formatting * Place backed up compressed log copies into log file directory * Increase default log file size to 16 MiB * Add comment to config file on log_max_size option
This commit is contained in:
@@ -35,7 +35,7 @@ use p2p;
|
||||
use pool;
|
||||
use rand::prelude::*;
|
||||
use store;
|
||||
use util::{OneTime, LOGGER};
|
||||
use util::OneTime;
|
||||
|
||||
/// Implementation of the NetAdapter for the . Gets notified when new
|
||||
/// blocks and transactions are received and forwards to the chain and pool
|
||||
@@ -74,7 +74,6 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
let header = self.chain().head_header().unwrap();
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"Received tx {}, inputs: {}, outputs: {}, kernels: {}, going to process.",
|
||||
tx_hash,
|
||||
tx.inputs().len(),
|
||||
@@ -88,13 +87,12 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
};
|
||||
|
||||
if let Err(e) = res {
|
||||
debug!(LOGGER, "Transaction {} rejected: {:?}", tx_hash, e);
|
||||
debug!("Transaction {} rejected: {:?}", tx_hash, e);
|
||||
}
|
||||
}
|
||||
|
||||
fn block_received(&self, b: core::Block, addr: SocketAddr) -> bool {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"Received block {} at {} from {}, inputs: {}, outputs: {}, kernels: {}, going to process.",
|
||||
b.hash(),
|
||||
b.header.height,
|
||||
@@ -109,7 +107,6 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
fn compact_block_received(&self, cb: core::CompactBlock, addr: SocketAddr) -> bool {
|
||||
let bhash = cb.hash();
|
||||
debug!(
|
||||
LOGGER,
|
||||
"Received compact_block {} at {} from {}, outputs: {}, kernels: {}, kern_ids: {}, going to process.",
|
||||
bhash,
|
||||
cb.header.height,
|
||||
@@ -125,7 +122,7 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
match core::Block::hydrate_from(cb, vec![]) {
|
||||
Ok(block) => self.process_block(block, addr),
|
||||
Err(e) => {
|
||||
debug!(LOGGER, "Invalid hydrated block {}: {}", cb_hash, e);
|
||||
debug!("Invalid hydrated block {}: {}", cb_hash, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -135,7 +132,7 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
.chain()
|
||||
.process_block_header(&cb.header, self.chain_opts())
|
||||
{
|
||||
debug!(LOGGER, "Invalid compact block header {}: {}", cb_hash, e);
|
||||
debug!("Invalid compact block header {}: {}", cb_hash, e);
|
||||
return !e.is_bad_data();
|
||||
}
|
||||
|
||||
@@ -145,7 +142,6 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
};
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"adapter: txs from tx pool - {}, (unknown kern_ids: {})",
|
||||
txs.len(),
|
||||
missing_short_ids.len(),
|
||||
@@ -159,7 +155,7 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
let block = match core::Block::hydrate_from(cb.clone(), txs) {
|
||||
Ok(block) => block,
|
||||
Err(e) => {
|
||||
debug!(LOGGER, "Invalid hydrated block {}: {}", cb.hash(), e);
|
||||
debug!("Invalid hydrated block {}: {}", cb.hash(), e);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -169,29 +165,22 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
.validate(&prev.total_kernel_offset, self.verifier_cache.clone())
|
||||
.is_ok()
|
||||
{
|
||||
debug!(LOGGER, "adapter: successfully hydrated block from tx pool!");
|
||||
debug!("adapter: successfully hydrated block from tx pool!");
|
||||
self.process_block(block, addr)
|
||||
} else {
|
||||
if self.sync_state.status() == SyncStatus::NoSync {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"adapter: block invalid after hydration, requesting full block"
|
||||
);
|
||||
debug!("adapter: block invalid after hydration, requesting full block");
|
||||
self.request_block(&cb.header, &addr);
|
||||
true
|
||||
} else {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"adapter: block invalid after hydration, ignoring it, cause still syncing"
|
||||
);
|
||||
true
|
||||
}
|
||||
}
|
||||
} else {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"adapter: failed to retrieve previous block header (still syncing?)"
|
||||
);
|
||||
debug!("adapter: failed to retrieve previous block header (still syncing?)");
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -200,8 +189,8 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
fn header_received(&self, bh: core::BlockHeader, addr: SocketAddr) -> bool {
|
||||
let bhash = bh.hash();
|
||||
debug!(
|
||||
LOGGER,
|
||||
"Received block header {} at {} from {}, going to process.", bhash, bh.height, addr,
|
||||
"Received block header {} at {} from {}, going to process.",
|
||||
bhash, bh.height, addr,
|
||||
);
|
||||
|
||||
// pushing the new block header through the header chain pipeline
|
||||
@@ -209,16 +198,11 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
let res = self.chain().process_block_header(&bh, self.chain_opts());
|
||||
|
||||
if let &Err(ref e) = &res {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"Block header {} refused by chain: {:?}",
|
||||
bhash,
|
||||
e.kind()
|
||||
);
|
||||
debug!("Block header {} refused by chain: {:?}", bhash, e.kind());
|
||||
if e.is_bad_data() {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"header_received: {} is a bad header, resetting header head", bhash
|
||||
"header_received: {} is a bad header, resetting header head",
|
||||
bhash
|
||||
);
|
||||
let _ = self.chain().reset_head();
|
||||
return false;
|
||||
@@ -239,7 +223,6 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
|
||||
fn headers_received(&self, bhs: Vec<core::BlockHeader>, addr: SocketAddr) -> bool {
|
||||
info!(
|
||||
LOGGER,
|
||||
"Received block headers {:?} from {}",
|
||||
bhs.iter().map(|x| x.hash()).collect::<Vec<_>>(),
|
||||
addr,
|
||||
@@ -252,7 +235,7 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
// try to add headers to our header chain
|
||||
let res = self.chain().sync_block_headers(&bhs, self.chain_opts());
|
||||
if let &Err(ref e) = &res {
|
||||
debug!(LOGGER, "Block headers refused by chain: {:?}", e);
|
||||
debug!("Block headers refused by chain: {:?}", e);
|
||||
|
||||
if e.is_bad_data() {
|
||||
return false;
|
||||
@@ -262,14 +245,14 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
}
|
||||
|
||||
fn locate_headers(&self, locator: Vec<Hash>) -> Vec<core::BlockHeader> {
|
||||
debug!(LOGGER, "locate_headers: {:?}", locator,);
|
||||
debug!("locate_headers: {:?}", locator,);
|
||||
|
||||
let header = match self.find_common_header(locator) {
|
||||
Some(header) => header,
|
||||
None => return vec![],
|
||||
};
|
||||
|
||||
debug!(LOGGER, "locate_headers: common header: {:?}", header.hash(),);
|
||||
debug!("locate_headers: common header: {:?}", header.hash(),);
|
||||
|
||||
// looks like we know one, getting as many following headers as allowed
|
||||
let hh = header.height;
|
||||
@@ -281,18 +264,14 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
Err(e) => match e.kind() {
|
||||
chain::ErrorKind::StoreErr(store::Error::NotFoundErr(_), _) => break,
|
||||
_ => {
|
||||
error!(LOGGER, "Could not build header locator: {:?}", e);
|
||||
error!("Could not build header locator: {:?}", e);
|
||||
return vec![];
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"locate_headers: returning headers: {}",
|
||||
headers.len(),
|
||||
);
|
||||
debug!("locate_headers: returning headers: {}", headers.len(),);
|
||||
|
||||
headers
|
||||
}
|
||||
@@ -317,10 +296,7 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
reader: read,
|
||||
}),
|
||||
Err(e) => {
|
||||
warn!(
|
||||
LOGGER,
|
||||
"Couldn't produce txhashset data for block {}: {:?}", h, e
|
||||
);
|
||||
warn!("Couldn't produce txhashset data for block {}: {:?}", h, e);
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -367,12 +343,12 @@ impl p2p::ChainAdapter for NetToChainAdapter {
|
||||
.chain()
|
||||
.txhashset_write(h, txhashset_data, self.sync_state.as_ref())
|
||||
{
|
||||
error!(LOGGER, "Failed to save txhashset archive: {}", e);
|
||||
error!("Failed to save txhashset archive: {}", e);
|
||||
let is_good_data = !e.is_bad_data();
|
||||
self.sync_state.set_sync_error(types::Error::Chain(e));
|
||||
is_good_data
|
||||
} else {
|
||||
info!(LOGGER, "Received valid txhashset data for {}.", h);
|
||||
info!("Received valid txhashset data for {}.", h);
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -447,7 +423,7 @@ impl NetToChainAdapter {
|
||||
self.find_common_header(locator[1..].to_vec())
|
||||
}
|
||||
_ => {
|
||||
error!(LOGGER, "Could not build header locator: {:?}", e);
|
||||
error!("Could not build header locator: {:?}", e);
|
||||
None
|
||||
}
|
||||
},
|
||||
@@ -479,8 +455,8 @@ impl NetToChainAdapter {
|
||||
}
|
||||
Err(ref e) if e.is_bad_data() => {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"adapter: process_block: {} is a bad block, resetting head", bhash
|
||||
"adapter: process_block: {} is a bad block, resetting head",
|
||||
bhash
|
||||
);
|
||||
let _ = self.chain().reset_head();
|
||||
|
||||
@@ -495,14 +471,13 @@ impl NetToChainAdapter {
|
||||
chain::ErrorKind::Orphan => {
|
||||
// make sure we did not miss the parent block
|
||||
if !self.chain().is_orphan(&prev_hash) && !self.sync_state.is_syncing() {
|
||||
debug!(LOGGER, "adapter: process_block: received an orphan block, checking the parent: {:}", prev_hash);
|
||||
debug!("adapter: process_block: received an orphan block, checking the parent: {:}", prev_hash);
|
||||
self.request_block_by_hash(prev_hash, &addr)
|
||||
}
|
||||
true
|
||||
}
|
||||
_ => {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"adapter: process_block: block {} refused by chain: {}",
|
||||
bhash,
|
||||
e.kind()
|
||||
@@ -527,8 +502,8 @@ impl NetToChainAdapter {
|
||||
let now = Instant::now();
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"adapter: process_block: ***** validating full chain state at {}", bhash,
|
||||
"adapter: process_block: ***** validating full chain state at {}",
|
||||
bhash,
|
||||
);
|
||||
|
||||
self.chain()
|
||||
@@ -536,7 +511,6 @@ impl NetToChainAdapter {
|
||||
.expect("chain validation failed, hard stop");
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"adapter: process_block: ***** done validating full chain state, took {}s",
|
||||
now.elapsed().as_secs(),
|
||||
);
|
||||
@@ -558,7 +532,7 @@ impl NetToChainAdapter {
|
||||
.name("compactor".to_string())
|
||||
.spawn(move || {
|
||||
if let Err(e) = chain.compact() {
|
||||
error!(LOGGER, "Could not compact chain: {:?}", e);
|
||||
error!("Could not compact chain: {:?}", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -592,23 +566,19 @@ impl NetToChainAdapter {
|
||||
match self.chain().block_exists(h) {
|
||||
Ok(false) => match self.peers().get_connected_peer(addr) {
|
||||
None => debug!(
|
||||
LOGGER,
|
||||
"send_block_request_to_peer: can't send request to peer {:?}, not connected",
|
||||
addr
|
||||
),
|
||||
Some(peer) => {
|
||||
if let Err(e) = f(&peer, h) {
|
||||
error!(LOGGER, "send_block_request_to_peer: failed: {:?}", e)
|
||||
error!("send_block_request_to_peer: failed: {:?}", e)
|
||||
}
|
||||
}
|
||||
},
|
||||
Ok(true) => debug!(
|
||||
LOGGER,
|
||||
"send_block_request_to_peer: block {} already known", h
|
||||
),
|
||||
Ok(true) => debug!("send_block_request_to_peer: block {} already known", h),
|
||||
Err(e) => error!(
|
||||
LOGGER,
|
||||
"send_block_request_to_peer: failed to check block exists: {:?}", e
|
||||
"send_block_request_to_peer: failed to check block exists: {:?}",
|
||||
e
|
||||
),
|
||||
}
|
||||
}
|
||||
@@ -639,11 +609,10 @@ impl ChainAdapter for ChainToPoolAndNetAdapter {
|
||||
return;
|
||||
}
|
||||
|
||||
debug!(LOGGER, "adapter: block_accepted: {:?}", b.hash());
|
||||
debug!("adapter: block_accepted: {:?}", b.hash());
|
||||
|
||||
if let Err(e) = self.tx_pool.write().reconcile_block(b) {
|
||||
error!(
|
||||
LOGGER,
|
||||
"Pool could not update itself at block {}: {:?}",
|
||||
b.hash(),
|
||||
e,
|
||||
|
||||
@@ -25,7 +25,6 @@ use core::{core, pow};
|
||||
use p2p;
|
||||
use pool;
|
||||
use store;
|
||||
use util::LOGGER;
|
||||
use wallet;
|
||||
|
||||
/// Error type wrapping underlying module errors.
|
||||
@@ -314,10 +313,7 @@ impl SyncState {
|
||||
|
||||
let mut status = self.current.write();
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"sync_state: sync_status: {:?} -> {:?}", *status, new_status,
|
||||
);
|
||||
debug!("sync_state: sync_status: {:?} -> {:?}", *status, new_status,);
|
||||
|
||||
*status = new_status;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ use core::core::hash::Hashed;
|
||||
use core::core::transaction;
|
||||
use core::core::verifier_cache::VerifierCache;
|
||||
use pool::{DandelionConfig, PoolEntryState, PoolError, TransactionPool, TxSource};
|
||||
use util::LOGGER;
|
||||
|
||||
/// A process to monitor transactions in the stempool.
|
||||
/// With Dandelion, transaction can be broadcasted in stem or fluff phase.
|
||||
@@ -40,7 +39,7 @@ pub fn monitor_transactions(
|
||||
verifier_cache: Arc<RwLock<VerifierCache>>,
|
||||
stop: Arc<AtomicBool>,
|
||||
) {
|
||||
debug!(LOGGER, "Started Dandelion transaction monitor.");
|
||||
debug!("Started Dandelion transaction monitor.");
|
||||
|
||||
let _ = thread::Builder::new()
|
||||
.name("dandelion".to_string())
|
||||
@@ -58,26 +57,26 @@ pub fn monitor_transactions(
|
||||
// Aggregate them up to give a single (valid) aggregated tx and propagate it
|
||||
// to the next Dandelion relay along the stem.
|
||||
if process_stem_phase(tx_pool.clone(), verifier_cache.clone()).is_err() {
|
||||
error!(LOGGER, "dand_mon: Problem with stem phase.");
|
||||
error!("dand_mon: Problem with stem phase.");
|
||||
}
|
||||
|
||||
// Step 2: find all "ToFluff" entries in stempool from last run.
|
||||
// Aggregate them up to give a single (valid) aggregated tx and (re)add it
|
||||
// to our pool with stem=false (which will then broadcast it).
|
||||
if process_fluff_phase(tx_pool.clone(), verifier_cache.clone()).is_err() {
|
||||
error!(LOGGER, "dand_mon: Problem with fluff phase.");
|
||||
error!("dand_mon: Problem with fluff phase.");
|
||||
}
|
||||
|
||||
// Step 3: now find all "Fresh" entries in stempool since last run.
|
||||
// Coin flip for each (90/10) and label them as either "ToStem" or "ToFluff".
|
||||
// We will process these in the next run (waiting patience secs).
|
||||
if process_fresh_entries(dandelion_config.clone(), tx_pool.clone()).is_err() {
|
||||
error!(LOGGER, "dand_mon: Problem processing fresh pool entries.");
|
||||
error!("dand_mon: Problem processing fresh pool entries.");
|
||||
}
|
||||
|
||||
// Step 4: now find all expired entries based on embargo timer.
|
||||
if process_expired_entries(dandelion_config.clone(), tx_pool.clone()).is_err() {
|
||||
error!(LOGGER, "dand_mon: Problem processing fresh pool entries.");
|
||||
error!("dand_mon: Problem processing fresh pool entries.");
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -103,21 +102,14 @@ fn process_stem_phase(
|
||||
.transition_to_state(&stem_txs, PoolEntryState::Stemmed);
|
||||
|
||||
if stem_txs.len() > 0 {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"dand_mon: Found {} txs for stemming.",
|
||||
stem_txs.len()
|
||||
);
|
||||
debug!("dand_mon: Found {} txs for stemming.", stem_txs.len());
|
||||
|
||||
let agg_tx = transaction::aggregate(stem_txs)?;
|
||||
agg_tx.validate(verifier_cache.clone())?;
|
||||
|
||||
let res = tx_pool.adapter.stem_tx_accepted(&agg_tx);
|
||||
if res.is_err() {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"dand_mon: Unable to propagate stem tx. No relay, fluffing instead."
|
||||
);
|
||||
debug!("dand_mon: Unable to propagate stem tx. No relay, fluffing instead.");
|
||||
|
||||
let src = TxSource {
|
||||
debug_name: "no_relay".to_string(),
|
||||
@@ -150,11 +142,7 @@ fn process_fluff_phase(
|
||||
.transition_to_state(&stem_txs, PoolEntryState::Fluffed);
|
||||
|
||||
if stem_txs.len() > 0 {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"dand_mon: Found {} txs for fluffing.",
|
||||
stem_txs.len()
|
||||
);
|
||||
debug!("dand_mon: Found {} txs for fluffing.", stem_txs.len());
|
||||
|
||||
let agg_tx = transaction::aggregate(stem_txs)?;
|
||||
agg_tx.validate(verifier_cache.clone())?;
|
||||
@@ -186,7 +174,6 @@ fn process_fresh_entries(
|
||||
|
||||
if fresh_entries.len() > 0 {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"dand_mon: Found {} fresh entries in stempool.",
|
||||
fresh_entries.len()
|
||||
);
|
||||
@@ -220,21 +207,13 @@ fn process_expired_entries(
|
||||
.iter()
|
||||
.filter(|x| x.tx_at.timestamp() < cutoff)
|
||||
{
|
||||
debug!(
|
||||
LOGGER,
|
||||
"dand_mon: Embargo timer expired for {:?}",
|
||||
entry.tx.hash()
|
||||
);
|
||||
debug!("dand_mon: Embargo timer expired for {:?}", entry.tx.hash());
|
||||
expired_entries.push(entry.clone());
|
||||
}
|
||||
}
|
||||
|
||||
if expired_entries.len() > 0 {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"dand_mon: Found {} expired txs.",
|
||||
expired_entries.len()
|
||||
);
|
||||
debug!("dand_mon: Found {} expired txs.", expired_entries.len());
|
||||
|
||||
{
|
||||
let mut tx_pool = tx_pool.write();
|
||||
@@ -246,11 +225,8 @@ fn process_expired_entries(
|
||||
identifier: "?.?.?.?".to_string(),
|
||||
};
|
||||
match tx_pool.add_to_pool(src, entry.tx, false, &header) {
|
||||
Ok(_) => debug!(
|
||||
LOGGER,
|
||||
"dand_mon: embargo expired, fluffed tx successfully."
|
||||
),
|
||||
Err(e) => debug!(LOGGER, "dand_mon: Failed to fluff expired tx - {:?}", e),
|
||||
Ok(_) => debug!("dand_mon: embargo expired, fluffed tx successfully."),
|
||||
Err(e) => debug!("dand_mon: Failed to fluff expired tx - {:?}", e),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
+14
-19
@@ -27,7 +27,6 @@ use std::{cmp, io, str, thread, time};
|
||||
use p2p;
|
||||
use p2p::ChainAdapter;
|
||||
use pool::DandelionConfig;
|
||||
use util::LOGGER;
|
||||
|
||||
// DNS Seeds with contact email associated
|
||||
const DNS_SEEDS: &'static [&'static str] = &[
|
||||
@@ -119,8 +118,8 @@ fn monitor_peers(
|
||||
if interval >= config.ban_window() {
|
||||
peers.unban_peer(&x.addr);
|
||||
debug!(
|
||||
LOGGER,
|
||||
"monitor_peers: unbanned {} after {} seconds", x.addr, interval
|
||||
"monitor_peers: unbanned {} after {} seconds",
|
||||
x.addr, interval
|
||||
);
|
||||
} else {
|
||||
banned_count += 1;
|
||||
@@ -132,7 +131,6 @@ fn monitor_peers(
|
||||
}
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"monitor_peers: on {}:{}, {} connected ({} most_work). \
|
||||
all {} = {} healthy + {} banned + {} defunct",
|
||||
config.host,
|
||||
@@ -158,8 +156,8 @@ fn monitor_peers(
|
||||
let mut connected_peers: Vec<SocketAddr> = vec![];
|
||||
for p in peers.connected_peers() {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"monitor_peers: {}:{} ask {} for more peers", config.host, config.port, p.info.addr,
|
||||
"monitor_peers: {}:{} ask {} for more peers",
|
||||
config.host, config.port, p.info.addr,
|
||||
);
|
||||
let _ = p.send_peer_request(capabilities);
|
||||
connected_peers.push(p.info.addr)
|
||||
@@ -178,7 +176,7 @@ fn monitor_peers(
|
||||
}
|
||||
}
|
||||
}
|
||||
None => debug!(LOGGER, "monitor_peers: no preferred peers"),
|
||||
None => debug!("monitor_peers: no preferred peers"),
|
||||
}
|
||||
|
||||
// take a random defunct peer and mark it healthy: over a long period any
|
||||
@@ -197,8 +195,8 @@ fn monitor_peers(
|
||||
);
|
||||
for p in new_peers.iter().filter(|p| !peers.is_known(&p.addr)) {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"monitor_peers: on {}:{}, queue to soon try {}", config.host, config.port, p.addr,
|
||||
"monitor_peers: on {}:{}, queue to soon try {}",
|
||||
config.host, config.port, p.addr,
|
||||
);
|
||||
tx.send(p.addr).unwrap();
|
||||
}
|
||||
@@ -208,13 +206,13 @@ fn update_dandelion_relay(peers: Arc<p2p::Peers>, dandelion_config: DandelionCon
|
||||
// Dandelion Relay Updater
|
||||
let dandelion_relay = peers.get_dandelion_relay();
|
||||
if dandelion_relay.is_empty() {
|
||||
debug!(LOGGER, "monitor_peers: no dandelion relay updating");
|
||||
debug!("monitor_peers: no dandelion relay updating");
|
||||
peers.update_dandelion_relay();
|
||||
} else {
|
||||
for last_added in dandelion_relay.keys() {
|
||||
let dandelion_interval = Utc::now().timestamp() - last_added;
|
||||
if dandelion_interval >= dandelion_config.relay_secs.unwrap() as i64 {
|
||||
debug!(LOGGER, "monitor_peers: updating expired dandelion relay");
|
||||
debug!("monitor_peers: updating expired dandelion relay");
|
||||
peers.update_dandelion_relay();
|
||||
}
|
||||
}
|
||||
@@ -242,11 +240,11 @@ fn connect_to_seeds_and_preferred_peers(
|
||||
// If we have preferred peers add them to the connection
|
||||
match peers_preferred_list {
|
||||
Some(mut peers_preferred) => peer_addrs.append(&mut peers_preferred),
|
||||
None => debug!(LOGGER, "No preferred peers"),
|
||||
None => debug!("No preferred peers"),
|
||||
};
|
||||
|
||||
if peer_addrs.len() == 0 {
|
||||
warn!(LOGGER, "No seeds were retrieved.");
|
||||
warn!("No seeds were retrieved.");
|
||||
}
|
||||
|
||||
// connect to this first set of addresses
|
||||
@@ -311,7 +309,7 @@ pub fn dns_seeds() -> Box<Fn() -> Vec<SocketAddr> + Send> {
|
||||
let mut addresses: Vec<SocketAddr> = vec![];
|
||||
for dns_seed in DNS_SEEDS {
|
||||
let temp_addresses = addresses.clone();
|
||||
debug!(LOGGER, "Retrieving seed nodes from dns {}", dns_seed);
|
||||
debug!("Retrieving seed nodes from dns {}", dns_seed);
|
||||
match (dns_seed.to_owned(), 0).to_socket_addrs() {
|
||||
Ok(addrs) => addresses.append(
|
||||
&mut (addrs
|
||||
@@ -321,13 +319,10 @@ pub fn dns_seeds() -> Box<Fn() -> Vec<SocketAddr> + Send> {
|
||||
}).filter(|addr| !temp_addresses.contains(addr))
|
||||
.collect()),
|
||||
),
|
||||
Err(e) => debug!(
|
||||
LOGGER,
|
||||
"Failed to resolve seed {:?} got error {:?}", dns_seed, e
|
||||
),
|
||||
Err(e) => debug!("Failed to resolve seed {:?} got error {:?}", dns_seed, e),
|
||||
}
|
||||
}
|
||||
debug!(LOGGER, "Retrieved seed addresses: {:?}", addresses);
|
||||
debug!("Retrieved seed addresses: {:?}", addresses);
|
||||
addresses
|
||||
})
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ use p2p;
|
||||
use pool;
|
||||
use store;
|
||||
use util::file::get_first_line;
|
||||
use util::LOGGER;
|
||||
|
||||
/// Grin server holding internal structures.
|
||||
pub struct Server {
|
||||
@@ -156,7 +155,7 @@ impl Server {
|
||||
global::ChainTypes::Mainnet => genesis::genesis_testnet2(), //TODO: Fix, obviously
|
||||
};
|
||||
|
||||
info!(LOGGER, "Starting server, genesis block: {}", genesis.hash());
|
||||
info!("Starting server, genesis block: {}", genesis.hash());
|
||||
|
||||
let db_env = Arc::new(store::new_env(config.db_root.clone()));
|
||||
let shared_chain = Arc::new(chain::Chain::init(
|
||||
@@ -205,10 +204,7 @@ impl Server {
|
||||
if config.p2p_config.seeding_type.clone() != p2p::Seeding::Programmatic {
|
||||
let seeder = match config.p2p_config.seeding_type.clone() {
|
||||
p2p::Seeding::None => {
|
||||
warn!(
|
||||
LOGGER,
|
||||
"No seed configured, will stay solo until connected to"
|
||||
);
|
||||
warn!("No seed configured, will stay solo until connected to");
|
||||
seed::predefined_seeds(vec![])
|
||||
}
|
||||
p2p::Seeding::List => {
|
||||
@@ -255,7 +251,7 @@ impl Server {
|
||||
.name("p2p-server".to_string())
|
||||
.spawn(move || p2p_inner.listen());
|
||||
|
||||
info!(LOGGER, "Starting rest apis at: {}", &config.api_http_addr);
|
||||
info!("Starting rest apis at: {}", &config.api_http_addr);
|
||||
let api_secret = get_first_line(config.api_secret_path.clone());
|
||||
api::start_rest_apis(
|
||||
config.api_http_addr.clone(),
|
||||
@@ -266,10 +262,7 @@ impl Server {
|
||||
None,
|
||||
);
|
||||
|
||||
info!(
|
||||
LOGGER,
|
||||
"Starting dandelion monitor: {}", &config.api_http_addr
|
||||
);
|
||||
info!("Starting dandelion monitor: {}", &config.api_http_addr);
|
||||
dandelion_monitor::monitor_transactions(
|
||||
config.dandelion_config.clone(),
|
||||
tx_pool.clone(),
|
||||
@@ -277,7 +270,7 @@ impl Server {
|
||||
stop.clone(),
|
||||
);
|
||||
|
||||
warn!(LOGGER, "Grin server started.");
|
||||
warn!("Grin server started.");
|
||||
Ok(Server {
|
||||
config,
|
||||
p2p: p2p_server,
|
||||
@@ -336,7 +329,7 @@ impl Server {
|
||||
/// internal miner, and should only be used for automated testing. Burns
|
||||
/// reward if wallet_listener_url is 'None'
|
||||
pub fn start_test_miner(&self, wallet_listener_url: Option<String>, stop: Arc<AtomicBool>) {
|
||||
info!(LOGGER, "start_test_miner - start",);
|
||||
info!("start_test_miner - start",);
|
||||
let sync_state = self.sync_state.clone();
|
||||
let config_wallet_url = match wallet_listener_url.clone() {
|
||||
Some(u) => u,
|
||||
@@ -467,6 +460,6 @@ impl Server {
|
||||
/// Stops the test miner without stopping the p2p layer
|
||||
pub fn stop_test_miner(&self, stop: Arc<AtomicBool>) {
|
||||
stop.store(true, Ordering::Relaxed);
|
||||
info!(LOGGER, "stop_test_miner - stop",);
|
||||
info!("stop_test_miner - stop",);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ use common::types::{SyncState, SyncStatus};
|
||||
use core::core::hash::{Hash, Hashed, ZERO_HASH};
|
||||
use core::global;
|
||||
use p2p;
|
||||
use util::LOGGER;
|
||||
|
||||
pub struct BodySync {
|
||||
chain: Arc<chain::Chain>,
|
||||
@@ -94,7 +93,6 @@ impl BodySync {
|
||||
self.reset();
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"body_sync: body_head - {}, {}, header_head - {}, {}, sync_head - {}, {}",
|
||||
body_head.last_block_h,
|
||||
body_head.height,
|
||||
@@ -148,7 +146,6 @@ impl BodySync {
|
||||
|
||||
if hashes_to_get.len() > 0 {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"block_sync: {}/{} requesting blocks {:?} from {} peers",
|
||||
body_head.height,
|
||||
header_head.height,
|
||||
@@ -161,7 +158,7 @@ impl BodySync {
|
||||
for hash in hashes_to_get.clone() {
|
||||
if let Some(peer) = peers_iter.next() {
|
||||
if let Err(e) = peer.send_block_request(*hash) {
|
||||
debug!(LOGGER, "Skipped request to {}: {:?}", peer.info.addr, e);
|
||||
debug!("Skipped request to {}: {:?}", peer.info.addr, e);
|
||||
} else {
|
||||
self.body_sync_hashes.push(hash.clone());
|
||||
}
|
||||
@@ -199,7 +196,6 @@ impl BodySync {
|
||||
.filter(|x| !self.chain.get_block(*x).is_ok() && !self.chain.is_orphan(*x))
|
||||
.collect::<Vec<_>>();
|
||||
debug!(
|
||||
LOGGER,
|
||||
"body_sync: {}/{} blocks received, and no more in 200ms",
|
||||
self.body_sync_hashes.len() - hashes_not_get.len(),
|
||||
self.body_sync_hashes.len(),
|
||||
@@ -210,7 +206,6 @@ impl BodySync {
|
||||
None => {
|
||||
if Utc::now() - self.sync_start_ts > Duration::seconds(5) {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"body_sync: 0/{} blocks received in 5s",
|
||||
self.body_sync_hashes.len(),
|
||||
);
|
||||
|
||||
@@ -20,7 +20,6 @@ use chain;
|
||||
use common::types::{Error, SyncState, SyncStatus};
|
||||
use core::core::hash::{Hash, Hashed};
|
||||
use p2p::{self, Peer};
|
||||
use util::LOGGER;
|
||||
|
||||
pub struct HeaderSync {
|
||||
sync_state: Arc<SyncState>,
|
||||
@@ -60,7 +59,6 @@ impl HeaderSync {
|
||||
// but ONLY on initial transition to HeaderSync state.
|
||||
let sync_head = self.chain.get_sync_head().unwrap();
|
||||
debug!(
|
||||
LOGGER,
|
||||
"sync: initial transition to HeaderSync. sync_head: {} at {}, reset to: {} at {}",
|
||||
sync_head.hash(),
|
||||
sync_head.height,
|
||||
@@ -141,8 +139,8 @@ impl HeaderSync {
|
||||
fn request_headers(&mut self, peer: &Peer) {
|
||||
if let Ok(locator) = self.get_locator() {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"sync: request_headers: asking {} for headers, {:?}", peer.info.addr, locator,
|
||||
"sync: request_headers: asking {} for headers, {:?}",
|
||||
peer.info.addr, locator,
|
||||
);
|
||||
|
||||
let _ = peer.send_header_request(locator);
|
||||
@@ -165,7 +163,7 @@ impl HeaderSync {
|
||||
self.history_locators.clear();
|
||||
}
|
||||
|
||||
debug!(LOGGER, "sync: locator heights : {:?}", heights);
|
||||
debug!("sync: locator heights : {:?}", heights);
|
||||
|
||||
let mut locator: Vec<Hash> = vec![];
|
||||
let mut current = self.chain.get_block_header(&tip.last_block_h);
|
||||
@@ -237,7 +235,7 @@ impl HeaderSync {
|
||||
}
|
||||
}
|
||||
|
||||
debug!(LOGGER, "sync: locator heights': {:?}", new_heights);
|
||||
debug!("sync: locator heights': {:?}", new_heights);
|
||||
|
||||
// shrink history_locators properly
|
||||
if heights.len() > 1 {
|
||||
@@ -258,14 +256,13 @@ impl HeaderSync {
|
||||
}
|
||||
}
|
||||
debug!(
|
||||
LOGGER,
|
||||
"sync: history locators: len={}, shrunk={}",
|
||||
self.history_locators.len(),
|
||||
shrunk_size
|
||||
);
|
||||
}
|
||||
|
||||
debug!(LOGGER, "sync: locator: {:?}", locator);
|
||||
debug!("sync: locator: {:?}", locator);
|
||||
|
||||
Ok(locator)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ use common::types::{Error, SyncState, SyncStatus};
|
||||
use core::core::hash::Hashed;
|
||||
use core::global;
|
||||
use p2p::{self, Peer};
|
||||
use util::LOGGER;
|
||||
|
||||
/// Fast sync has 3 "states":
|
||||
/// * syncing headers
|
||||
@@ -77,10 +76,7 @@ impl StateSync {
|
||||
{
|
||||
let clone = self.sync_state.sync_error();
|
||||
if let Some(ref sync_error) = *clone.read() {
|
||||
error!(
|
||||
LOGGER,
|
||||
"fast_sync: error = {:?}. restart fast sync", sync_error
|
||||
);
|
||||
error!("fast_sync: error = {:?}. restart fast sync", sync_error);
|
||||
sync_need_restart = true;
|
||||
}
|
||||
drop(clone);
|
||||
@@ -92,8 +88,8 @@ impl StateSync {
|
||||
if !peer.is_connected() {
|
||||
sync_need_restart = true;
|
||||
info!(
|
||||
LOGGER,
|
||||
"fast_sync: peer connection lost: {:?}. restart", peer.info.addr,
|
||||
"fast_sync: peer connection lost: {:?}. restart",
|
||||
peer.info.addr,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -110,10 +106,7 @@ impl StateSync {
|
||||
|
||||
if let SyncStatus::TxHashsetDownload { .. } = self.sync_state.status() {
|
||||
if download_timeout {
|
||||
error!(
|
||||
LOGGER,
|
||||
"fast_sync: TxHashsetDownload status timeout in 10 minutes!"
|
||||
);
|
||||
error!("fast_sync: TxHashsetDownload status timeout in 10 minutes!");
|
||||
self.sync_state
|
||||
.set_sync_error(Error::P2P(p2p::Error::Timeout));
|
||||
}
|
||||
@@ -168,7 +161,6 @@ impl StateSync {
|
||||
}
|
||||
let bhash = txhashset_head.hash();
|
||||
debug!(
|
||||
LOGGER,
|
||||
"fast_sync: before txhashset request, header head: {} / {}, txhashset_head: {} / {}",
|
||||
header_head.height,
|
||||
header_head.last_block_h,
|
||||
@@ -176,7 +168,7 @@ impl StateSync {
|
||||
bhash
|
||||
);
|
||||
if let Err(e) = peer.send_txhashset_request(txhashset_head.height, bhash) {
|
||||
error!(LOGGER, "fast_sync: send_txhashset_request err! {:?}", e);
|
||||
error!("fast_sync: send_txhashset_request err! {:?}", e);
|
||||
return Err(e);
|
||||
}
|
||||
return Ok(peer.clone());
|
||||
|
||||
@@ -24,7 +24,6 @@ use grin::sync::body_sync::BodySync;
|
||||
use grin::sync::header_sync::HeaderSync;
|
||||
use grin::sync::state_sync::StateSync;
|
||||
use p2p::{self, Peers};
|
||||
use util::LOGGER;
|
||||
|
||||
pub fn run_sync(
|
||||
sync_state: Arc<SyncState>,
|
||||
@@ -164,7 +163,6 @@ fn needs_syncing(
|
||||
if peer.info.total_difficulty() <= local_diff {
|
||||
let ch = chain.head().unwrap();
|
||||
info!(
|
||||
LOGGER,
|
||||
"synchronized at {} @ {} [{}]",
|
||||
local_diff.to_num(),
|
||||
ch.height,
|
||||
@@ -175,7 +173,7 @@ fn needs_syncing(
|
||||
return (false, most_work_height);
|
||||
}
|
||||
} else {
|
||||
warn!(LOGGER, "sync: no peers available, disabling sync");
|
||||
warn!("sync: no peers available, disabling sync");
|
||||
return (false, 0);
|
||||
}
|
||||
} else {
|
||||
@@ -192,7 +190,6 @@ fn needs_syncing(
|
||||
let peer_diff = peer.info.total_difficulty();
|
||||
if peer_diff > local_diff.clone() + threshold.clone() {
|
||||
info!(
|
||||
LOGGER,
|
||||
"sync: total_difficulty {}, peer_difficulty {}, threshold {} (last 5 blocks), enabling sync",
|
||||
local_diff,
|
||||
peer_diff,
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ extern crate serde;
|
||||
extern crate serde_derive;
|
||||
extern crate serde_json;
|
||||
#[macro_use]
|
||||
extern crate slog;
|
||||
extern crate log;
|
||||
extern crate chrono;
|
||||
|
||||
extern crate grin_api as api;
|
||||
|
||||
@@ -28,7 +28,7 @@ use core::core::verifier_cache::VerifierCache;
|
||||
use core::{consensus, core, ser};
|
||||
use keychain::{ExtKeychain, Identifier, Keychain};
|
||||
use pool;
|
||||
use util::{self, LOGGER};
|
||||
use util;
|
||||
use wallet::{self, BlockFees};
|
||||
|
||||
// Ensure a block suitable for mining is built and returned
|
||||
@@ -55,24 +55,22 @@ pub fn get_block(
|
||||
self::Error::Chain(c) => match c.kind() {
|
||||
chain::ErrorKind::DuplicateCommitment(_) => {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"Duplicate commit for potential coinbase detected. Trying next derivation."
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
error!(LOGGER, "Chain Error: {}", c);
|
||||
error!("Chain Error: {}", c);
|
||||
}
|
||||
},
|
||||
self::Error::Wallet(_) => {
|
||||
error!(
|
||||
LOGGER,
|
||||
"Error building new block: Can't connect to wallet listener at {:?}; will retry",
|
||||
wallet_listener_url.as_ref().unwrap()
|
||||
);
|
||||
thread::sleep(Duration::from_secs(wallet_retry_interval));
|
||||
}
|
||||
ae => {
|
||||
warn!(LOGGER, "Error building new block: {:?}. Retrying.", ae);
|
||||
warn!("Error building new block: {:?}. Retrying.", ae);
|
||||
}
|
||||
}
|
||||
thread::sleep(Duration::from_millis(100));
|
||||
@@ -134,7 +132,6 @@ fn build_block(
|
||||
|
||||
let b_difficulty = (b.header.total_difficulty() - head.total_difficulty()).to_num();
|
||||
debug!(
|
||||
LOGGER,
|
||||
"Built new block with {} inputs and {} outputs, network difficulty: {}, cumulative difficulty {}",
|
||||
b.inputs().len(),
|
||||
b.outputs().len(),
|
||||
@@ -159,10 +156,7 @@ fn build_block(
|
||||
|
||||
//Some other issue, possibly duplicate kernel
|
||||
_ => {
|
||||
error!(
|
||||
LOGGER,
|
||||
"Error setting txhashset root to build a block: {:?}", e
|
||||
);
|
||||
error!("Error setting txhashset root to build a block: {:?}", e);
|
||||
Err(Error::Chain(
|
||||
chain::ErrorKind::Other(format!("{:?}", e)).into(),
|
||||
))
|
||||
@@ -176,7 +170,7 @@ fn build_block(
|
||||
/// Probably only want to do this when testing.
|
||||
///
|
||||
fn burn_reward(block_fees: BlockFees) -> Result<(core::Output, core::TxKernel, BlockFees), Error> {
|
||||
warn!(LOGGER, "Burning block fees: {:?}", block_fees);
|
||||
warn!("Burning block fees: {:?}", block_fees);
|
||||
let keychain = ExtKeychain::from_random_seed().unwrap();
|
||||
let key_id = ExtKeychain::derive_key_id(1, 1, 0, 0, 0);
|
||||
let (out, kernel) =
|
||||
@@ -209,7 +203,7 @@ fn get_coinbase(
|
||||
..block_fees
|
||||
};
|
||||
|
||||
debug!(LOGGER, "get_coinbase: {:?}", block_fees);
|
||||
debug!("get_coinbase: {:?}", block_fees);
|
||||
return Ok((output, kernel, block_fees));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ use core::{pow, ser};
|
||||
use keychain;
|
||||
use mining::mine_block;
|
||||
use pool;
|
||||
use util::{self, LOGGER};
|
||||
use util;
|
||||
|
||||
// ----------------------------------------
|
||||
// http://www.jsonrpc.org/specification
|
||||
@@ -114,7 +114,6 @@ fn accept_workers(
|
||||
match stream {
|
||||
Ok(stream) => {
|
||||
warn!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) New connection: {}",
|
||||
id,
|
||||
stream.peer_addr().unwrap()
|
||||
@@ -135,10 +134,7 @@ fn accept_workers(
|
||||
worker_id = worker_id + 1;
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Error accepting connection: {:?}", id, e
|
||||
);
|
||||
warn!("(Server ID: {}) Error accepting connection: {:?}", id, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,8 +181,8 @@ impl Worker {
|
||||
}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Error in connection with stratum client: {}", self.id, e
|
||||
"(Server ID: {}) Error in connection with stratum client: {}",
|
||||
self.id, e
|
||||
);
|
||||
self.error = true;
|
||||
return None;
|
||||
@@ -206,16 +202,16 @@ impl Worker {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
warn!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Error in connection with stratum client: {}", self.id, e
|
||||
"(Server ID: {}) Error in connection with stratum client: {}",
|
||||
self.id, e
|
||||
);
|
||||
self.error = true;
|
||||
}
|
||||
},
|
||||
Err(e) => {
|
||||
warn!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Error in connection with stratum client: {}", self.id, e
|
||||
"(Server ID: {}) Error in connection with stratum client: {}",
|
||||
self.id, e
|
||||
);
|
||||
self.error = true;
|
||||
return;
|
||||
@@ -296,7 +292,6 @@ impl StratumServer {
|
||||
Err(e) => {
|
||||
// not a valid JSON RpcRequest - disconnect the worker
|
||||
warn!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Failed to parse JSONRpc: {} - {:?}",
|
||||
self.id,
|
||||
e.description(),
|
||||
@@ -409,11 +404,8 @@ impl StratumServer {
|
||||
let job_template = self.build_block_template();
|
||||
let response = serde_json::to_value(&job_template).unwrap();
|
||||
debug!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) sending block {} with id {} to single worker",
|
||||
self.id,
|
||||
job_template.height,
|
||||
job_template.job_id,
|
||||
self.id, job_template.height, job_template.job_id,
|
||||
);
|
||||
return Ok(response);
|
||||
}
|
||||
@@ -452,8 +444,8 @@ impl StratumServer {
|
||||
if params.height != self.current_block_versions.last().unwrap().header.height {
|
||||
// Return error status
|
||||
error!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Share at height {} submitted too late", self.id, params.height,
|
||||
"(Server ID: {}) Share at height {} submitted too late",
|
||||
self.id, params.height,
|
||||
);
|
||||
worker_stats.num_stale += 1;
|
||||
let e = RpcError {
|
||||
@@ -467,11 +459,8 @@ impl StratumServer {
|
||||
if b.is_none() {
|
||||
// Return error status
|
||||
error!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Failed to validate solution at height {}: invalid job_id {}",
|
||||
self.id,
|
||||
params.height,
|
||||
params.job_id,
|
||||
self.id, params.height, params.job_id,
|
||||
);
|
||||
worker_stats.num_rejected += 1;
|
||||
let e = RpcError {
|
||||
@@ -491,11 +480,8 @@ impl StratumServer {
|
||||
if share_difficulty < self.minimum_share_difficulty {
|
||||
// Return error status
|
||||
error!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Share rejected due to low difficulty: {}/{}",
|
||||
self.id,
|
||||
share_difficulty,
|
||||
self.minimum_share_difficulty,
|
||||
self.id, share_difficulty, self.minimum_share_difficulty,
|
||||
);
|
||||
worker_stats.num_rejected += 1;
|
||||
let e = RpcError {
|
||||
@@ -511,7 +497,6 @@ impl StratumServer {
|
||||
if let Err(e) = res {
|
||||
// Return error status
|
||||
error!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Failed to validate solution at height {}: {}: {}",
|
||||
self.id,
|
||||
params.height,
|
||||
@@ -528,15 +513,14 @@ impl StratumServer {
|
||||
share_is_block = true;
|
||||
// Log message to make it obvious we found a block
|
||||
warn!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Solution Found for block {} - Yay!!!", self.id, params.height
|
||||
"(Server ID: {}) Solution Found for block {} - Yay!!!",
|
||||
self.id, params.height
|
||||
);
|
||||
} else {
|
||||
// Do some validation but dont submit
|
||||
if !pow::verify_size(&b.header, b.header.pow.proof.edge_bits).is_ok() {
|
||||
// Return error status
|
||||
error!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Failed to validate share at height {} with nonce {} using job_id {}",
|
||||
self.id,
|
||||
params.height,
|
||||
@@ -557,7 +541,6 @@ impl StratumServer {
|
||||
Some(login) => login.clone(),
|
||||
};
|
||||
info!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Got share for block: hash {}, height {}, nonce {}, difficulty {}/{}, submitted by {}",
|
||||
self.id,
|
||||
b.hash(),
|
||||
@@ -588,11 +571,9 @@ impl StratumServer {
|
||||
for num in start..workers_l.len() {
|
||||
if workers_l[num].error == true {
|
||||
warn!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Dropping worker: {}",
|
||||
self.id,
|
||||
workers_l[num].id;
|
||||
);
|
||||
"(Server ID: {}) Dropping worker: {}",
|
||||
self.id, workers_l[num].id
|
||||
);
|
||||
// Update worker stats
|
||||
let mut stratum_stats = stratum_stats.write();
|
||||
let worker_stats_id = stratum_stats
|
||||
@@ -631,11 +612,8 @@ impl StratumServer {
|
||||
};
|
||||
let job_request_json = serde_json::to_string(&job_request).unwrap();
|
||||
debug!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) sending block {} with id {} to stratum clients",
|
||||
self.id,
|
||||
job_template.height,
|
||||
job_template.job_id,
|
||||
self.id, job_template.height, job_template.job_id,
|
||||
);
|
||||
// Push the new block to all connected clients
|
||||
// NOTE: We do not give a unique nonce (should we?) so miners need
|
||||
@@ -659,11 +637,8 @@ impl StratumServer {
|
||||
sync_state: Arc<SyncState>,
|
||||
) {
|
||||
info!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Starting stratum server with edge_bits = {}, proof_size = {}",
|
||||
self.id,
|
||||
edge_bits,
|
||||
proof_size
|
||||
self.id, edge_bits, proof_size
|
||||
);
|
||||
|
||||
self.sync_state = sync_state;
|
||||
@@ -698,7 +673,6 @@ impl StratumServer {
|
||||
}
|
||||
|
||||
warn!(
|
||||
LOGGER,
|
||||
"Stratum server started on {}",
|
||||
self.config.stratum_server_addr.clone().unwrap()
|
||||
);
|
||||
|
||||
@@ -31,7 +31,6 @@ use core::global;
|
||||
use core::pow::PoWContext;
|
||||
use mining::mine_block;
|
||||
use pool;
|
||||
use util::LOGGER;
|
||||
|
||||
pub struct Miner {
|
||||
config: StratumServerConfig,
|
||||
@@ -85,7 +84,6 @@ impl Miner {
|
||||
let deadline = Utc::now().timestamp() + attempt_time_per_block as i64;
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Mining Cuckoo{} for max {}s on {} @ {} [{}].",
|
||||
self.debug_output_id,
|
||||
global::min_edge_bits(),
|
||||
@@ -116,10 +114,8 @@ impl Miner {
|
||||
}
|
||||
|
||||
debug!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) No solution found after {} iterations, continuing...",
|
||||
self.debug_output_id,
|
||||
iter_count
|
||||
self.debug_output_id, iter_count
|
||||
);
|
||||
false
|
||||
}
|
||||
@@ -128,8 +124,8 @@ impl Miner {
|
||||
/// chain anytime required and looking for PoW solution.
|
||||
pub fn run_loop(&self, wallet_listener_url: Option<String>) {
|
||||
info!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Starting test miner loop.", self.debug_output_id
|
||||
"(Server ID: {}) Starting test miner loop.",
|
||||
self.debug_output_id
|
||||
);
|
||||
|
||||
// iteration, we keep the returned derivation to provide it back when
|
||||
@@ -137,7 +133,7 @@ impl Miner {
|
||||
let mut key_id = None;
|
||||
|
||||
while !self.stop.load(Ordering::Relaxed) {
|
||||
trace!(LOGGER, "in miner loop. key_id: {:?}", key_id);
|
||||
trace!("in miner loop. key_id: {:?}", key_id);
|
||||
|
||||
// get the latest chain state and build a block on top of it
|
||||
let head = self.chain.head_header().unwrap();
|
||||
@@ -161,7 +157,6 @@ impl Miner {
|
||||
// we found a solution, push our block through the chain processing pipeline
|
||||
if sol {
|
||||
info!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Found valid proof of work, adding block {}.",
|
||||
self.debug_output_id,
|
||||
b.hash()
|
||||
@@ -169,26 +164,21 @@ impl Miner {
|
||||
let res = self.chain.process_block(b, chain::Options::MINE);
|
||||
if let Err(e) = res {
|
||||
error!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) Error validating mined block: {:?}",
|
||||
self.debug_output_id,
|
||||
e
|
||||
self.debug_output_id, e
|
||||
);
|
||||
}
|
||||
trace!(LOGGER, "resetting key_id in miner to None");
|
||||
trace!("resetting key_id in miner to None");
|
||||
key_id = None;
|
||||
} else {
|
||||
debug!(
|
||||
LOGGER,
|
||||
"setting pubkey in miner to pubkey from block_fees - {:?}", block_fees
|
||||
"setting pubkey in miner to pubkey from block_fees - {:?}",
|
||||
block_fees
|
||||
);
|
||||
key_id = block_fees.key_id();
|
||||
}
|
||||
}
|
||||
|
||||
info!(
|
||||
LOGGER,
|
||||
"(Server ID: {}) test miner exit.", self.debug_output_id
|
||||
);
|
||||
info!("(Server ID: {}) test miner exit.", self.debug_output_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,6 @@ use std::env;
|
||||
use std::io::Error;
|
||||
use std::thread;
|
||||
|
||||
use util::LOGGER;
|
||||
|
||||
/// Future returned from `MainService`.
|
||||
enum MainFuture {
|
||||
Root,
|
||||
@@ -94,10 +92,7 @@ pub fn start_webwallet_server() {
|
||||
let server = Server::bind(&addr)
|
||||
.serve(|| future::ok::<_, Error>(MainService::new()))
|
||||
.map_err(|e| eprintln!("server error: {}", e));
|
||||
warn!(
|
||||
LOGGER,
|
||||
"Grin Web-Wallet Application is running at http://{}/", addr
|
||||
);
|
||||
warn!("Grin Web-Wallet Application is running at http://{}/", addr);
|
||||
rt::run(server);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user