Skip to content

Commit

Permalink
move save epoch metadata to ending of recover func add comment
Browse files Browse the repository at this point in the history
  • Loading branch information
kc1116 committed Apr 26, 2024
1 parent 4c0dcf7 commit cbb2885
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions contracts/epochs/FlowEpoch.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -599,22 +599,6 @@ access(all) contract FlowEpoch {
FlowEpoch.borrowDKGAdmin().forceEndDKG()
}

/// Create new Epoch metadata for the next epoch
/// with the new values
let newEpochMetadata = EpochMetadata(
//
counter: FlowEpoch.proposedEpochCounter(),
seed: randomSource,
startView: startView,
endView: endView,
stakingEndView: stakingEndView,
// This will be overwritten in `calculateAndSetRewards` below
totalRewards: UFix64(0.0),
collectorClusters: [],
clusterQCs: [],
dkgKeys: dkgPubKeys)

FlowEpoch.saveEpochMetadata(newEpochMetadata)
// Calculate rewards for the current epoch
// and set the payout for the next epoch
FlowEpoch.calculateAndSetRewards()
Expand All @@ -640,6 +624,25 @@ access(all) contract FlowEpoch {
/// save the recovery epoch metadata this will be emitted in the EpochRecover service event
/// during the next heart beat interval.
FlowEpoch.account.storage.save(recoverEpochMetadata, to: /storage/recoverEpochMetadataStoragePath)

/// Create new metadata for the recovery epoch with the new values
let newEpochMetadata = EpochMetadata(
/// When the network enters EFM the epoch counter will not be incremented
/// so it's safe to use current_epoch_counter + 1
counter: FlowEpoch.proposedEpochCounter(),
seed: randomSource,
startView: startView,
endView: endView,
stakingEndView: stakingEndView,
// This will be overwritten in `calculateAndSetRewards` below
totalRewards: UFix64(0.0),
collectorClusters: [],
clusterQCs: [],
dkgKeys: dkgPubKeys)

/// Save the new epoch meta data, it will be referenced as
/// the epoch progresses through each phase.
FlowEpoch.saveEpochMetadata(newEpochMetadata)
}

/// Ends the currently active epoch and starts a new one with the provided configuration.
Expand Down

0 comments on commit cbb2885

Please sign in to comment.