Skip to content

Commit

Permalink
add timing config struct
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanschalm committed Nov 10, 2023
1 parent 54f4552 commit 25a0f98
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions contracts/epochs/FlowEpoch.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ pub contract FlowEpoch {
/// than the given deadline, it can safely transition to the next phase.
DKGPhase1FinalView: UInt64,
DKGPhase2FinalView: UInt64,
DKGPhase3FinalView: UInt64
DKGPhase3FinalView: UInt64,

/// The target end time for the upcoming epoch, specified in second-precision Unix time
targetEndTime: Int64
)

/// The EpochCommit service event is emitted when we transition from the Epoch
Expand Down Expand Up @@ -226,7 +229,7 @@ pub contract FlowEpoch {
}
}

/// Metadata that is managed and can be changed by the Admin///
/// Metadata that is managed and can be changed by the Admin
pub struct Config {
/// The number of views in an entire epoch
pub(set) var numViewsInEpoch: UInt64
Expand All @@ -253,6 +256,29 @@ pub contract FlowEpoch {
}
}

/// Configuration for epoch timing.
/// Each epoch is assigned a target end time when it is setup (within the EpochSetup event).
/// The configuration defines a reference epoch counter and timestamp, which defines
/// all future target end times. If `targetEpochCounter` is an upcoming epoch, then
/// its target end time is given by:
///
/// targetEndTime = refTimestamp + duration * (targetEpochCounter-refCounter)
///
pub struct EpochTimingConfig {
/// The duration of each epoch, in seconds
pub(set) duration: UInt64
/// The counter of the reference epoch
pub(set) refCounter: UInt64
/// The end time of the reference epoch, specified in second-precision Unix time
pub(set) refTimestamp: Int64

init(duration: UInt64, refCounter: UInt64, refTimestamp: Int64) {
self.duration = duration
self.refCounter = refCounter
self.refTimestamp = refTimestamp
}
}

/// Holds the `FlowEpoch.Config` struct with the configurable metadata
access(contract) let configurableMetadata: Config

Expand Down

0 comments on commit 25a0f98

Please sign in to comment.