mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-28 11:50:45 +00:00
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
This commit is contained in:
parent
e666eb52b0
commit
b6584153ff
@ -1,5 +1,5 @@
|
|||||||
# nimbus-eth1
|
# nimbus-eth1
|
||||||
# Copyright (c) 2023-2024 Status Research & Development GmbH
|
# Copyright (c) 2023-2025 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
@ -130,9 +130,6 @@ func `$`*(vid: VertexID): string =
|
|||||||
"$" & (if vid == VertexID(0): "ø"
|
"$" & (if vid == VertexID(0): "ø"
|
||||||
else: vid.uint64.toHex.strip(trailing=false,chars={'0'}).toLowerAscii)
|
else: vid.uint64.toHex.strip(trailing=false,chars={'0'}).toLowerAscii)
|
||||||
|
|
||||||
func `$`*(rvid: RootedVertexID): string =
|
|
||||||
$rvid.root & "/" & $rvid.vid
|
|
||||||
|
|
||||||
func `==`*(a: VertexID; b: static[uint]): bool = (a == VertexID(b))
|
func `==`*(a: VertexID; b: static[uint]): bool = (a == VertexID(b))
|
||||||
|
|
||||||
# Scalar model extension as in `IntervalSetRef[VertexID,uint64]`
|
# Scalar model extension as in `IntervalSetRef[VertexID,uint64]`
|
||||||
@ -140,6 +137,15 @@ func `+`*(a: VertexID; b: uint64): VertexID = (a.uint64+b).VertexID
|
|||||||
func `-`*(a: VertexID; b: uint64): VertexID = (a.uint64-b).VertexID
|
func `-`*(a: VertexID; b: uint64): VertexID = (a.uint64-b).VertexID
|
||||||
func `-`*(a, b: VertexID): uint64 = (a.uint64 - b.uint64)
|
func `-`*(a, b: VertexID): uint64 = (a.uint64 - b.uint64)
|
||||||
|
|
||||||
|
func `==`*(a, b: RootedVertexID): bool {.inline.} =
|
||||||
|
a.vid == b.vid
|
||||||
|
|
||||||
|
func hash*(rvid: RootedVertexID): Hash {.inline.} =
|
||||||
|
hash(rvid.vid)
|
||||||
|
|
||||||
|
func `$`*(rvid: RootedVertexID): string =
|
||||||
|
$rvid.root & "/" & $rvid.vid
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Public helpers: `PathID` ordered scalar data model
|
# Public helpers: `PathID` ordered scalar data model
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
# at your option. This file may not be copied, modified, or distributed
|
# at your option. This file may not be copied, modified, or distributed
|
||||||
# except according to those terms.
|
# except according to those terms.
|
||||||
|
|
||||||
## This module implements Ethereum Wire Protocol version 67, `eth/67`.
|
## This module implements Ethereum Wire Protocol version 68, `eth/68`.
|
||||||
## Specification:
|
## Specification:
|
||||||
## `eth/68 <https://github.com/ethereum/devp2p/blob/master/caps/eth.md>`_
|
## `eth/68 <https://github.com/ethereum/devp2p/blob/master/caps/eth.md>`_
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user