small fixes needed for the beacon node build
This commit is contained in:
parent
420298dca0
commit
c4c596a90f
|
@ -149,3 +149,12 @@ proc randomPeer*(node: EthereumNode): Peer =
|
|||
for peer in node.peers:
|
||||
if i == peerIdx: return peer
|
||||
inc i
|
||||
|
||||
proc randomPeerWith*(node: EthereumNode, Protocol: type): Peer =
|
||||
mixin state
|
||||
var candidates = newSeq[Peer]()
|
||||
for p in node.peers(Protocol):
|
||||
candidates.add(p)
|
||||
if candidates.len > 0:
|
||||
return candidates[random(candidates.len)]
|
||||
|
||||
|
|
|
@ -1,22 +1,24 @@
|
|||
import
|
||||
macros,
|
||||
serialization, json_serialization/writer,
|
||||
chronicles, chronicles_tail/configuration,
|
||||
private/types
|
||||
|
||||
export
|
||||
# XXX: Nim visibility rules get in the way here.
|
||||
# It would be nice if the users of this module don't have to
|
||||
# import json_serializer, but this won't work at the moment,
|
||||
# because the `encode` call inside `logMsgEvent` has its symbols
|
||||
# mixed in from the module where `logMsgEvent` is called
|
||||
# (instead of from this module, which will be more logical).
|
||||
init, writeValue, getOutput
|
||||
# TODO: File this as an issue
|
||||
|
||||
const tracingEnabled* = defined(p2pdump)
|
||||
|
||||
when tracingEnabled:
|
||||
import
|
||||
macros,
|
||||
serialization, json_serialization/writer,
|
||||
chronicles, chronicles_tail/configuration
|
||||
|
||||
export
|
||||
# XXX: Nim visibility rules get in the way here.
|
||||
# It would be nice if the users of this module don't have to
|
||||
# import json_serializer, but this won't work at the moment,
|
||||
# because the `encode` call inside `logMsgEvent` has its symbols
|
||||
# mixed in from the module where `logMsgEvent` is called
|
||||
# (instead of from this module, which will be more logical).
|
||||
init, writeValue, getOutput
|
||||
# TODO: File this as an issue
|
||||
|
||||
logStream p2pMessages[json[file(p2p_messages.json,truncate)]]
|
||||
p2pMessages.useTailPlugin "p2p_tracing_ctail_plugin.nim"
|
||||
|
||||
|
|
|
@ -548,6 +548,7 @@ proc getState(peer: Peer, proto: ProtocolInfo): RootRef =
|
|||
template state*(peer: Peer, Protocol: type): untyped =
|
||||
## Returns the state object of a particular protocol for a
|
||||
## particular connection.
|
||||
mixin State
|
||||
bind getState
|
||||
cast[Protocol.State](getState(peer, Protocol.protocolInfo))
|
||||
|
||||
|
@ -555,6 +556,7 @@ proc getNetworkState(node: EthereumNode, proto: ProtocolInfo): RootRef =
|
|||
node.protocolStates[proto.index]
|
||||
|
||||
template protocolState*(node: EthereumNode, Protocol: type): untyped =
|
||||
mixin NetworkState
|
||||
bind getNetworkState
|
||||
cast[Protocol.NetworkState](getNetworkState(node, Protocol.protocolInfo))
|
||||
|
||||
|
|
Loading…
Reference in New Issue