Skip to content

Commit b658415

Browse files
authored
add custom hash for RootedVertexID (#3070)
* add custom `hash` for `RootedVertexID` There's no benefit hashing `root` since `vid` is already unique and the "default" hash is not free - this trivially brings a small perf boost to one of the key lookup tables in aristo_layers. * lint
1 parent e666eb5 commit b658415

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

execution_chain/db/aristo/aristo_desc/desc_identifiers.nim

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# nimbus-eth1
2-
# Copyright (c) 2023-2024 Status Research & Development GmbH
2+
# Copyright (c) 2023-2025 Status Research & Development GmbH
33
# Licensed under either of
44
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
55
# http://www.apache.org/licenses/LICENSE-2.0)
@@ -130,16 +130,22 @@ func `$`*(vid: VertexID): string =
130130
"$" & (if vid == VertexID(0): "ø"
131131
else: vid.uint64.toHex.strip(trailing=false,chars={'0'}).toLowerAscii)
132132

133-
func `$`*(rvid: RootedVertexID): string =
134-
$rvid.root & "/" & $rvid.vid
135-
136133
func `==`*(a: VertexID; b: static[uint]): bool = (a == VertexID(b))
137134

138135
# Scalar model extension as in `IntervalSetRef[VertexID,uint64]`
139136
func `+`*(a: VertexID; b: uint64): VertexID = (a.uint64+b).VertexID
140137
func `-`*(a: VertexID; b: uint64): VertexID = (a.uint64-b).VertexID
141138
func `-`*(a, b: VertexID): uint64 = (a.uint64 - b.uint64)
142139

140+
func `==`*(a, b: RootedVertexID): bool {.inline.} =
141+
a.vid == b.vid
142+
143+
func hash*(rvid: RootedVertexID): Hash {.inline.} =
144+
hash(rvid.vid)
145+
146+
func `$`*(rvid: RootedVertexID): string =
147+
$rvid.root & "/" & $rvid.vid
148+
143149
# ------------------------------------------------------------------------------
144150
# Public helpers: `PathID` ordered scalar data model
145151
# ------------------------------------------------------------------------------

execution_chain/sync/protocol/eth68.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# at your option. This file may not be copied, modified, or distributed
1010
# except according to those terms.
1111

12-
## This module implements Ethereum Wire Protocol version 67, `eth/67`.
12+
## This module implements Ethereum Wire Protocol version 68, `eth/68`.
1313
## Specification:
1414
## `eth/68 <https://github.com/ethereum/devp2p/blob/master/caps/eth.md>`_
1515

0 commit comments

Comments
 (0)