mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-11-17 00:07:47 +00:00
P2PServer: added 1 second grace time for stale shares
Only for shares that lag 1 Monero block behind
This commit is contained in:
parent
bb8ff24db8
commit
4757cdb8e2
5 changed files with 13 additions and 4 deletions
|
@ -51,6 +51,7 @@
|
|||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
|
@ -247,6 +248,8 @@ struct MinerData
|
|||
uint64_t already_generated_coins;
|
||||
uint64_t median_timestamp;
|
||||
std::vector<TxMempoolData> tx_backlog;
|
||||
|
||||
std::chrono::system_clock::time_point time_received;
|
||||
};
|
||||
|
||||
struct ChainMain
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "common.h"
|
||||
#include "uv_util.h"
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
|
||||
|
|
|
@ -1273,8 +1273,15 @@ bool P2PServer::P2PClient::on_block_broadcast(const uint8_t* buf, uint32_t size)
|
|||
|
||||
if (peer_height < our_height) {
|
||||
if (our_height - peer_height < 5) {
|
||||
LOGINFO(5, "peer " << static_cast<char*>(m_addrString) << " broadcasted a stale block (mainchain height " << peer_height << ", expected >= " << our_height << "), ignoring it");
|
||||
return true;
|
||||
using namespace std::chrono;
|
||||
const int64_t elapsed_ms = duration_cast<milliseconds>(system_clock::now() - server->m_pool->miner_data().time_received).count();
|
||||
if ((our_height - peer_height > 1) || (elapsed_ms >= 1000)) {
|
||||
LOGWARN(5, "peer " << static_cast<char*>(m_addrString) << " broadcasted a stale block (" << elapsed_ms << " ms late, mainchain height " << peer_height << ", expected >= " << our_height << "), ignoring it");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
LOGINFO(5, "peer " << static_cast<char*>(m_addrString) << " broadcasted a stale block (" << elapsed_ms << " ms late, mainchain height " << peer_height << ", expected >= " << our_height << ")");
|
||||
}
|
||||
}
|
||||
else {
|
||||
LOGWARN(5, "peer " << static_cast<char*>(m_addrString) << " broadcasted an unreasonably stale block (mainchain height " << peer_height << ", expected >= " << our_height << ')');
|
||||
|
|
|
@ -176,6 +176,7 @@ void p2pool::handle_miner_data(MinerData& data)
|
|||
}
|
||||
|
||||
data.tx_backlog.clear();
|
||||
data.time_received = std::chrono::system_clock::now();
|
||||
m_minerData = data;
|
||||
m_updateSeed = true;
|
||||
update_median_timestamp();
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
#include "uv_util.h"
|
||||
#include <map>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <sched.h>
|
||||
|
|
Loading…
Reference in a new issue