aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-09-24 13:08:25 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-09-25 16:00:43 +0000
commit3455efafa812d646f2eea42db14b761f34975147 (patch)
treedffe8ec81dc709f86bbb004017aca3dfa77efa30 /src/rpc
parentMerge pull request #5928 (diff)
downloadmonero-3455efafa812d646f2eea42db14b761f34975147.tar.xz
ban peers sending bad pow outright
PoW is expensive to verify, so be strict
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp4
-rw-r--r--src/rpc/core_rpc_server.h2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 3f53d59cf..ac8e0784f 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -217,13 +217,13 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
- bool core_rpc_server::add_host_fail(const connection_context *ctx)
+ bool core_rpc_server::add_host_fail(const connection_context *ctx, unsigned int score)
{
if(!ctx || !ctx->m_remote_address.is_blockable())
return false;
CRITICAL_REGION_LOCAL(m_host_fails_score_lock);
- uint64_t fails = ++m_host_fails_score[ctx->m_remote_address.host_str()];
+ uint64_t fails = m_host_fails_score[ctx->m_remote_address.host_str()] += score;
MDEBUG("Host " << ctx->m_remote_address.host_str() << " fail score=" << fails);
if(fails > RPC_IP_FAILS_BEFORE_BLOCK)
{
diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h
index 379f6ed28..fe03012b7 100644
--- a/src/rpc/core_rpc_server.h
+++ b/src/rpc/core_rpc_server.h
@@ -241,7 +241,7 @@ namespace cryptonote
private:
bool check_core_busy();
bool check_core_ready();
- bool add_host_fail(const connection_context *ctx);
+ bool add_host_fail(const connection_context *ctx, unsigned int score = 1);
//utils
uint64_t get_block_reward(const block& blk);