mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Change epoch milliseconds return type to uint64_t. (#155)
This commit is contained in:
@@ -279,10 +279,10 @@ namespace conf
|
||||
cfg.unl.emplace(bin_pubkey);
|
||||
}
|
||||
|
||||
cfg.peerport = d["peerport"].as<int>();
|
||||
cfg.pubport = d["pubport"].as<int>();
|
||||
cfg.roundtime = d["roundtime"].as<int>();
|
||||
cfg.peerdiscoverytime = d["peerdiscoverytime"].as<int>();
|
||||
cfg.peerport = d["peerport"].as<uint16_t>();
|
||||
cfg.pubport = d["pubport"].as<uint16_t>();
|
||||
cfg.roundtime = d["roundtime"].as<uint16_t>();
|
||||
cfg.peerdiscoverytime = d["peerdiscoverytime"].as<uint16_t>();
|
||||
|
||||
cfg.pubmaxsize = d["pubmaxsize"].as<uint64_t>();
|
||||
cfg.pubmaxcpm = d["pubmaxcpm"].as<uint64_t>();
|
||||
|
||||
@@ -290,7 +290,7 @@ namespace consensus
|
||||
// Stage 1 must start in the next round window.
|
||||
// (This makes sure stage 3 gets whichever the remaining time in the round after stage 1 and 2)
|
||||
stage_start = current_round_start + conf::cfg.roundtime;
|
||||
const int64_t to_wait = stage_start - now;
|
||||
const uint64_t to_wait = stage_start - now;
|
||||
|
||||
LOG_DEBUG << "Waiting " << std::to_string(to_wait) << "ms for next round stage 1";
|
||||
util::sleep(to_wait);
|
||||
@@ -302,7 +302,7 @@ namespace consensus
|
||||
|
||||
// Compute stage time wait.
|
||||
// Node wait between stages to collect enough proposals from previous stages from other nodes.
|
||||
const int64_t to_wait = stage_start - now;
|
||||
const uint64_t to_wait = stage_start - now;
|
||||
|
||||
// If a node doesn't have enough time (eg. due to network delay) to recieve/send reliable stage proposals for next stage,
|
||||
// it will join in next round. Otherwise it will continue particapating in this round.
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace msg::fbuf::p2pmsg
|
||||
//check message timestamp (ignore this for large messages).
|
||||
if (container_buf_size <= MAX_SIZE_FOR_TIME_CHECK)
|
||||
{
|
||||
const int64_t time_now = util::get_epoch_milliseconds();
|
||||
const uint64_t time_now = util::get_epoch_milliseconds();
|
||||
if (container->timestamp() < (time_now - conf::cfg.roundtime * 4))
|
||||
{
|
||||
LOG_DEBUG << "Peer message is too old.";
|
||||
|
||||
@@ -197,7 +197,7 @@ namespace p2p
|
||||
return false;
|
||||
}
|
||||
|
||||
const int64_t time_now = util::get_epoch_milliseconds();
|
||||
const uint64_t time_now = util::get_epoch_milliseconds();
|
||||
// Checking the time to live of the container. The time to live for forwarding is three times the round time.
|
||||
if (container->timestamp() < (time_now - (conf::cfg.roundtime * 3)))
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace sc
|
||||
{
|
||||
const int MAX_SEQ_PACKET_SIZE = 128 * 1024;
|
||||
const uint32_t MAX_SEQ_PACKET_SIZE = 128 * 1024;
|
||||
bool init_success = false;
|
||||
|
||||
// We maintain two hpfs global processes for merging and rw sessions.
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace sc
|
||||
moodycamel::ReaderWriterQueue<std::string> control_messages;
|
||||
|
||||
// Current HotPocket consensus time.
|
||||
int64_t time = 0;
|
||||
uint64_t time = 0;
|
||||
|
||||
// Current HotPocket lcl (seq no. and ledger hash hex)
|
||||
std::string lcl;
|
||||
|
||||
15
src/util.cpp
15
src/util.cpp
@@ -134,18 +134,18 @@ namespace util
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns current time in UNIX epoch milliseconds.
|
||||
*/
|
||||
int64_t get_epoch_milliseconds()
|
||||
* Returns current time in UNIX epoch milliseconds.
|
||||
*/
|
||||
uint64_t get_epoch_milliseconds()
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
return std::chrono::duration_cast<std::chrono::duration<std::uint64_t, std::milli>>(
|
||||
std::chrono::system_clock::now().time_since_epoch())
|
||||
.count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sleeps the current thread for specified no. of milliseconds.
|
||||
*/
|
||||
* Sleeps the current thread for specified no. of milliseconds.
|
||||
*/
|
||||
void sleep(const uint64_t milliseconds)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
|
||||
@@ -423,13 +423,12 @@ namespace util
|
||||
{
|
||||
result = std::stoull(str);
|
||||
}
|
||||
catch(const std::exception& e)
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
// Return -1 if any exceptions are captured.
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
} // namespace util
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace util
|
||||
|
||||
std::string get_hex(std::string_view bin, const off_t skip = 0, const size_t take = 0);
|
||||
|
||||
int64_t get_epoch_milliseconds();
|
||||
uint64_t get_epoch_milliseconds();
|
||||
|
||||
void sleep(const uint64_t milliseconds);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user