mirror of https://github.com/waku-org/nwaku.git
Add top level push raises Defect to protocol v1 (#670)
This commit is contained in:
parent
13cf7380bb
commit
4b9b654655
|
@ -1 +1 @@
|
||||||
Subproject commit 601fa7ff667431b05d18579af0e43bf4d8dafa61
|
Subproject commit a8d11dd30bf0b844e049702353addbbca803845c
|
|
@ -1 +1 @@
|
||||||
Subproject commit b985323d6418a738aa2b9e0b819efe169f00b078
|
Subproject commit 97e05aea6573d2630e318e7777a54d95db6ec40e
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# Waku - Whisper Bridge
|
# Waku - Whisper Bridge
|
||||||
# (c) Copyright 2019
|
# (c) Copyright 2018-2021
|
||||||
# Status Research & Development GmbH
|
# Status Research & Development GmbH
|
||||||
#
|
#
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
|
@ -8,6 +8,8 @@
|
||||||
# MIT license (LICENSE-MIT)
|
# MIT license (LICENSE-MIT)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
{.push raises: [Defect].}
|
||||||
|
|
||||||
import
|
import
|
||||||
eth/p2p,
|
eth/p2p,
|
||||||
eth/p2p/rlpx_protocols/whisper_protocol,
|
eth/p2p/rlpx_protocols/whisper_protocol,
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
#
|
#
|
||||||
# Waku Mail Client & Server
|
# Waku Mail Client & Server
|
||||||
# (c) Copyright 2019
|
# (c) Copyright 2018-2021
|
||||||
# Status Research & Development GmbH
|
# Status Research & Development GmbH
|
||||||
#
|
#
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# Apache License, version 2.0, (LICENSE-APACHEv2)
|
# Apache License, version 2.0, (LICENSE-APACHEv2)F
|
||||||
# MIT license (LICENSE-MIT)
|
# MIT license (LICENSE-MIT)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
{.push raises: [Defect].}
|
||||||
|
|
||||||
import
|
import
|
||||||
chronos,
|
chronos,
|
||||||
eth/[p2p, async_utils],
|
eth/[p2p, async_utils],
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#
|
#
|
||||||
# Waku
|
# Waku
|
||||||
# (c) Copyright 2018-2019
|
# (c) Copyright 2018-2021
|
||||||
# Status Research & Development GmbH
|
# Status Research & Development GmbH
|
||||||
#
|
#
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
|
@ -37,6 +37,8 @@
|
||||||
## However, they only make real sense after ``connectToNetwork`` was started. As
|
## However, they only make real sense after ``connectToNetwork`` was started. As
|
||||||
## else there will be no peers to send and receive messages from.
|
## else there will be no peers to send and receive messages from.
|
||||||
|
|
||||||
|
{.push raises: [Defect].}
|
||||||
|
|
||||||
import
|
import
|
||||||
options, tables, times, chronos, chronicles, metrics,
|
options, tables, times, chronos, chronicles, metrics,
|
||||||
eth/[keys, async_utils, p2p], eth/p2p/rlpx_protocols/whisper/whisper_types,
|
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()
|
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():
|
if not rlp.isList():
|
||||||
raise newException(RlpTypeMismatch,
|
raise newException(RlpTypeMismatch,
|
||||||
"List expected, but the source RLP is not a list.")
|
"List expected, but the source RLP is not a list.")
|
||||||
|
@ -433,7 +440,7 @@ proc run(peer: Peer) {.async, raises: [Defect].} =
|
||||||
peer.processQueue()
|
peer.processQueue()
|
||||||
await sleepAsync(messageInterval)
|
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 ...
|
if node.peerPool != nil: # XXX: a bit dirty to need to check for this here ...
|
||||||
var wakuNet = node.protocolState(Waku)
|
var wakuNet = node.protocolState(Waku)
|
||||||
|
|
||||||
|
@ -561,7 +568,8 @@ proc unsubscribeFilter*(node: EthereumNode, filterId: string): bool =
|
||||||
var filter: Filter
|
var filter: Filter
|
||||||
return node.protocolState(Waku).filters.take(filterId, 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
|
## Get all the messages currently in the filter queue. This will reset the
|
||||||
## filter message queue.
|
## filter message queue.
|
||||||
return node.protocolState(Waku).filters.getFilterMessages(filterId)
|
return node.protocolState(Waku).filters.getFilterMessages(filterId)
|
||||||
|
|
Loading…
Reference in New Issue