From 3f3c4249ba1a2cb8d7ccdb45f8b2aee2f36066c0 Mon Sep 17 00:00:00 2001 From: coffeepots Date: Tue, 21 Aug 2018 22:21:41 +0100 Subject: [PATCH] Add Whisper types --- nimbus/rpc/rpc_types.nim | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/nimbus/rpc/rpc_types.nim b/nimbus/rpc/rpc_types.nim index 050f04e46..c9bb7e4d7 100644 --- a/nimbus/rpc/rpc_types.nim +++ b/nimbus/rpc/rpc_types.nim @@ -105,3 +105,40 @@ type root*: Hash256 # post-transaction stateroot (pre Byzantium). status*: int # 1 = success, 0 = failure. + FilterDataKind* = enum fkItem, fkList + FilterData* = object + # Difficult to process variant objects in input data, as kind is immutable. + # TODO: This might need more work to handle "or" options + kind*: FilterDataKind + items*: seq[FilterData] + item*: UInt256 + + FilterOptions* = object + # Parameter from user + fromBlock*: string # (optional, default: "latest") integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions. + toBlock*: string # (optional, default: "latest") integer block number, or "latest" for the last mined block or "pending", "earliest" for not yet mined transactions. + address*: EthAddress # (optional) contract address or a list of addresses from which logs should originate. + topics*: seq[FilterData] # (optional) list of DATA topics. Topics are order-dependent. Each topic can also be a list of DATA with "or" options. + + WhisperPost* = object + # Parameter from user + source*: WhisperIdentityStr # (optional) the identity of the sender. + to*: WhisperIdentityStr # (optional) the identity of the receiver. When present whisper will encrypt the message so that only the receiver can decrypt it. + topics*: seq[HexDataStr] # list of DATA topics, for the receiver to identify messages. + payload*: HexDataStr # the payload of the message. + priority*: int # integer of the priority in a rang from. + ttl*: int # integer of the time to live in seconds. + + WhisperIdentity = array[60, byte] + + WhisperMessage* = object + # Returned to user + hash*: Hash256 # the hash of the message. + source*: WhisperIdentity # the sender of the message, if a sender was specified. + to*: WhisperIdentity # the receiver of the message, if a receiver was specified. + expiry*: int # integer of the time in seconds when this message should expire. + ttl*: int # integer of the time the message should float in the system in seconds. + sent*: int # integer of the unix timestamp when the message was sent. + topics*: seq[UInt256] # list of DATA topics the message contained. + payload*: Blob # the payload of the message. + workProved*: int # integer of the work this message required before it was send.