Add top level push raises Defect to protocol v1 (#670)

This commit is contained in:
Kim De Mey 2021-07-16 23:13:04 +02:00 committed by GitHub
parent 13cf7380bb
commit 4b9b654655
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 10 deletions

2
vendor/nim-eth vendored

@ -1 +1 @@
Subproject commit 601fa7ff667431b05d18579af0e43bf4d8dafa61
Subproject commit a8d11dd30bf0b844e049702353addbbca803845c

2
vendor/nim-web3 vendored

@ -1 +1 @@
Subproject commit b985323d6418a738aa2b9e0b819efe169f00b078
Subproject commit 97e05aea6573d2630e318e7777a54d95db6ec40e

View File

@ -1,6 +1,6 @@
#
# Waku - Whisper Bridge
# (c) Copyright 2019
# (c) Copyright 2018-2021
# Status Research & Development GmbH
#
# Licensed under either of
@ -8,6 +8,8 @@
# MIT license (LICENSE-MIT)
#
{.push raises: [Defect].}
import
eth/p2p,
eth/p2p/rlpx_protocols/whisper_protocol,

View File

@ -1,12 +1,15 @@
#
# Waku Mail Client & Server
# (c) Copyright 2019
# (c) Copyright 2018-2021
# Status Research & Development GmbH
#
# Licensed under either of
# Apache License, version 2.0, (LICENSE-APACHEv2)
# Apache License, version 2.0, (LICENSE-APACHEv2)F
# MIT license (LICENSE-MIT)
#
{.push raises: [Defect].}
import
chronos,
eth/[p2p, async_utils],

View File

@ -1,6 +1,6 @@
#
# Waku
# (c) Copyright 2018-2019
# (c) Copyright 2018-2021
# Status Research & Development GmbH
#
# Licensed under either of
@ -37,6 +37,8 @@
## However, they only make real sense after ``connectToNetwork`` was started. As
## else there will be no peers to send and receive messages from.
{.push raises: [Defect].}
import
options, tables, times, chronos, chronicles, metrics,
eth/[keys, async_utils, p2p], eth/p2p/rlpx_protocols/whisper/whisper_types,
@ -143,9 +145,14 @@ proc append*(rlpWriter: var RlpWriter, value: StatusOptions) =
let bytes = list.finish()
rlpWriter.append(rlpFromBytes(bytes))
try:
rlpWriter.append(rlpFromBytes(bytes))
except RlpError as e:
# bytes is valid rlp just created here, rlpFromBytes should thus never fail
raiseAssert e.msg
proc read*(rlp: var Rlp, T: typedesc[StatusOptions]): T =
proc read*(rlp: var Rlp, T: typedesc[StatusOptions]):
T {.raises: [RlpError, Defect].}=
if not rlp.isList():
raise newException(RlpTypeMismatch,
"List expected, but the source RLP is not a list.")
@ -433,7 +440,7 @@ proc run(peer: Peer) {.async, raises: [Defect].} =
peer.processQueue()
await sleepAsync(messageInterval)
proc pruneReceived(node: EthereumNode) {.raises: [].} =
proc pruneReceived(node: EthereumNode) =
if node.peerPool != nil: # XXX: a bit dirty to need to check for this here ...
var wakuNet = node.protocolState(Waku)
@ -561,7 +568,8 @@ proc unsubscribeFilter*(node: EthereumNode, filterId: string): bool =
var filter: Filter
return node.protocolState(Waku).filters.take(filterId, filter)
proc getFilterMessages*(node: EthereumNode, filterId: string): seq[ReceivedMessage] =
proc getFilterMessages*(node: EthereumNode, filterId: string):
seq[ReceivedMessage] {.raises: [KeyError, Defect].} =
## Get all the messages currently in the filter queue. This will reset the
## filter message queue.
return node.protocolState(Waku).filters.getFilterMessages(filterId)