mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-02-02 09:46:26 +00:00
improve consistency of checkpoint read function (#3178)
Makes `readSszForkedTrustedSignedBeaconBlock` consistent with `readSszForkedHashedBeaconState`, adjusting the length check to verify the same type that is used for length computation, and using the same formatting.
This commit is contained in:
parent
342ba68053
commit
9d5389654b
@ -450,13 +450,12 @@ func readSszForkedTrustedSignedBeaconBlock*(
|
|||||||
ForkedTrustedSignedBeaconBlock {.raises: [Defect, SszError].} =
|
ForkedTrustedSignedBeaconBlock {.raises: [Defect, SszError].} =
|
||||||
## Helper to read a header from bytes when it's not certain what kind of block
|
## Helper to read a header from bytes when it's not certain what kind of block
|
||||||
## it is
|
## it is
|
||||||
|
if data.len() < sizeof(ForkedBeaconBlockHeader):
|
||||||
if data.len() < sizeof(BeaconBlockHeader):
|
|
||||||
raise (ref MalformedSszError)(msg: "Not enough data for SignedBeaconBlock header")
|
raise (ref MalformedSszError)(msg: "Not enough data for SignedBeaconBlock header")
|
||||||
|
|
||||||
let header = SSZ.decode(
|
let header = SSZ.decode(
|
||||||
data.toOpenArray(0, sizeof(ForkedBeaconBlockHeader) - 1),
|
data.toOpenArray(0, sizeof(ForkedBeaconBlockHeader) - 1),
|
||||||
ForkedBeaconBlockHeader)
|
ForkedBeaconBlockHeader)
|
||||||
|
|
||||||
# careful - `result` is used, RVO didn't seem to work without
|
# careful - `result` is used, RVO didn't seem to work without
|
||||||
# TODO move time helpers somewhere to avoid circular imports
|
# TODO move time helpers somewhere to avoid circular imports
|
||||||
result = ForkedTrustedSignedBeaconBlock(
|
result = ForkedTrustedSignedBeaconBlock(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user