Skip to content

Commit ee58911

Browse files
committed
Fix overlapping datapoint submits with epoch change
1 parent 323e4b9 commit ee58911

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

core/src/state.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,12 @@ pub fn process(
3434
if let Some(local_datapoint_box_state) = live_epoch.local_datapoint_box_state {
3535
match local_datapoint_box_state {
3636
Collected { height: _ } => {
37-
// publish datapoint after some blocks have passed after the pool box published
38-
// to avoid some oracle box become stale on the next refresh
39-
// (datapoint posted on the first block of the epoch go out of the epoch window too fast)
40-
if current_height.0
41-
> live_epoch.latest_pool_box_height.0 + (epoch_length.0 as u32) / 2
37+
// publish datapoint in the second part of the epoch
38+
// to avoid some oracle boxes becoming stale on next refresh
39+
// (datapoint posted on the first block of the epoch goes out of the epoch window too fast)
40+
if (current_height.0 - live_epoch.latest_pool_box_height.0)
41+
% epoch_length.0 as u32
42+
> (epoch_length.0 as u32) / 2
4243
{
4344
Some(PoolCommand::PublishSubsequentDataPoint { republish: false })
4445
} else {

0 commit comments

Comments
 (0)