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:
18
examples/nodejs_client/package-lock.json
generated
18
examples/nodejs_client/package-lock.json
generated
@@ -5,17 +5,17 @@
|
||||
"async-limiter": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
|
||||
"integrity": "sha1-3TeelPDbgxCwgpH51kwyCXZmF/0="
|
||||
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
|
||||
},
|
||||
"base64-js": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
|
||||
"integrity": "sha1-WOzoy3XdB+ce0IxzarxfrE2/jfE="
|
||||
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
|
||||
},
|
||||
"bson": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/bson/-/bson-4.0.4.tgz",
|
||||
"integrity": "sha1-S9os7fKuehjRXLJO4e3ox5f47s8=",
|
||||
"integrity": "sha512-Ioi3TD0/1V3aI8+hPfC56TetYmzfq2H07jJa9A1lKTxWsFtHtYdLMGMXjtGEg9v0f72NSM07diRQEUNYhLupIA==",
|
||||
"requires": {
|
||||
"buffer": "^5.1.0",
|
||||
"long": "^4.0.0"
|
||||
@@ -24,7 +24,7 @@
|
||||
"buffer": {
|
||||
"version": "5.6.0",
|
||||
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz",
|
||||
"integrity": "sha1-oxdJ3H2B2E2wir+Te2uMQDP2J4Y=",
|
||||
"integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==",
|
||||
"requires": {
|
||||
"base64-js": "^1.0.2",
|
||||
"ieee754": "^1.1.4"
|
||||
@@ -41,7 +41,7 @@
|
||||
"ieee754": {
|
||||
"version": "1.1.13",
|
||||
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz",
|
||||
"integrity": "sha1-7BaFWOlaoYH9h9N/VcMrvLZwi4Q="
|
||||
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
|
||||
},
|
||||
"isomorphic-ws": {
|
||||
"version": "4.0.1",
|
||||
@@ -51,12 +51,12 @@
|
||||
"libsodium": {
|
||||
"version": "0.7.6",
|
||||
"resolved": "https://registry.npmjs.org/libsodium/-/libsodium-0.7.6.tgz",
|
||||
"integrity": "sha1-AYuAxXKAVIF4Rfv/pVQnREG9onc="
|
||||
"integrity": "sha512-hPb/04sEuLcTRdWDtd+xH3RXBihpmbPCsKW/Jtf4PsvdyKh+D6z2D2gvp/5BfoxseP+0FCOg66kE+0oGUE/loQ=="
|
||||
},
|
||||
"libsodium-wrappers": {
|
||||
"version": "0.7.6",
|
||||
"resolved": "https://registry.npmjs.org/libsodium-wrappers/-/libsodium-wrappers-0.7.6.tgz",
|
||||
"integrity": "sha1-uu1MFtS/lhAQSHWtio4WTSWdSPs=",
|
||||
"integrity": "sha512-OUO2CWW5bHdLr6hkKLHIKI4raEkZrf3QHkhXsJ1yCh6MZ3JDA7jFD3kCATNquuGSG6MjjPHQIQms0y0gBDzjQg==",
|
||||
"requires": {
|
||||
"libsodium": "0.7.6"
|
||||
}
|
||||
@@ -64,7 +64,7 @@
|
||||
"long": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
|
||||
"integrity": "sha1-mntxz7fTYaGU6lVSQckvdGjVvyg="
|
||||
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA=="
|
||||
},
|
||||
"node-gyp-build": {
|
||||
"version": "3.7.0",
|
||||
@@ -82,7 +82,7 @@
|
||||
"ws": {
|
||||
"version": "7.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.1.2.tgz",
|
||||
"integrity": "sha1-xnLRYp3ouyepaZ61mb5Hru7dj3M=",
|
||||
"integrity": "sha512-gftXq3XI81cJCgkUiAVixA0raD9IVmXqsylCrjRygw4+UOOGzPoxnQ6r/CnVL9i+mDncJo94tSkyrtuuQVBmrg==",
|
||||
"requires": {
|
||||
"async-limiter": "^1.0.0"
|
||||
}
|
||||
|
||||
@@ -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