From c5e564d771a66e086ac689c63dfcf75e1ec0d374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Tue, 23 Apr 2019 17:03:32 +0200 Subject: [PATCH] more gcsafe pragmas for Nim HEAD --- eth/p2p/discovery.nim | 4 ++-- eth/p2p/kademlia.nim | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/eth/p2p/discovery.nim b/eth/p2p/discovery.nim index e14209c..a11fb86 100644 --- a/eth/p2p/discovery.nim +++ b/eth/p2p/discovery.nim @@ -207,7 +207,7 @@ proc recvNeighbours(d: DiscoveryProtocol, node: Node, neighbours.add(newNode(pk, Address(ip: ip, udpPort: udpPort, tcpPort: tcpPort))) d.kademlia.recvNeighbours(node, neighbours) -proc recvFindNode(d: DiscoveryProtocol, node: Node, payload: Bytes) {.inline.} = +proc recvFindNode(d: DiscoveryProtocol, node: Node, payload: Bytes) {.inline, gcsafe.} = let rlp = rlpFromBytes(payload.toRange) trace "<<< find_node from ", node let rng = rlp.listElem(0).toBytes @@ -219,7 +219,7 @@ proc expirationValid(rlpEncodedPayload: seq[byte]): bool {.inline.} = let expiration = rlp.listElem(rlp.listLen - 1).toInt(uint32) result = epochTime() <= expiration.float -proc receive(d: DiscoveryProtocol, a: Address, msg: Bytes) = +proc receive(d: DiscoveryProtocol, a: Address, msg: Bytes) {.gcsafe.} = var msgHash: MDigest[256] if validateMsgHash(msg, msgHash): var remotePubkey: PublicKey diff --git a/eth/p2p/kademlia.nim b/eth/p2p/kademlia.nim index 702444d..21f711a 100644 --- a/eth/p2p/kademlia.nim +++ b/eth/p2p/kademlia.nim @@ -240,7 +240,7 @@ proc newKademliaProtocol*[Wire](thisNode: Node, proc bond(k: KademliaProtocol, n: Node): Future[bool] {.async.} -proc updateRoutingTable(k: KademliaProtocol, n: Node) = +proc updateRoutingTable(k: KademliaProtocol, n: Node) {.gcsafe.} = ## Update the routing table entry for the given node. let evictionCandidate = k.routing.addNode(n) if not evictionCandidate.isNil: @@ -250,7 +250,7 @@ proc updateRoutingTable(k: KademliaProtocol, n: Node) = # replacement cache. asyncCheck k.bond(evictionCandidate) -proc doSleep(p: proc()) {.async.} = +proc doSleep(p: proc() {.gcsafe.}) {.async, gcsafe.} = await sleepAsync(REQUEST_TIMEOUT) p() @@ -275,7 +275,7 @@ proc ping(k: KademliaProtocol, n: Node): seq[byte] = doAssert(n != k.thisNode) result = k.wire.sendPing(n) -proc waitPing(k: KademliaProtocol, n: Node): Future[bool] = +proc waitPing(k: KademliaProtocol, n: Node): Future[bool] {.gcsafe.} = result = newFuture[bool]("waitPing") doAssert(n notin k.pingFutures) k.pingFutures[n] = result @@ -317,7 +317,7 @@ proc populateNotFullBuckets(k: KademliaProtocol) = for node in bucket.replacementCache: asyncCheck k.bond(node) -proc bond(k: KademliaProtocol, n: Node): Future[bool] {.async.} = +proc bond(k: KademliaProtocol, n: Node): Future[bool] {.async, gcsafe.} = ## Bond with the given node. ## ## Bonding consists of pinging the node, waiting for a pong and maybe a ping as well. @@ -469,7 +469,7 @@ proc recvNeighbours*(k: KademliaProtocol, remote: Node, neighbours: seq[Node]) = else: trace "Unexpected neighbours, probably came too late", remote -proc recvFindNode*(k: KademliaProtocol, remote: Node, nodeId: NodeId) = +proc recvFindNode*(k: KademliaProtocol, remote: Node, nodeId: NodeId) {.gcsafe.} = if remote notin k.routing: # FIXME: This is not correct; a node we've bonded before may have become unavailable # and thus removed from self.routing, but once it's back online we should accept