mirror of https://github.com/status-im/nim-eth.git
refactor: compile with nim-devel
This commit is contained in:
parent
e1bdf1741a
commit
5d13052dd9
|
@ -93,7 +93,10 @@ type
|
|||
KfResult*[T] = Result[T, KeyFileError]
|
||||
|
||||
proc mapErrTo[T, E](r: Result[T, E], v: static KeyFileError): KfResult[T] =
|
||||
r.mapErr(proc (e: E): KeyFileError = v)
|
||||
if r.isOk:
|
||||
ok(r.value)
|
||||
else:
|
||||
err(v)
|
||||
|
||||
const
|
||||
SupportedHashes = [
|
||||
|
|
|
@ -211,7 +211,7 @@ proc randomNodes*(d: Protocol, maxAmount: int): seq[Node] =
|
|||
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, raises:[Defect].}): seq[Node] =
|
||||
## 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)
|
||||
|
|
|
@ -512,7 +512,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, raises:[Defect].} = nil): seq[Node] =
|
||||
## 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
|
||||
|
|
|
@ -21,6 +21,9 @@ type
|
|||
items: seq[Option[A]]
|
||||
mask: uint32
|
||||
|
||||
when not defined(nimHasEffectsOfs):
|
||||
template effectsOf(f: untyped) {.pragma.}
|
||||
|
||||
# provided size will always be adjusted to next power of two
|
||||
proc init*[A](T: type GrowableCircularBuffer[A], size: uint32 = 16): T =
|
||||
let powOfTwoSize = nextPowerOfTwo(int(size))
|
||||
|
@ -44,11 +47,13 @@ proc delete*[A](buff: var GrowableCircularBuffer[A], i: uint32) =
|
|||
proc hasKey*[A](buff: GrowableCircularBuffer[A], i: uint32): bool =
|
||||
buff.get(i).isSome()
|
||||
|
||||
proc exists*[A](buff: GrowableCircularBuffer[A], i: uint32, check: proc (x: A): bool): bool =
|
||||
proc exists*[A](buff: GrowableCircularBuffer[A], i: uint32,
|
||||
check: proc (x: A): bool): bool {.gcsafe, effectsOf: check.} =
|
||||
let maybeElem = buff.get(i)
|
||||
if (maybeElem.isSome()):
|
||||
let elem = maybeElem.unsafeGet()
|
||||
check(elem)
|
||||
{.gcsafe.}:
|
||||
check(elem)
|
||||
else:
|
||||
false
|
||||
|
||||
|
|
Loading…
Reference in New Issue