add `toBeaconBlockHeader` overload (#3468)
Overloads `toBeaconBlockHeader` for `ForkedTrustedSignedBeaconBlock`.
This commit is contained in:
parent
187eabeeb9
commit
7d7bfa1299
|
@ -245,21 +245,6 @@ template toFork*[T:
|
||||||
t: type T): BeaconBlockFork =
|
t: type T): BeaconBlockFork =
|
||||||
BeaconBlockFork.Bellatrix
|
BeaconBlockFork.Bellatrix
|
||||||
|
|
||||||
func toBeaconBlockHeader*(
|
|
||||||
blck: SomeForkyBeaconBlock): BeaconBlockHeader =
|
|
||||||
## Reduce a given `BeaconBlock` to just its `BeaconBlockHeader`.
|
|
||||||
BeaconBlockHeader(
|
|
||||||
slot: blck.slot,
|
|
||||||
proposer_index: blck.proposer_index,
|
|
||||||
parent_root: blck.parent_root,
|
|
||||||
state_root: blck.state_root,
|
|
||||||
body_root: blck.body.hash_tree_root())
|
|
||||||
|
|
||||||
template toBeaconBlockHeader*(
|
|
||||||
blck: SomeForkySignedBeaconBlock): BeaconBlockHeader =
|
|
||||||
## Reduce a given `SignedBeaconBlock` to just its `BeaconBlockHeader`.
|
|
||||||
blck.message.toBeaconBlockHeader
|
|
||||||
|
|
||||||
template init*(T: type ForkedEpochInfo, info: phase0.EpochInfo): T =
|
template init*(T: type ForkedEpochInfo, info: phase0.EpochInfo): T =
|
||||||
T(kind: EpochInfoFork.Phase0, phase0Data: info)
|
T(kind: EpochInfoFork.Phase0, phase0Data: info)
|
||||||
template init*(T: type ForkedEpochInfo, info: altair.EpochInfo): T =
|
template init*(T: type ForkedEpochInfo, info: altair.EpochInfo): T =
|
||||||
|
@ -433,6 +418,27 @@ template withStateAndBlck*(
|
||||||
template blck: untyped {.inject.} = b.phase0Data
|
template blck: untyped {.inject.} = b.phase0Data
|
||||||
body
|
body
|
||||||
|
|
||||||
|
func toBeaconBlockHeader*(
|
||||||
|
blck: SomeForkyBeaconBlock): BeaconBlockHeader =
|
||||||
|
## Reduce a given `BeaconBlock` to its `BeaconBlockHeader`.
|
||||||
|
BeaconBlockHeader(
|
||||||
|
slot: blck.slot,
|
||||||
|
proposer_index: blck.proposer_index,
|
||||||
|
parent_root: blck.parent_root,
|
||||||
|
state_root: blck.state_root,
|
||||||
|
body_root: blck.body.hash_tree_root())
|
||||||
|
|
||||||
|
template toBeaconBlockHeader*(
|
||||||
|
blck: SomeForkySignedBeaconBlock): BeaconBlockHeader =
|
||||||
|
## Reduce a given `SignedBeaconBlock` to its `BeaconBlockHeader`.
|
||||||
|
blck.message.toBeaconBlockHeader
|
||||||
|
|
||||||
|
template toBeaconBlockHeader*(
|
||||||
|
blckParam: ForkedTrustedSignedBeaconBlock): BeaconBlockHeader =
|
||||||
|
## Reduce a given `ForkedTrustedSignedBeaconBlock` to its `BeaconBlockHeader`.
|
||||||
|
withBlck(blckParam):
|
||||||
|
blck.toBeaconBlockHeader()
|
||||||
|
|
||||||
func genesisFork*(cfg: RuntimeConfig): Fork =
|
func genesisFork*(cfg: RuntimeConfig): Fork =
|
||||||
Fork(
|
Fork(
|
||||||
previous_version: cfg.GENESIS_FORK_VERSION,
|
previous_version: cfg.GENESIS_FORK_VERSION,
|
||||||
|
|
Loading…
Reference in New Issue