mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Added roundtime offset based on contract id. (#238)
This commit is contained in:
@@ -34,6 +34,11 @@ namespace consensus
|
||||
ctx.stage_time = conf::cfg.contract.roundtime / 4;
|
||||
ctx.stage_reset_wait_threshold = conf::cfg.contract.roundtime / 10;
|
||||
|
||||
// We use a time window boundry offset based on contract id to vary the window boundries between
|
||||
// different contracts with same round time.
|
||||
std::hash<std::string> str_hasher;
|
||||
ctx.round_boundry_offset = str_hasher(conf::cfg.contract.id) % conf::cfg.contract.roundtime;
|
||||
|
||||
// Starting consensus processing thread.
|
||||
ctx.consensus_thread = std::thread(run_consensus);
|
||||
|
||||
@@ -306,7 +311,7 @@ namespace consensus
|
||||
if (ctx.stage == 0)
|
||||
{
|
||||
// This gets the start time of current round window. Stage 0 must start in the window after that.
|
||||
const uint64_t previous_round_start = (((uint64_t)(now / conf::cfg.contract.roundtime)) * conf::cfg.contract.roundtime);
|
||||
const uint64_t previous_round_start = (((uint64_t)((now - ctx.round_boundry_offset) / conf::cfg.contract.roundtime)) * conf::cfg.contract.roundtime) + ctx.round_boundry_offset;
|
||||
|
||||
// Stage 0 must start in the next round window.
|
||||
// (This makes sure stage 3 gets whichever the remaining time in the round after stages 0,1,2)
|
||||
|
||||
Reference in New Issue
Block a user