Add pragma for exception raises

This commit is contained in:
Arnaud 2024-12-09 12:45:57 +01:00
parent 57f4b6f7cb
commit d73dc48515
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
2 changed files with 4 additions and 4 deletions

View File

@ -236,18 +236,18 @@ proc getNode*(d: Protocol, id: NodeId): Option[Node] =
## Get the node with id from the routing table.
d.routingTable.getNode(id)
proc randomNodes*(d: Protocol, maxAmount: int): seq[Node] =
proc randomNodes*(d: Protocol, maxAmount: int): seq[Node] {.raises: Exception.} =
## Get a `maxAmount` of random nodes from the local routing table.
d.routingTable.randomNodes(maxAmount)
proc randomNodes*(d: Protocol, maxAmount: int,
pred: proc(x: Node): bool {.gcsafe, noSideEffect.}): seq[Node] =
pred: proc(x: Node): bool {.gcsafe, noSideEffect.}): seq[Node] {.raises: Exception.} =
## Get a `maxAmount` of random nodes from the local routing table with the
## `pred` predicate function applied as filter on the nodes selected.
d.routingTable.randomNodes(maxAmount, pred)
proc randomNodes*(d: Protocol, maxAmount: int,
enrField: (string, seq[byte])): seq[Node] =
enrField: (string, seq[byte])): seq[Node] {.raises: Exception.} =
## Get a `maxAmount` of random nodes from the local routing table. The
## the nodes selected are filtered by provided `enrField`.
d.randomNodes(maxAmount, proc(x: Node): bool = x.record.contains(enrField))

View File

@ -555,7 +555,7 @@ proc nodeToRevalidate*(r: RoutingTable): Node =
return b.nodes[^1]
proc randomNodes*(r: RoutingTable, maxAmount: int,
pred: proc(x: Node): bool {.gcsafe, noSideEffect.} = nil): seq[Node] =
pred: proc(x: Node): bool {.gcsafe, noSideEffect.} = nil): seq[Node] {.raises: Exception.} =
## Get a `maxAmount` of random nodes from the routing table with the `pred`
## predicate function applied as filter on the nodes selected.
var maxAmount = maxAmount