GC-safety for Nimbus (#63)
This commit is contained in:
parent
53e98faa74
commit
94d4ff50ad
|
@ -4,7 +4,7 @@ import
|
|||
# TODO: Perhaps we can move this to eth-common
|
||||
|
||||
proc getBlockHeaders*(db: AbstractChainDb,
|
||||
req: BlocksRequest): seq[BlockHeader] =
|
||||
req: BlocksRequest): seq[BlockHeader] {.gcsafe.} =
|
||||
result = newSeqOfCap[BlockHeader](req.maxResults)
|
||||
|
||||
var foundBlock: BlockHeader
|
||||
|
@ -18,7 +18,7 @@ proc getBlockHeaders*(db: AbstractChainDb,
|
|||
|
||||
template fetcher*(fetcherName, fetchingFunc, InputType, ResultType: untyped) =
|
||||
proc fetcherName*(db: AbstractChainDb,
|
||||
lookups: openarray[InputType]): seq[ResultType] =
|
||||
lookups: openarray[InputType]): seq[ResultType] {.gcsafe.} =
|
||||
for lookup in lookups:
|
||||
let fetched = fetchingFunc(db, lookup)
|
||||
if fetched.hasData:
|
||||
|
|
|
@ -75,7 +75,7 @@ p2pProtocol eth(version = protocolVersion,
|
|||
discard
|
||||
|
||||
requestResponse:
|
||||
proc getBlockHeaders(peer: Peer, request: BlocksRequest) =
|
||||
proc getBlockHeaders(peer: Peer, request: BlocksRequest) {.gcsafe.} =
|
||||
if request.maxResults > uint64(maxHeadersFetch):
|
||||
await peer.disconnect(BreachOfProtocol)
|
||||
return
|
||||
|
@ -85,7 +85,7 @@ p2pProtocol eth(version = protocolVersion,
|
|||
proc blockHeaders(p: Peer, headers: openarray[BlockHeader])
|
||||
|
||||
requestResponse:
|
||||
proc getBlockBodies(peer: Peer, hashes: openarray[KeccakHash]) =
|
||||
proc getBlockBodies(peer: Peer, hashes: openarray[KeccakHash]) {.gcsafe.} =
|
||||
if hashes.len > maxBodiesFetch:
|
||||
await peer.disconnect(BreachOfProtocol)
|
||||
return
|
||||
|
|
|
@ -301,7 +301,7 @@ p2pProtocol les(version = lesVersion,
|
|||
proc getBlockBodies(
|
||||
peer: Peer,
|
||||
blocks: openarray[KeccakHash]) {.
|
||||
costQuantity(blocks.len, max = maxBodiesFetch).} =
|
||||
costQuantity(blocks.len, max = maxBodiesFetch), gcsafe.} =
|
||||
|
||||
let blocks = peer.network.chain.getBlockBodies(blocks)
|
||||
await peer.blockBodies(reqId, updateBV(), blocks)
|
||||
|
|
Loading…
Reference in New Issue