aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlexander Blair <snipa@jagtech.io>2020-12-28 11:39:01 -0800
committerAlexander Blair <snipa@jagtech.io>2020-12-28 11:39:01 -0800
commit2bccbeecb3cf931e80a2b299763f7b4b39dc9eaa (patch)
tree313ba86d0736f5c61d94311c4b5da5c4898d7440 /src
parentMerge pull request #7202 (diff)
parentprotocol: fix false positives dropping peers (diff)
downloadmonero-2bccbeecb3cf931e80a2b299763f7b4b39dc9eaa.tar.xz
Merge pull request #7205
bcdc6c62b protocol: fix false positives dropping peers (moneromooo-monero)
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_protocol/cryptonote_protocol_handler.inl44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.inl b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
index cda28368a..22e87465f 100644
--- a/src/cryptonote_protocol/cryptonote_protocol_handler.inl
+++ b/src/cryptonote_protocol/cryptonote_protocol_handler.inl
@@ -2064,8 +2064,14 @@ skip:
// get rid of blocks we already requested, or already have
if (skip_unneeded_hashes(context, true) && context.m_needed_objects.empty() && context.m_num_requested == 0)
{
- MERROR(context << "Nothing we can request from this peer, and we did not request anything previously");
- return false;
+ if (context.m_remote_blockchain_height > m_block_queue.get_next_needed_height(bc_height))
+ {
+ MERROR(context << "Nothing we can request from this peer, and we did not request anything previously");
+ return false;
+ }
+ MDEBUG(context << "Nothing to get from this peer, and it's not ahead of us, all done");
+ context.m_state = cryptonote_connection_context::state_normal;
+ return true;
}
uint64_t next_needed_height = m_block_queue.get_next_needed_height(bc_height);
uint64_t next_block_height;
@@ -2204,8 +2210,14 @@ skip:
}
if (skip_unneeded_hashes(context, false) && context.m_needed_objects.empty() && context.m_num_requested == 0)
{
- MERROR(context << "Nothing we can request from this peer, and we did not request anything previously");
- return false;
+ if (context.m_remote_blockchain_height > m_block_queue.get_next_needed_height(m_core.get_current_blockchain_height()))
+ {
+ MERROR(context << "Nothing we can request from this peer, and we did not request anything previously");
+ return false;
+ }
+ MDEBUG(context << "Nothing to get from this peer, and it's not ahead of us, all done");
+ context.m_state = cryptonote_connection_context::state_normal;
+ return true;
}
const uint64_t first_block_height = context.m_last_response_height - context.m_needed_objects.size() + 1;
@@ -2309,30 +2321,16 @@ skip:
return true;
}
- // if we're still around, we might be at a point where the peer is pruned, so we could either
- // drop it to make space for other peers, or ask for a span further down the line
- const uint32_t next_stripe = get_next_needed_pruning_stripe().first;
- const uint32_t peer_stripe = tools::get_pruning_stripe(context.m_pruning_seed);
- const uint32_t local_stripe = tools::get_pruning_stripe(m_core.get_blockchain_pruning_seed());
- if (!(m_sync_pruned_blocks && peer_stripe == local_stripe) && next_stripe && peer_stripe && next_stripe != peer_stripe)
+ // we can do nothing, so drop this peer to make room for others unless we think we've downloaded all we need
+ const uint64_t blockchain_height = m_core.get_current_blockchain_height();
+ if (std::max(blockchain_height, m_block_queue.get_next_needed_height(blockchain_height)) >= m_core.get_target_blockchain_height())
{
- // at this point, we have to either close the connection, or start getting blocks past the
- // current point, or become dormant
- MDEBUG(context << "this peer is pruned at seed " << epee::string_tools::to_string_hex(context.m_pruning_seed) <<
- ", next stripe needed is " << next_stripe);
- if (!context.m_is_income)
- {
- if (should_drop_connection(context, next_stripe))
- {
- m_p2p->add_used_stripe_peer(context);
- return false; // drop outgoing connections
- }
- }
- // we'll get back stuck waiting for the go ahead
context.m_state = cryptonote_connection_context::state_normal;
MLOG_PEER_STATE("Nothing to do for now, switching to normal state");
return true;
}
+ MLOG_PEER_STATE("We can download nothing from this peer, dropping");
+ return false;
}
skip: