Skip to content

Commit

Permalink
chore: remove unneeded diffs
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior committed Feb 27, 2023
1 parent a038c62 commit 65fa6d0
Showing 1 changed file with 8 additions and 26 deletions.
34 changes: 8 additions & 26 deletions lib/babe/epoch_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,14 @@ type epochHandler struct {
handleSlot handleSlotFunc
}

// preRuntimeDigestMap maps the slot number to its respective pre runtime digest
type preRuntimeDigestMap map[uint64]*types.PreRuntimeDigest

// determine which slots we'll be authoring in by pre-calculating VRF output
func determineAuthoringSlotsInEpoch(epochNumber, startSlot, epochLength uint64,
epochData *epochData, keypair *sr25519.Keypair) (preRuntimeDigestMap, error) {

preRuntimeDigestMap := make(preRuntimeDigestMap, epochLength)
finalSlot := startSlot + epochLength

for slotNumber := startSlot; slotNumber < finalSlot; slotNumber++ {
preRuntimeDigest, err := claimSlot(epochNumber, slotNumber, epochData, keypair)
func newEpochHandler(epochNumber, firstSlot uint64, epochData *epochData, constants constants,
handleSlot handleSlotFunc, keypair *sr25519.Keypair) (*epochHandler, error) {
// determine which slots we'll be authoring in by pre-calculating VRF output
slotToPreRuntimeDigest := make(map[uint64]*types.PreRuntimeDigest, constants.epochLength)
for i := firstSlot; i < firstSlot+constants.epochLength; i++ {
preRuntimeDigest, err := claimSlot(epochNumber, i, epochData, keypair)
if err == nil {
preRuntimeDigestMap[slotNumber] = preRuntimeDigest
slotToPreRuntimeDigest[i] = preRuntimeDigest
continue
}

Expand All @@ -56,26 +50,14 @@ func determineAuthoringSlotsInEpoch(epochNumber, startSlot, epochLength uint64,
return nil, fmt.Errorf("failed to create new epoch handler: %w", err)
}

return preRuntimeDigestMap, nil
}

func newEpochHandler(epochNumber, firstSlot uint64, epochData *epochData, constants constants,
handleSlot handleSlotFunc, keypair *sr25519.Keypair) (*epochHandler, error) {

preRuntimeDigestMap, err := determineAuthoringSlotsInEpoch(epochNumber, firstSlot,
constants.epochLength, epochData, keypair)
if err != nil {
return nil, fmt.Errorf("determining authoring slots: %w", err)
}

return &epochHandler{
slotHandler: newSlotHandler(constants.slotDuration),
epochNumber: epochNumber,
firstSlot: firstSlot,
constants: constants,
epochData: epochData,
handleSlot: handleSlot,
slotToPreRuntimeDigest: preRuntimeDigestMap,
slotToPreRuntimeDigest: slotToPreRuntimeDigest,
}, nil
}

Expand Down

0 comments on commit 65fa6d0

Please sign in to comment.