2018-11-23 23:58:49 +00:00
|
|
|
import
|
2018-11-26 13:33:06 +00:00
|
|
|
tables, sets,
|
2018-11-29 01:08:34 +00:00
|
|
|
asyncdispatch2, chronicles, rlp, eth_p2p, eth_p2p/rlpx
|
2018-11-23 23:58:49 +00:00
|
|
|
|
|
|
|
type
|
2018-11-26 13:33:06 +00:00
|
|
|
TopicMsgHandler = proc(data: seq[byte]): Future[void]
|
|
|
|
|
2018-11-29 01:08:34 +00:00
|
|
|
GossibSubPeer = ref object
|
|
|
|
sentMessages: HashSet[string]
|
|
|
|
|
|
|
|
GossipSubNetwork = ref object
|
2018-11-26 13:33:06 +00:00
|
|
|
deliveredMessages: Table[Peer, HashSet[string]]
|
|
|
|
topicSubscribers: Table[string, seq[TopicMsgHandler]]
|
2018-11-23 23:58:49 +00:00
|
|
|
|
2018-11-29 01:08:34 +00:00
|
|
|
p2pProtocol GossipSub(version = 1,
|
|
|
|
shortName = "gss",
|
|
|
|
peerState = GossibSubPeer,
|
|
|
|
networkState = GossipSubNetwork):
|
2018-11-26 13:33:06 +00:00
|
|
|
# This is a very barebones emulation of the GossipSub protocol
|
|
|
|
# available in LibP2P:
|
|
|
|
|
2018-11-29 01:08:34 +00:00
|
|
|
proc interestedIn(peer: Peer, topic: string)
|
|
|
|
proc emit(peer: Peer, topic: string, msgId: string, data: openarray[byte])
|
2018-11-26 13:33:06 +00:00
|
|
|
|
|
|
|
proc subscribeImpl(node: EthereumNode,
|
|
|
|
topic: string,
|
|
|
|
subscriber: TopicMsgHandler) =
|
|
|
|
discard
|
|
|
|
|
|
|
|
proc broadcastImpl(node: EthereumNode, topic: string, data: seq[byte]) =
|
|
|
|
discard
|
|
|
|
|
2018-11-29 01:08:34 +00:00
|
|
|
macro subscribe*(node: EthereumNode, topic: string, handler: untyped): untyped =
|
2018-11-26 13:33:06 +00:00
|
|
|
discard
|
|
|
|
|
2018-11-29 01:08:34 +00:00
|
|
|
proc broadcast*(node: EthereumNode, topic: string, data: auto) {.async.} =
|
2018-11-26 13:33:06 +00:00
|
|
|
discard
|
2018-11-23 23:58:49 +00:00
|
|
|
|