Skip to content

Commit

Permalink
check for block timestamp buffer size before pruning
Browse files Browse the repository at this point in the history
  • Loading branch information
yan-soon authored and yan-soon committed Jun 4, 2024
1 parent ea429b7 commit 3babce3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion oracle/reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func (oracleR *Reactor) broadcastVoteRoutine(peer p2p.Peer) {

// only gossip votes that are younger than the latestAllowableTimestamp, which is the max(earliest block timestamp collected, current time - maxOracleGossipAge)
latestAllowableTimestamp := time.Now().Unix() - int64(oracleR.OracleInfo.Config.MaxOracleGossipAge)
if len(oracleR.OracleInfo.BlockTimestamps) > 0 && oracleR.OracleInfo.BlockTimestamps[0] > latestAllowableTimestamp {
if len(oracleR.OracleInfo.BlockTimestamps) == oracleR.OracleInfo.Config.MaxOracleGossipBlocksDelayed && oracleR.OracleInfo.BlockTimestamps[0] > latestAllowableTimestamp {
latestAllowableTimestamp = oracleR.OracleInfo.BlockTimestamps[0]
}

Expand Down
2 changes: 1 addition & 1 deletion oracle/service/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func PruneVoteBuffers(oracleInfo *types.OracleInfo, consensusState *cs.State) {

latestAllowableTimestamp := time.Now().Unix() - int64(maxOracleGossipAge)
// prune votes that are older than the latestAllowableTimestamp, which is the max(earliest block timestamp collected, current time - maxOracleGossipAge)
if oracleInfo.BlockTimestamps[0] > latestAllowableTimestamp {
if len(oracleInfo.BlockTimestamps) == maxOracleGossipBlocksDelayed && oracleInfo.BlockTimestamps[0] > latestAllowableTimestamp {
latestAllowableTimestamp = oracleInfo.BlockTimestamps[0]
}

Expand Down

0 comments on commit 3babce3

Please sign in to comment.