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.
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:
## 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.
result = generateRandomID().Identifier
keys.asymKeys.add(result.string, KeyPair(seckey: key,
pubkey: key.getPublicKey()))
keys.asymKeys.add(result.string, key.toKeyPair())
rpcsrv.rpc("shh_deleteKeyPair") do(id: Identifier) -> bool:
## 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.
let messages = node.getFilterMessages(id.string)
for msg in messages:
var filterMsg: WhisperFilterMessage
filterMsg.sig = msg.decoded.src
filterMsg.recipientPublicKey = msg.dst
filterMsg.ttl = msg.ttl
filterMsg.topic = msg.topic
filterMsg.timestamp = msg.timestamp
filterMsg.payload = msg.decoded.payload
# Note: whisper_protocol padding is an Option as there is the
# possibility of 0 padding in case of custom padding.
if msg.decoded.padding.isSome():
filterMsg.padding = msg.decoded.padding.get()
filterMsg.pow = msg.pow
filterMsg.hash = msg.hash
result.add(filterMsg)
result.add WhisperFilterMessage(
sig: msg.decoded.src,
recipientPublicKey: msg.dst,
ttl: msg.ttl,
topic: msg.topic,
timestamp: msg.timestamp,
payload: msg.decoded.payload,
# Note: whisper_protocol padding is an Option as there is the
# possibility of 0 padding in case of custom padding.
padding: msg.decoded.padding.get(@[]),
pow: msg.pow,
hash: msg.hash)
rpcsrv.rpc("shh_post") do(message: WhisperPostMessage) -> bool:
## 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:
try:
let privKey = initPrivateKey(makeOpenArray(privateKey, 32))
keypair = KeyPair(seckey: privKey, pubkey: privKey.getPublicKey())
keypair = privKey.toKeyPair()
except EthKeysException:
error "Passed an invalid private key."
return false
@ -176,8 +177,8 @@ proc nimbus_add_keypair(privateKey: ptr byte, id: var Identifier):
var keypair: KeyPair
try:
keypair.seckey = initPrivateKey(makeOpenArray(privateKey, 32))
keypair.pubkey = keypair.seckey.getPublicKey()
let privKey = initPrivateKey(makeOpenArray(privateKey, 32))
keypair = privKey.toKeyPair()
except EthKeysException, Secp256k1Exception:
error "Passed an invalid private key."
return false