Skip to content

Commit

Permalink
fix(epochs): handle old epochs (#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler authored Dec 20, 2024
2 parents 19f19e8 + 0605c24 commit 73eb542
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1926,7 +1926,18 @@ addEventingHandler(
function(msg)
local epochIndex = msg.Tags["Epoch-Index"] and tonumber(msg.Tags["Epoch-Index"])
or epochs.getEpochIndexForTimestamp(msg.Timestamp)
local prescribedObserversWithWeights = epochs.getPrescribedObserversWithWeightsForEpoch(epochIndex)
local epoch = epochs.getEpoch(epochIndex)
local prescribedObserversWithWeights
-- TODO: this is to support old epochs that have full array of prescribedObservers, we can remove after the new epochs are created
if
epoch.prescribedObservers
and epoch.prescribedObservers[1]
and epoch.prescribedObservers[1].gatewayAddress
then
prescribedObserversWithWeights = epoch.prescribedObservers
else
prescribedObserversWithWeights = epochs.getPrescribedObserversWithWeightsForEpoch(epochIndex)
end
Send(msg, {
Target = msg.From,
Action = "Prescribed-Observers-Notice",
Expand Down

0 comments on commit 73eb542

Please sign in to comment.