-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add function to create epoch defaults from fork epochs
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package iterator | ||
|
||
import ( | ||
"github.com/attestantio/go-eth2-client/spec" | ||
"github.com/attestantio/go-eth2-client/spec/phase0" | ||
"github.com/ethpandaops/beacon/pkg/beacon/state" | ||
"github.com/ethpandaops/xatu/pkg/proto/xatu" | ||
) | ||
|
||
func NewEpochDefaultsFromForkEpochs(forkEpochs state.ForkEpochs) map[xatu.CannonType]phase0.Epoch { | ||
var ( | ||
bellatrixEpoch, | ||
capellaEpoch, | ||
denebEpoch phase0.Epoch | ||
) | ||
|
||
bellatrix, err := forkEpochs.GetByName(spec.DataVersionBellatrix.String()) | ||
if err == nil { | ||
bellatrixEpoch = bellatrix.Epoch | ||
} | ||
|
||
capella, err := forkEpochs.GetByName(spec.DataVersionCapella.String()) | ||
if err == nil { | ||
capellaEpoch = capella.Epoch | ||
} | ||
|
||
deneb, err := forkEpochs.GetByName(spec.DataVersionDeneb.String()) | ||
if err == nil { | ||
denebEpoch = deneb.Epoch | ||
} | ||
|
||
return map[xatu.CannonType]phase0.Epoch{ | ||
xatu.CannonType_BEACON_API_ETH_V2_BEACON_BLOCK_BLS_TO_EXECUTION_CHANGE: capellaEpoch, | ||
xatu.CannonType_BEACON_API_ETH_V2_BEACON_BLOCK_WITHDRAWAL: capellaEpoch, | ||
xatu.CannonType_BEACON_API_ETH_V2_BEACON_BLOCK_EXECUTION_TRANSACTION: bellatrixEpoch, | ||
xatu.CannonType_BEACON_API_ETH_V1_BEACON_BLOB_SIDECAR: denebEpoch, | ||
} | ||
} |