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