Reduce size of api/client import graph (#14871)

* relocate DownloadFinalizedData from api to sync

* unexpected go mod changes

---------

Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com>
This commit is contained in:
kasey
2025-02-05 14:40:13 -06:00
committed by GitHub
parent 41daac1b04
commit 842f241cb9
16 changed files with 494 additions and 464 deletions

View File

@@ -100,3 +100,26 @@ func NewOrderedSchedule(b *params.BeaconChainConfig) OrderedSchedule {
sort.Sort(ofs)
return ofs
}
// ForkForEpochFromConfig returns the fork data for the given epoch from the provided config.
func ForkForEpochFromConfig(cfg *params.BeaconChainConfig, epoch primitives.Epoch) (*ethpb.Fork, error) {
os := NewOrderedSchedule(cfg)
currentVersion, err := os.VersionForEpoch(epoch)
if err != nil {
return nil, err
}
prevVersion, err := os.Previous(currentVersion)
if err != nil {
if !errors.Is(err, ErrNoPreviousVersion) {
return nil, err
}
// use same version for both in the case of genesis
prevVersion = currentVersion
}
forkEpoch := cfg.ForkVersionSchedule[currentVersion]
return &ethpb.Fork{
PreviousVersion: prevVersion[:],
CurrentVersion: currentVersion[:],
Epoch: forkEpoch,
}, nil
}