mirror of https://github.com/waku-org/nwaku.git
Refactor: waku_types separation of concern (trial with waku_swap) (#282)
* waku_types refactor: Accounting types to waku_swap * waku_types refactor: Separate waku_swap_types file * Fix import path for waku_swap
This commit is contained in:
parent
f8aff5756c
commit
54ac399f5f
|
@ -11,7 +11,8 @@ import
|
|||
libp2p/transports/transport,
|
||||
libp2p/transports/tcptransport,
|
||||
eth/keys,
|
||||
../../waku/v2/protocol/[waku_store, message_notifier, waku_swap],
|
||||
../../waku/v2/protocol/[waku_store, message_notifier],
|
||||
../../waku/v2/protocol/waku_swap/waku_swap,
|
||||
../../waku/v2/node/message_store,
|
||||
../../waku/v2/node/wakunode2,
|
||||
../test_helpers, ./utils,
|
||||
|
|
|
@ -10,7 +10,8 @@ import
|
|||
libp2p/protocols/pubsub/pubsub,
|
||||
libp2p/peerinfo,
|
||||
libp2p/standard_setup,
|
||||
../protocol/[waku_relay, waku_store, waku_filter, waku_swap, message_notifier],
|
||||
../protocol/[waku_relay, waku_store, waku_filter, message_notifier],
|
||||
../protocol/waku_swap/waku_swap,
|
||||
../waku_types,
|
||||
./message_store
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import
|
|||
libp2p/stream/connection,
|
||||
./message_notifier,
|
||||
../node/message_store,
|
||||
waku_swap/waku_swap,
|
||||
../waku_types
|
||||
|
||||
logScope:
|
||||
|
|
|
@ -30,10 +30,10 @@ import
|
|||
libp2p/protocols/protocol,
|
||||
libp2p/protobuf/minprotobuf,
|
||||
libp2p/stream/connection,
|
||||
./message_notifier,
|
||||
../waku_types
|
||||
../message_notifier,
|
||||
waku_swap_types
|
||||
|
||||
export waku_types
|
||||
export waku_swap_types
|
||||
|
||||
logScope:
|
||||
topics = "wakuswap"
|
|
@ -0,0 +1,28 @@
|
|||
import
|
||||
std/tables,
|
||||
bearssl,
|
||||
libp2p/protocols/protocol,
|
||||
libp2p/switch,
|
||||
libp2p/peerinfo
|
||||
|
||||
type
|
||||
Beneficiary* = seq[byte]
|
||||
|
||||
# TODO Consider adding payment threshhold and terms field
|
||||
Handshake* = object
|
||||
beneficiary*: Beneficiary
|
||||
|
||||
Cheque* = object
|
||||
beneficiary*: Beneficiary
|
||||
date*: uint32
|
||||
amount*: uint32
|
||||
|
||||
AccountHandler* = proc (peerId: PeerId, amount: int) {.gcsafe, closure.}
|
||||
|
||||
WakuSwap* = ref object of LPProtocol
|
||||
switch*: Switch
|
||||
rng*: ref BrHmacDrbgContext
|
||||
#peers*: seq[PeerInfo]
|
||||
text*: string
|
||||
accounting*: Table[PeerId, int]
|
||||
accountFor*: AccountHandler
|
|
@ -11,6 +11,7 @@ import
|
|||
libp2p/switch,
|
||||
libp2p/stream/connection,
|
||||
libp2p/protocols/pubsub/[pubsub, gossipsub],
|
||||
protocol/waku_swap/waku_swap_types,
|
||||
nimcrypto/sha2,
|
||||
sqlite3_abi
|
||||
|
||||
|
@ -40,7 +41,6 @@ type
|
|||
|
||||
QueryHandlerFunc* = proc(response: HistoryResponse) {.gcsafe, closure.}
|
||||
|
||||
|
||||
Index* = object
|
||||
## This type contains the description of an Index used in the pagination of WakuMessages
|
||||
digest*: MDigest[256]
|
||||
|
@ -134,16 +134,6 @@ type
|
|||
# @TODO MAYBE MORE INFO?
|
||||
Filters* = Table[string, Filter]
|
||||
|
||||
AccountHandler* = proc (peerId: PeerId, amount: int) {.gcsafe, closure.}
|
||||
|
||||
WakuSwap* = ref object of LPProtocol
|
||||
switch*: Switch
|
||||
rng*: ref BrHmacDrbgContext
|
||||
#peers*: seq[PeerInfo]
|
||||
text*: string
|
||||
accounting*: Table[PeerId, int]
|
||||
accountFor*: AccountHandler
|
||||
|
||||
# NOTE based on Eth2Node in NBC eth2_network.nim
|
||||
WakuNode* = ref object of RootObj
|
||||
switch*: Switch
|
||||
|
@ -169,20 +159,6 @@ type
|
|||
|
||||
WakuResult*[T] = Result[T, cstring]
|
||||
|
||||
Beneficiary* = seq[byte]
|
||||
|
||||
# TODO Consider adding payment threshhold and terms field
|
||||
Handshake* = object
|
||||
beneficiary*: Beneficiary
|
||||
|
||||
Cheque* = object
|
||||
beneficiary*: Beneficiary
|
||||
date*: uint32
|
||||
amount*: uint32
|
||||
|
||||
AccountUpdateFunc* = proc(peerId: PeerId, amount: int) {.gcsafe.}
|
||||
|
||||
|
||||
# Encoding and decoding -------------------------------------------------------
|
||||
# TODO Move out to to waku_message module
|
||||
# Possibly same with util functions
|
||||
|
|
Loading…
Reference in New Issue