Skip to content

Commit

Permalink
add support for returning network based on fork version
Browse files Browse the repository at this point in the history
  • Loading branch information
y0sher authored Oct 31, 2023
1 parent e2b8264 commit 1f6fd74
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions core/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ func (n Network) GenesisForkVersion() phase0.Version {
}
}

// NetworkFromGenesisForkVersion returns the network base on the 4 bytes of the genesis fork version
func NetworkFromGenesisForkVersion(fork phase0.Version) Network {
switch fork {
case phase0.Version{0, 0, 32, 9}:
return PyrmontNetwork
case phase0.Version{0x00, 0x00, 0x10, 0x20}:
return PraterNetwork
case phase0.Version{0x01, 0x01, 0x70, 0x00}:
return HoleskyNetwork
case phase0.Version{0, 0, 0, 0}:
return MainNetwork
default:
logrus.WithField("network", n).Fatal("undefined network")

Check failure on line 59 in core/networks.go

View workflow job for this annotation

GitHub Actions / lint

undefined: n) (typecheck)

Check failure on line 59 in core/networks.go

View workflow job for this annotation

GitHub Actions / lint

undefined: n) (typecheck)

Check failure on line 59 in core/networks.go

View workflow job for this annotation

GitHub Actions / lint

undefined: n) (typecheck)

Check failure on line 59 in core/networks.go

View workflow job for this annotation

GitHub Actions / lint

undefined: n (typecheck)

Check failure on line 59 in core/networks.go

View workflow job for this annotation

GitHub Actions / lint

undefined: n

Check failure on line 59 in core/networks.go

View workflow job for this annotation

GitHub Actions / test

undefined: n

Check failure on line 59 in core/networks.go

View workflow job for this annotation

GitHub Actions / lint

undefined: n) (typecheck)

Check failure on line 59 in core/networks.go

View workflow job for this annotation

GitHub Actions / lint

undefined: n) (typecheck)

Check failure on line 59 in core/networks.go

View workflow job for this annotation

GitHub Actions / lint

undefined: n) (typecheck)

Check failure on line 59 in core/networks.go

View workflow job for this annotation

GitHub Actions / lint

undefined: n (typecheck)
return ""
}
}

// GenesisValidatorsRoot returns the genesis validators root of the network.
func (n Network) GenesisValidatorsRoot() phase0.Root {
var genValidatorsRoot phase0.Root
Expand Down

0 comments on commit 1f6fd74

Please sign in to comment.