mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Used uint32 for roundtime and timeout fields. (#248)
This commit is contained in:
@@ -9,8 +9,8 @@
|
||||
namespace comm
|
||||
{
|
||||
constexpr uint32_t INTERVALMS = 60000;
|
||||
constexpr uint16_t UNVERIFIED_INACTIVE_TIMEOUT = 5; // Time threshold for unverified inactive connections in seconds.
|
||||
constexpr uint16_t MAX_IN_MSG_QUEUE_SIZE = 64; // Maximum in message queue size, The size passed is rounded to next number in binary sequence 1(1),11(3),111(7),1111(15),11111(31)....
|
||||
constexpr uint32_t UNVERIFIED_INACTIVE_TIMEOUT = 5000; // Time threshold ms for unverified inactive connections.
|
||||
constexpr uint16_t MAX_IN_MSG_QUEUE_SIZE = 64; // Maximum in message queue size, The size passed is rounded to next number in binary sequence 1(1),11(3),111(7),1111(15),11111(31)....
|
||||
|
||||
comm_session::comm_session(
|
||||
std::string_view host_address, hpws::client &&hpws_client, const bool is_inbound, const uint64_t (&metric_thresholds)[5])
|
||||
@@ -302,13 +302,13 @@ namespace comm
|
||||
*/
|
||||
void comm_session::check_last_activity_rules()
|
||||
{
|
||||
const uint16_t timeout_seconds = (challenge_status == CHALLENGE_STATUS::CHALLENGE_VERIFIED ? thresholds[SESSION_THRESHOLDS::IDLE_CONNECTION_TIMEOUT].threshold_limit : UNVERIFIED_INACTIVE_TIMEOUT);
|
||||
const uint32_t timeout = (challenge_status == CHALLENGE_STATUS::CHALLENGE_VERIFIED ? thresholds[SESSION_THRESHOLDS::IDLE_CONNECTION_TIMEOUT].threshold_limit : UNVERIFIED_INACTIVE_TIMEOUT);
|
||||
|
||||
// Timeout zero means unlimited.
|
||||
if (timeout_seconds == 0)
|
||||
if (timeout == 0)
|
||||
return;
|
||||
|
||||
if (util::get_epoch_milliseconds() - last_activity_timestamp >= (timeout_seconds * 1000))
|
||||
if (util::get_epoch_milliseconds() - last_activity_timestamp >= timeout)
|
||||
{
|
||||
LOG_DEBUG << "Closing " << display_name() << " connection due to inactivity.";
|
||||
mark_for_closure();
|
||||
|
||||
10
src/conf.cpp
10
src/conf.cpp
@@ -149,7 +149,7 @@ namespace conf
|
||||
|
||||
cfg.mesh.port = 22860;
|
||||
cfg.mesh.msg_forwarding = true;
|
||||
cfg.mesh.idle_timeout = 120;
|
||||
cfg.mesh.idle_timeout = 120000;
|
||||
cfg.mesh.peer_discovery.enabled = true;
|
||||
cfg.mesh.peer_discovery.interval = 30000;
|
||||
|
||||
@@ -347,6 +347,7 @@ namespace conf
|
||||
const jsoncons::ojson &mesh = d["mesh"];
|
||||
cfg.mesh.port = mesh["port"].as<uint16_t>();
|
||||
cfg.mesh.listen = mesh["listen"].as<bool>();
|
||||
cfg.mesh.idle_timeout = mesh["idle_timeout"].as<uint32_t>();
|
||||
|
||||
// Storing peers in unordered map keyed by the concatenated address:port and also saving address and port
|
||||
// seperately to retrieve easily when handling peer connections.
|
||||
@@ -387,7 +388,6 @@ namespace conf
|
||||
cfg.mesh.max_bad_msgs_per_min = mesh["max_bad_msgs_per_min"].as<uint64_t>();
|
||||
cfg.mesh.max_bad_msgsigs_per_min = mesh["max_bad_msgsigs_per_min"].as<uint64_t>();
|
||||
cfg.mesh.max_dup_msgs_per_min = mesh["max_dup_msgs_per_min"].as<uint64_t>();
|
||||
cfg.mesh.idle_timeout = mesh["idle_timeout"].as<uint16_t>();
|
||||
|
||||
jpath = "mesh.peer_discovery";
|
||||
cfg.mesh.peer_discovery.interval = mesh["peer_discovery"]["interval"].as<uint16_t>();
|
||||
@@ -409,12 +409,12 @@ namespace conf
|
||||
const jsoncons::ojson &user = d["user"];
|
||||
cfg.user.port = user["port"].as<uint16_t>();
|
||||
cfg.user.listen = user["listen"].as<bool>();
|
||||
cfg.user.idle_timeout = user["idle_timeout"].as<uint32_t>();
|
||||
cfg.user.max_connections = user["max_connections"].as<uint64_t>();
|
||||
cfg.user.max_in_connections_per_host = user["max_in_connections_per_host"].as<uint64_t>();
|
||||
cfg.user.max_bytes_per_msg = user["max_bytes_per_msg"].as<uint64_t>();
|
||||
cfg.user.max_bytes_per_min = user["max_bytes_per_min"].as<uint64_t>();
|
||||
cfg.user.max_bad_msgs_per_min = user["max_bad_msgs_per_min"].as<uint64_t>();
|
||||
cfg.user.idle_timeout = user["idle_timeout"].as<uint16_t>();
|
||||
cfg.user.concurrent_read_reqeuests = user["concurrent_read_reqeuests"].as<uint64_t>();
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
@@ -498,6 +498,7 @@ namespace conf
|
||||
jsoncons::ojson mesh_config;
|
||||
mesh_config.insert_or_assign("port", cfg.mesh.port);
|
||||
mesh_config.insert_or_assign("listen", cfg.mesh.listen);
|
||||
mesh_config.insert_or_assign("idle_timeout", cfg.mesh.idle_timeout);
|
||||
|
||||
jsoncons::ojson peers(jsoncons::json_array_arg);
|
||||
for (const auto &peer : cfg.mesh.known_peers)
|
||||
@@ -515,7 +516,6 @@ namespace conf
|
||||
mesh_config.insert_or_assign("max_bad_msgs_per_min", cfg.mesh.max_bad_msgs_per_min);
|
||||
mesh_config.insert_or_assign("max_bad_msgsigs_per_min", cfg.mesh.max_bad_msgsigs_per_min);
|
||||
mesh_config.insert_or_assign("max_dup_msgs_per_min", cfg.mesh.max_dup_msgs_per_min);
|
||||
mesh_config.insert_or_assign("idle_timeout", cfg.mesh.idle_timeout);
|
||||
|
||||
jsoncons::ojson peer_discovery_config;
|
||||
peer_discovery_config.insert_or_assign("enabled", cfg.mesh.peer_discovery.enabled);
|
||||
@@ -938,7 +938,7 @@ namespace conf
|
||||
contract.bin_path = jdoc["bin_path"].as<std::string>();
|
||||
contract.bin_args = jdoc["bin_args"].as<std::string>();
|
||||
|
||||
contract.roundtime = jdoc["roundtime"].as<uint16_t>();
|
||||
contract.roundtime = jdoc["roundtime"].as<uint32_t>();
|
||||
if (contract.roundtime == 0)
|
||||
{
|
||||
std::cerr << "Round time cannot be zero.\n";
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace conf
|
||||
std::set<std::string> unl; // Unique node list (list of binary public keys)
|
||||
std::string bin_path; // Full path to the contract binary
|
||||
std::string bin_args; // CLI arguments to pass to the contract binary
|
||||
std::atomic<uint16_t> roundtime = 0; // Consensus round time in ms
|
||||
std::atomic<uint32_t> roundtime = 0; // Consensus round time in ms
|
||||
bool is_consensus_public = false; // If true, consensus are broadcasted to non-unl nodes as well.
|
||||
bool is_npl_public = false; // If true, npl messages are broadcasted to non-unl nodes as well.
|
||||
appbill_config appbill;
|
||||
@@ -118,7 +118,7 @@ namespace conf
|
||||
{
|
||||
uint16_t port = 0; // Listening port for public user connections
|
||||
bool listen = true; // Whether to listen for incoming user connections.
|
||||
uint16_t idle_timeout = 0; // Idle connection timeout for user connections in seconds.
|
||||
uint32_t idle_timeout = 0; // Idle connection timeout ms for user connections.
|
||||
uint64_t max_bytes_per_msg = 0; // User message max size in bytes
|
||||
uint64_t max_bytes_per_min = 0; // User message rate (characters(bytes) per minute)
|
||||
uint64_t max_bad_msgs_per_min = 0; // User bad messages per minute
|
||||
@@ -137,6 +137,7 @@ namespace conf
|
||||
{
|
||||
uint16_t port = 0; // Listening port for peer connections
|
||||
bool listen = true; // Whether to listen for incoming peer connections.
|
||||
uint32_t idle_timeout = 0; // Idle connection timeout ms for peer connections.
|
||||
std::vector<peer_properties> known_peers; // Vector of peers with ip_port, timestamp, capacity.
|
||||
bool msg_forwarding = false; // Whether peer message forwarding is on/off.
|
||||
uint16_t max_connections = 0; // Max peer connections.
|
||||
@@ -147,7 +148,6 @@ namespace conf
|
||||
uint64_t max_bad_msgs_per_min = 0; // Peer bad messages per minute.
|
||||
uint64_t max_bad_msgsigs_per_min = 0; // Peer bad signatures per minute.
|
||||
uint64_t max_dup_msgs_per_min = 0; // Peer max duplicate messages per minute.
|
||||
uint16_t idle_timeout = 0; // Idle connection timeout for peer connections in seconds.
|
||||
peer_discovery_config peer_discovery; // Peer discovery configs.
|
||||
};
|
||||
|
||||
|
||||
@@ -1070,7 +1070,7 @@ namespace consensus
|
||||
if (perform_detection)
|
||||
{
|
||||
LOG_DEBUG << "Detecting roundtime...";
|
||||
const uint16_t majority_roundtime = unl::get_majority_roundtime();
|
||||
const uint32_t majority_roundtime = unl::get_majority_roundtime();
|
||||
|
||||
if (majority_roundtime == 0 || conf::cfg.contract.roundtime == majority_roundtime)
|
||||
return;
|
||||
|
||||
@@ -69,8 +69,8 @@ namespace consensus
|
||||
|
||||
uint8_t stage = 1;
|
||||
uint64_t round_start_time = 0;
|
||||
uint16_t stage_time = 0; // Time allocated to a consensus stage.
|
||||
uint16_t stage_reset_wait_threshold = 0; // Minimum stage wait time to reset the stage.
|
||||
uint32_t stage_time = 0; // Time allocated to a consensus stage.
|
||||
uint32_t stage_reset_wait_threshold = 0; // Minimum stage wait time to reset the stage.
|
||||
uint64_t round_boundry_offset = 0; // Time window boundry offset based on contract id.
|
||||
uint16_t unreliable_votes_attempts = 0; // No. of times we failed to get reliable votes continously.
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace hpfs
|
||||
}
|
||||
};
|
||||
|
||||
inline uint16_t get_request_resubmit_timeout()
|
||||
inline uint32_t get_request_resubmit_timeout()
|
||||
{
|
||||
return conf::cfg.contract.roundtime;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace hpfs
|
||||
prev_requests_processed = !hpfs_requests.empty();
|
||||
const uint64_t time_start = util::get_epoch_milliseconds();
|
||||
const std::string lcl = ledger::ctx.get_lcl();
|
||||
const uint16_t request_batch_timeout = hpfs::get_request_resubmit_timeout() * 0.9;
|
||||
const uint32_t request_batch_timeout = hpfs::get_request_resubmit_timeout() * 0.9;
|
||||
|
||||
if (hpfs_requests.empty())
|
||||
continue;
|
||||
|
||||
@@ -287,7 +287,7 @@ namespace hpfs
|
||||
candidate_hpfs_responses.clear();
|
||||
|
||||
// No. of milliseconds to wait before resubmitting a request.
|
||||
const uint16_t request_resubmit_timeout = hpfs::get_request_resubmit_timeout();
|
||||
const uint32_t request_resubmit_timeout = hpfs::get_request_resubmit_timeout();
|
||||
|
||||
// Check for long-awaited responses and re-request them.
|
||||
for (auto &[hash, request] : submitted_requests)
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace hpfs
|
||||
|
||||
// No. of millisconds that this item has been waiting in pending state.
|
||||
// Used by pending_responses list to increase waiting time and resubmit request.
|
||||
uint16_t waiting_time = 0;
|
||||
uint32_t waiting_time = 0;
|
||||
};
|
||||
|
||||
struct sync_target
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace msg.fbuf.p2pmsg;
|
||||
|
||||
table Peer_Challenge_Message {
|
||||
contract_id:string;
|
||||
roundtime:uint16;
|
||||
roundtime:uint32;
|
||||
challenge:string;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ table NonUnl_Proposal_Message {
|
||||
table Proposal_Message { //Proposal type message schema
|
||||
stage:uint8;
|
||||
time:uint64;
|
||||
roundtime:uint16;
|
||||
roundtime:uint32;
|
||||
nonce: [ubyte];
|
||||
users:[ByteArray];
|
||||
input_hashes:[ByteArray];
|
||||
|
||||
@@ -307,11 +307,11 @@ struct Peer_Challenge_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Tab
|
||||
flatbuffers::String *mutable_contract_id() {
|
||||
return GetPointer<flatbuffers::String *>(VT_CONTRACT_ID);
|
||||
}
|
||||
uint16_t roundtime() const {
|
||||
return GetField<uint16_t>(VT_ROUNDTIME, 0);
|
||||
uint32_t roundtime() const {
|
||||
return GetField<uint32_t>(VT_ROUNDTIME, 0);
|
||||
}
|
||||
bool mutate_roundtime(uint16_t _roundtime) {
|
||||
return SetField<uint16_t>(VT_ROUNDTIME, _roundtime, 0);
|
||||
bool mutate_roundtime(uint32_t _roundtime) {
|
||||
return SetField<uint32_t>(VT_ROUNDTIME, _roundtime, 0);
|
||||
}
|
||||
const flatbuffers::String *challenge() const {
|
||||
return GetPointer<const flatbuffers::String *>(VT_CHALLENGE);
|
||||
@@ -323,7 +323,7 @@ struct Peer_Challenge_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Tab
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyOffset(verifier, VT_CONTRACT_ID) &&
|
||||
verifier.VerifyString(contract_id()) &&
|
||||
VerifyField<uint16_t>(verifier, VT_ROUNDTIME) &&
|
||||
VerifyField<uint32_t>(verifier, VT_ROUNDTIME) &&
|
||||
VerifyOffset(verifier, VT_CHALLENGE) &&
|
||||
verifier.VerifyString(challenge()) &&
|
||||
verifier.EndTable();
|
||||
@@ -337,8 +337,8 @@ struct Peer_Challenge_MessageBuilder {
|
||||
void add_contract_id(flatbuffers::Offset<flatbuffers::String> contract_id) {
|
||||
fbb_.AddOffset(Peer_Challenge_Message::VT_CONTRACT_ID, contract_id);
|
||||
}
|
||||
void add_roundtime(uint16_t roundtime) {
|
||||
fbb_.AddElement<uint16_t>(Peer_Challenge_Message::VT_ROUNDTIME, roundtime, 0);
|
||||
void add_roundtime(uint32_t roundtime) {
|
||||
fbb_.AddElement<uint32_t>(Peer_Challenge_Message::VT_ROUNDTIME, roundtime, 0);
|
||||
}
|
||||
void add_challenge(flatbuffers::Offset<flatbuffers::String> challenge) {
|
||||
fbb_.AddOffset(Peer_Challenge_Message::VT_CHALLENGE, challenge);
|
||||
@@ -358,19 +358,19 @@ struct Peer_Challenge_MessageBuilder {
|
||||
inline flatbuffers::Offset<Peer_Challenge_Message> CreatePeer_Challenge_Message(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
flatbuffers::Offset<flatbuffers::String> contract_id = 0,
|
||||
uint16_t roundtime = 0,
|
||||
uint32_t roundtime = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> challenge = 0) {
|
||||
Peer_Challenge_MessageBuilder builder_(_fbb);
|
||||
builder_.add_challenge(challenge);
|
||||
builder_.add_contract_id(contract_id);
|
||||
builder_.add_roundtime(roundtime);
|
||||
builder_.add_contract_id(contract_id);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
inline flatbuffers::Offset<Peer_Challenge_Message> CreatePeer_Challenge_MessageDirect(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
const char *contract_id = nullptr,
|
||||
uint16_t roundtime = 0,
|
||||
uint32_t roundtime = 0,
|
||||
const char *challenge = nullptr) {
|
||||
auto contract_id__ = contract_id ? _fbb.CreateString(contract_id) : 0;
|
||||
auto challenge__ = challenge ? _fbb.CreateString(challenge) : 0;
|
||||
@@ -843,11 +843,11 @@ struct Proposal_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
bool mutate_time(uint64_t _time) {
|
||||
return SetField<uint64_t>(VT_TIME, _time, 0);
|
||||
}
|
||||
uint16_t roundtime() const {
|
||||
return GetField<uint16_t>(VT_ROUNDTIME, 0);
|
||||
uint32_t roundtime() const {
|
||||
return GetField<uint32_t>(VT_ROUNDTIME, 0);
|
||||
}
|
||||
bool mutate_roundtime(uint16_t _roundtime) {
|
||||
return SetField<uint16_t>(VT_ROUNDTIME, _roundtime, 0);
|
||||
bool mutate_roundtime(uint32_t _roundtime) {
|
||||
return SetField<uint32_t>(VT_ROUNDTIME, _roundtime, 0);
|
||||
}
|
||||
const flatbuffers::Vector<uint8_t> *nonce() const {
|
||||
return GetPointer<const flatbuffers::Vector<uint8_t> *>(VT_NONCE);
|
||||
@@ -895,7 +895,7 @@ struct Proposal_Message FLATBUFFERS_FINAL_CLASS : private flatbuffers::Table {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<uint8_t>(verifier, VT_STAGE) &&
|
||||
VerifyField<uint64_t>(verifier, VT_TIME) &&
|
||||
VerifyField<uint16_t>(verifier, VT_ROUNDTIME) &&
|
||||
VerifyField<uint32_t>(verifier, VT_ROUNDTIME) &&
|
||||
VerifyOffset(verifier, VT_NONCE) &&
|
||||
verifier.VerifyVector(nonce()) &&
|
||||
VerifyOffset(verifier, VT_USERS) &&
|
||||
@@ -926,8 +926,8 @@ struct Proposal_MessageBuilder {
|
||||
void add_time(uint64_t time) {
|
||||
fbb_.AddElement<uint64_t>(Proposal_Message::VT_TIME, time, 0);
|
||||
}
|
||||
void add_roundtime(uint16_t roundtime) {
|
||||
fbb_.AddElement<uint16_t>(Proposal_Message::VT_ROUNDTIME, roundtime, 0);
|
||||
void add_roundtime(uint32_t roundtime) {
|
||||
fbb_.AddElement<uint32_t>(Proposal_Message::VT_ROUNDTIME, roundtime, 0);
|
||||
}
|
||||
void add_nonce(flatbuffers::Offset<flatbuffers::Vector<uint8_t>> nonce) {
|
||||
fbb_.AddOffset(Proposal_Message::VT_NONCE, nonce);
|
||||
@@ -966,7 +966,7 @@ inline flatbuffers::Offset<Proposal_Message> CreateProposal_Message(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
uint8_t stage = 0,
|
||||
uint64_t time = 0,
|
||||
uint16_t roundtime = 0,
|
||||
uint32_t roundtime = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint8_t>> nonce = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<msg::fbuf::ByteArray>>> users = 0,
|
||||
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<msg::fbuf::ByteArray>>> input_hashes = 0,
|
||||
@@ -992,7 +992,7 @@ inline flatbuffers::Offset<Proposal_Message> CreateProposal_MessageDirect(
|
||||
flatbuffers::FlatBufferBuilder &_fbb,
|
||||
uint8_t stage = 0,
|
||||
uint64_t time = 0,
|
||||
uint16_t roundtime = 0,
|
||||
uint32_t roundtime = 0,
|
||||
const std::vector<uint8_t> *nonce = nullptr,
|
||||
const std::vector<flatbuffers::Offset<msg::fbuf::ByteArray>> *users = nullptr,
|
||||
const std::vector<flatbuffers::Offset<msg::fbuf::ByteArray>> *input_hashes = nullptr,
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace p2p
|
||||
uint64_t recv_timestamp = 0; // The timestamp when we received the proposal. (used for network statistics)
|
||||
uint64_t time = 0; // The descreet concensus time value that is voted on.
|
||||
uint8_t stage = 0; // The round-stage that this proposal belongs to.
|
||||
uint16_t roundtime = 0; // Roundtime of the proposer.
|
||||
uint32_t roundtime = 0; // Roundtime of the proposer.
|
||||
std::string nonce; // Random nonce that is used to reduce lcl predictability.
|
||||
std::string lcl;
|
||||
util::h32 state_hash; // Contract state hash.
|
||||
@@ -57,7 +57,7 @@ namespace p2p
|
||||
struct peer_challenge
|
||||
{
|
||||
std::string contract_id;
|
||||
uint16_t roundtime = 0;
|
||||
uint32_t roundtime = 0;
|
||||
std::string challenge;
|
||||
};
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace p2p
|
||||
std::optional<conf::peer_ip_port> known_ipport; // A known ip/port information that matches with our peer list configuration.
|
||||
bool need_consensus_msg_forwarding = false; // Holds whether this node requires consensus message forwarding.
|
||||
bool is_unl = false; // Whether this session's pubkey is in unl list.
|
||||
uint16_t reported_roundtime = 0; // Initial roundtime reported by this peer on peer challenge.
|
||||
uint32_t reported_roundtime = 0; // Initial roundtime reported by this peer on peer challenge.
|
||||
};
|
||||
|
||||
} // namespace p2p
|
||||
|
||||
10
src/unl.cpp
10
src/unl.cpp
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
namespace unl
|
||||
{
|
||||
std::map<std::string, uint16_t> list; // List of binary pubkeys of UNL and their latest reported roundtime.
|
||||
std::map<std::string, uint32_t> list; // List of binary pubkeys of UNL and their latest reported roundtime.
|
||||
std::string json_list; // Stringified json array of UNL. (To be fed into the contract args)
|
||||
std::shared_mutex unl_mutex;
|
||||
|
||||
@@ -98,13 +98,13 @@ namespace unl
|
||||
/**
|
||||
* Returns the majority roundtime reported among the unl.
|
||||
*/
|
||||
uint16_t get_majority_roundtime()
|
||||
uint32_t get_majority_roundtime()
|
||||
{
|
||||
std::unique_lock lock(unl_mutex);
|
||||
|
||||
// Vote and find majority roundtime within the unl.
|
||||
// Fill any 0 roundtimes with information from peer connections.
|
||||
std::map<uint16_t, uint32_t> roundtime_votes;
|
||||
std::map<uint32_t, uint32_t> roundtime_votes;
|
||||
|
||||
{
|
||||
std::scoped_lock<std::mutex> lock(p2p::ctx.peer_connections_mutex);
|
||||
@@ -119,7 +119,7 @@ namespace unl
|
||||
itr->second = peer_itr->second->reported_roundtime;
|
||||
}
|
||||
|
||||
const uint16_t roundtime = itr->second;
|
||||
const uint32_t roundtime = itr->second;
|
||||
if (roundtime > 0)
|
||||
roundtime_votes[roundtime]++;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ namespace unl
|
||||
|
||||
// Find the majority vote.
|
||||
uint32_t highest_votes = 0;
|
||||
uint16_t majority_roundtime = 0;
|
||||
uint32_t majority_roundtime = 0;
|
||||
for (const auto [roundtime, num_votes] : roundtime_votes)
|
||||
{
|
||||
if (num_votes > highest_votes)
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace unl
|
||||
int init();
|
||||
void update_unl_changes_from_patch();
|
||||
void update_roundtime_stats(const std::list<p2p::proposal> &proposals);
|
||||
uint16_t get_majority_roundtime();
|
||||
uint32_t get_majority_roundtime();
|
||||
bool update_unl_list(const std::set<std::string> &new_list);
|
||||
const std::string prepare_json_list(const std::set<std::string> &new_list);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Runs the specified contract directory with hpcore docker image.
|
||||
# This script assumes you already have the hpcore docker image and 'hpnet' virtual docker network.
|
||||
# Usage: ./rundir.sh 1
|
||||
# Usage: ./rundir.sh <dir path>
|
||||
|
||||
# Validate the node count arg.
|
||||
if [ -z "$1" ]; then
|
||||
|
||||
Reference in New Issue
Block a user