Skip to content

Commit

Permalink
fix(epoch): Fixing linting
Browse files Browse the repository at this point in the history
  • Loading branch information
ramiroJCB committed Aug 20, 2024
1 parent 1e4ce50 commit 2cf996f
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions dot/state/epoch.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ func NewEpochState(db database.Database, blockState *BlockState,
}

// getNextEpochAndConfigDataFromDisk retrieves the next epoch and config data maps from the database
func getNextEpochAndConfigDataFromDisk(db database.Database) (nextEpochMap[types.NextEpochData], nextEpochMap[types.NextConfigDataV1], error) {
func getNextEpochAndConfigDataFromDisk(db database.Database) (
nextEpochMap[types.NextEpochData], nextEpochMap[types.NextConfigDataV1], error) {

nextConfigData := make(nextEpochMap[types.NextConfigDataV1])
nextEpochData := make(nextEpochMap[types.NextEpochData])

Expand All @@ -199,8 +201,6 @@ func getNextEpochAndConfigDataFromDisk(db database.Database) (nextEpochMap[types
nextConfigData[epoch][fork] = *nexEpochvalue
}

configIter.Close()

epochIter, err := db.NewPrefixIterator(nextEpochDataPrefix)
if err != nil {
return nextEpochMap[types.NextEpochData]{}, nextEpochMap[types.NextConfigDataV1]{}, err
Expand All @@ -224,13 +224,12 @@ func getNextEpochAndConfigDataFromDisk(db database.Database) (nextEpochMap[types

}

epochIter.Close()

return nextEpochData, nextConfigData, nil
}

// getNextEpochOrConfigData retrieves the next epoch or config data from the iterator
func getNextEpochOrConfigData[T *types.NextConfigDataV1 | *types.NextEpochData](NextData T, nextDataPrefix []byte, iter database.Iterator) (T, uint64, common.Hash, error) {
func getNextEpochOrConfigData[T *types.NextConfigDataV1 | *types.NextEpochData](
NextData T, nextDataPrefix []byte, iter database.Iterator) (T, uint64, common.Hash, error) {
key := string(iter.Key())
value := iter.Value()

Expand Down Expand Up @@ -937,7 +936,8 @@ func (s *EpochState) storeBABENextEpochData(epoch uint64, hash common.Hash, next
}

// setBABENextEpochDataInDB stores the types.NextEpochData under epoch and hash keys
func (s *EpochState) setBABENextEpochDataInDB(epoch uint64, forkHash common.Hash, nextEpochData types.NextEpochData) error {
func (s *EpochState) setBABENextEpochDataInDB(epoch uint64, forkHash common.Hash,
nextEpochData types.NextEpochData) error {
encodedEpochData, err := scale.Marshal(nextEpochData)
if err != nil {
return err
Expand All @@ -963,7 +963,8 @@ func (s *EpochState) storeBABENextConfigData(epoch uint64, hash common.Hash, nex
}

// setBABENextConfigData stores the types.NextConfigData under epoch and hash keys
func (s *EpochState) setBABENextConfigData(epoch uint64, forkHash common.Hash, nextConfigData types.NextConfigDataV1) error {
func (s *EpochState) setBABENextConfigData(epoch uint64,
forkHash common.Hash, nextConfigData types.NextConfigDataV1) error {
encodedConfigData, err := scale.Marshal(nextConfigData)
if err != nil {
return err
Expand Down Expand Up @@ -1052,7 +1053,10 @@ func (s *EpochState) deleteEpochDataFromDisk(epoch uint64) error {

// getNextEpochOrConfigDataKeysFromDisk is a generic function that returns all the nextEpochData or nextConfigData keys
// for a given epoch from the database
func getNextEpochOrConfigDataKeysFromDisk[T *types.NextEpochData | *types.NextConfigDataV1](db GetterPutterNewBatcherPrefixIter, value T, prefix []byte, currentEpoch uint64) ([]string, error) {
func getNextEpochOrConfigDataKeysFromDisk[T *types.NextEpochData | *types.NextConfigDataV1](
db GetterPutterNewBatcherPrefixIter, value T, prefix []byte, currentEpoch uint64) (
[]string, error) {

dataKeys := []string{}

iter, err := db.NewPrefixIterator(prefix)
Expand All @@ -1075,8 +1079,6 @@ func getNextEpochOrConfigDataKeysFromDisk[T *types.NextEpochData | *types.NextCo

}

iter.Close()

return dataKeys, nil
}

Expand Down

0 comments on commit 2cf996f

Please sign in to comment.