mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Subject unl list to consensus. (#186)
* Unl hash in consensus proposals. * Unl syncing and sync request serving. * Adding unl hash to the ledger block.
This commit is contained in:
committed by
GitHub
parent
a87e8a0c7e
commit
7bf0475b6f
@@ -13,6 +13,7 @@
|
||||
#include "../ledger.hpp"
|
||||
#include "peer_comm_session.hpp"
|
||||
#include "p2p.hpp"
|
||||
#include "../unl.hpp"
|
||||
|
||||
namespace p2pmsg = msg::fbuf::p2pmsg;
|
||||
|
||||
@@ -256,6 +257,41 @@ namespace p2p
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (content_message_type == p2pmsg::Message_Unl_Request_Message) //message is a unl request message.
|
||||
{
|
||||
// Check the cap and insert request with lock.
|
||||
std::scoped_lock<std::mutex> lock(unl::sync_ctx.list_mutex);
|
||||
|
||||
// If max number of unl requests reached skip the rest.
|
||||
if (unl::sync_ctx.collected_unl_sync_requests.size() < unl::UNL_REQ_LIST_CAP)
|
||||
{
|
||||
const p2p::unl_sync_request unl_request = p2pmsg::create_unl_sync_request_from_msg(*content->message_as_Unl_Request_Message());
|
||||
unl::sync_ctx.collected_unl_sync_requests.push_back(std::make_pair(session.pubkey, std::move(unl_request)));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG << "Unl request rejected. Maximum unl request count reached. " << session.display_name();
|
||||
}
|
||||
}
|
||||
else if (content_message_type == p2pmsg::Message_Unl_Response_Message) //message is a unl response message.
|
||||
{
|
||||
if (unl::sync_ctx.is_syncing) // Only accept history responses if ledger is syncing.
|
||||
{
|
||||
// Check the cap and insert response with lock.
|
||||
std::scoped_lock<std::mutex> lock(unl::sync_ctx.list_mutex);
|
||||
|
||||
// If max number of unl responses reached skip the rest.
|
||||
if (unl::sync_ctx.collected_unl_sync_responses.size() < unl::UNL_RES_LIST_CAP)
|
||||
{
|
||||
const p2p::unl_sync_response unl_response = p2pmsg::create_unl_sync_response_from_msg(*content->message_as_Unl_Response_Message());
|
||||
unl::sync_ctx.collected_unl_sync_responses.push_back(std::move(unl_response));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_DEBUG << "Unl response rejected. Maximum unl response count reached. " << session.display_name();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
session.increment_metric(comm::SESSION_THRESHOLDS::MAX_BADMSGS_PER_MINUTE, 1);
|
||||
|
||||
Reference in New Issue
Block a user