mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 21:34:33 +00:00
parent
1d472cf090
commit
c1899711c9
@ -429,8 +429,9 @@ proc processProtocolList(v: string, flags: var set[ProtocolFlags]): ConfigStatus
|
||||
|
||||
proc processENode(v: string, o: var ENode): ConfigStatus =
|
||||
## Convert string to ENode.
|
||||
let res = initENode(v, o)
|
||||
if res == ENodeStatus.Success:
|
||||
let res = ENode.fromString(v)
|
||||
if res.isOk:
|
||||
o = res[]
|
||||
result = Success
|
||||
else:
|
||||
result = ErrorParseOption
|
||||
|
2
vendor/nim-eth
vendored
2
vendor/nim-eth
vendored
@ -1 +1 @@
|
||||
Subproject commit ac5bbe4d3d04ca1baf455f5a7e22a04692bcc73a
|
||||
Subproject commit 0b110f3287f26e03f5e7ac4c9e7f0103456895c0
|
@ -11,18 +11,15 @@ const clientId = "Nimbus waku node"
|
||||
let globalListeningAddr = parseIpAddress("0.0.0.0")
|
||||
|
||||
proc setBootNodes(nodes: openArray[string]): seq[ENode] =
|
||||
var bootnode: ENode
|
||||
result = newSeqOfCap[ENode](nodes.len)
|
||||
for nodeId in nodes:
|
||||
# TODO: something more user friendly than an assert
|
||||
doAssert(initENode(nodeId, bootnode) == ENodeStatus.Success)
|
||||
result.add(bootnode)
|
||||
# TODO: something more user friendly than an expect
|
||||
result.add(ENode.fromString(nodeId).expect("correct node"))
|
||||
|
||||
proc connectToNodes(node: EthereumNode, nodes: openArray[string]) =
|
||||
for nodeId in nodes:
|
||||
var whisperENode: ENode
|
||||
# TODO: something more user friendly than an assert
|
||||
doAssert(initENode(nodeId, whisperENode) == ENodeStatus.Success)
|
||||
let whisperENode = ENode.fromString(nodeId).expect("correct node")
|
||||
|
||||
traceAsyncErrors node.peerPool.connectToNode(newNode(whisperENode))
|
||||
|
||||
|
@ -69,20 +69,18 @@ proc generateRandomID(): Identifier =
|
||||
break
|
||||
|
||||
proc setBootNodes(nodes: openArray[string]): seq[ENode] =
|
||||
var bootnode: ENode
|
||||
result = newSeqOfCap[ENode](nodes.len)
|
||||
for nodeId in nodes:
|
||||
# For now we can just do assert as we only pass our own const arrays.
|
||||
doAssert(initENode(nodeId, bootnode) == ENodeStatus.Success)
|
||||
result.add(bootnode)
|
||||
let enode = ENode.fromString(nodeId).expect("correct enode")
|
||||
result.add(enode)
|
||||
|
||||
proc connectToNodes(nodes: openArray[string]) =
|
||||
for nodeId in nodes:
|
||||
var whisperENode: ENode
|
||||
# For now we can just do assert as we only pass our own const arrays.
|
||||
doAssert(initENode(nodeId, whisperENode) == ENodeStatus.Success)
|
||||
let enode = ENode.fromString(nodeId).expect("correct enode")
|
||||
|
||||
traceAsyncErrors node.peerPool.connectToNode(newNode(whisperENode))
|
||||
traceAsyncErrors node.peerPool.connectToNode(newNode(enode))
|
||||
|
||||
# Setting up the node
|
||||
|
||||
@ -135,11 +133,12 @@ proc nimbus_poll() {.exportc, dynlib.} =
|
||||
|
||||
proc nimbus_add_peer(nodeId: cstring): bool {.exportc, dynlib.} =
|
||||
var
|
||||
whisperENode: ENode
|
||||
whisperNode: Node
|
||||
discard initENode($nodeId, whisperENode)
|
||||
let enode = ENode.fromString($nodeId)
|
||||
if enode.isErr:
|
||||
return false
|
||||
try:
|
||||
whisperNode = newNode(whisperENode)
|
||||
whisperNode = newNode(enode[])
|
||||
except CatchableError:
|
||||
return false
|
||||
|
||||
@ -234,7 +233,7 @@ proc nimbus_add_symkey(symKey: ptr SymKey, id: var Identifier): bool
|
||||
whisperKeys.symKeys.add(id.toHex, symKey[])
|
||||
|
||||
proc nimbus_add_symkey_from_password(password: cstring, id: var Identifier):
|
||||
bool {.exportc, dynlib, raises: [].} =
|
||||
bool {.exportc, dynlib, raises: [Defect].} =
|
||||
## Caller needs to provide as id a pointer to 32 bytes allocation.
|
||||
doAssert(not (unsafeAddr id).isNil, "Key id cannot be nil.")
|
||||
doAssert(not password.isNil, "Password cannot be nil.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user