More cosmetic changes

This commit is contained in:
kdeme 2020-01-23 15:40:41 +01:00
parent e8ec1706ed
commit 4ec126afaf
No known key found for this signature in database
GPG Key ID: 4E8DD21420AF43F5
3 changed files with 18 additions and 22 deletions

View File

@ -80,7 +80,7 @@ proc setupWakuRPC*(node: EthereumNode, keys: KeyStorage, rpcsrv: RpcServer) =
## Returns key identifier on success and an error on failure. ## Returns key identifier on success and an error on failure.
result = generateRandomID().Identifier result = generateRandomID().Identifier
keys.asymKeys.add(result.string, key.toKeyPair) keys.asymKeys.add(result.string, key.toKeyPair())
rpcsrv.rpc("waku_deleteKeyPair") do(id: Identifier) -> bool: rpcsrv.rpc("waku_deleteKeyPair") do(id: Identifier) -> bool:
## Deletes the specifies key if it exists. ## Deletes the specifies key if it exists.

View File

@ -81,8 +81,7 @@ proc setupWhisperRPC*(node: EthereumNode, keys: KeyStorage, rpcsrv: RpcServer) =
## Returns key identifier on success and an error on failure. ## Returns key identifier on success and an error on failure.
result = generateRandomID().Identifier result = generateRandomID().Identifier
keys.asymKeys.add(result.string, KeyPair(seckey: key, keys.asymKeys.add(result.string, key.toKeyPair())
pubkey: key.getPublicKey()))
rpcsrv.rpc("shh_deleteKeyPair") do(id: Identifier) -> bool: rpcsrv.rpc("shh_deleteKeyPair") do(id: Identifier) -> bool:
## Deletes the specifies key if it exists. ## Deletes the specifies key if it exists.
@ -283,22 +282,18 @@ proc setupWhisperRPC*(node: EthereumNode, keys: KeyStorage, rpcsrv: RpcServer) =
## Returns array of messages on success and an error on failure. ## Returns array of messages on success and an error on failure.
let messages = node.getFilterMessages(id.string) let messages = node.getFilterMessages(id.string)
for msg in messages: for msg in messages:
var filterMsg: WhisperFilterMessage result.add WhisperFilterMessage(
sig: msg.decoded.src,
filterMsg.sig = msg.decoded.src recipientPublicKey: msg.dst,
filterMsg.recipientPublicKey = msg.dst ttl: msg.ttl,
filterMsg.ttl = msg.ttl topic: msg.topic,
filterMsg.topic = msg.topic timestamp: msg.timestamp,
filterMsg.timestamp = msg.timestamp payload: msg.decoded.payload,
filterMsg.payload = msg.decoded.payload # Note: whisper_protocol padding is an Option as there is the
# Note: whisper_protocol padding is an Option as there is the # possibility of 0 padding in case of custom padding.
# possibility of 0 padding in case of custom padding. padding: msg.decoded.padding.get(@[]),
if msg.decoded.padding.isSome(): pow: msg.pow,
filterMsg.padding = msg.decoded.padding.get() hash: msg.hash)
filterMsg.pow = msg.pow
filterMsg.hash = msg.hash
result.add(filterMsg)
rpcsrv.rpc("shh_post") do(message: WhisperPostMessage) -> bool: rpcsrv.rpc("shh_post") do(message: WhisperPostMessage) -> bool:
## Creates a whisper message and injects it into the network for ## Creates a whisper message and injects it into the network for

View File

@ -99,7 +99,8 @@ proc nimbus_start(port: uint16, startListening: bool, enableDiscovery: bool,
else: else:
try: try:
let privKey = initPrivateKey(makeOpenArray(privateKey, 32)) let privKey = initPrivateKey(makeOpenArray(privateKey, 32))
keypair = KeyPair(seckey: privKey, pubkey: privKey.getPublicKey()) keypair = privKey.toKeyPair()
except EthKeysException: except EthKeysException:
error "Passed an invalid private key." error "Passed an invalid private key."
return false return false
@ -176,8 +177,8 @@ proc nimbus_add_keypair(privateKey: ptr byte, id: var Identifier):
var keypair: KeyPair var keypair: KeyPair
try: try:
keypair.seckey = initPrivateKey(makeOpenArray(privateKey, 32)) let privKey = initPrivateKey(makeOpenArray(privateKey, 32))
keypair.pubkey = keypair.seckey.getPublicKey() keypair = privKey.toKeyPair()
except EthKeysException, Secp256k1Exception: except EthKeysException, Secp256k1Exception:
error "Passed an invalid private key." error "Passed an invalid private key."
return false return false