Temp modified publish
This commit is contained in:
parent
218bdb42c4
commit
b528c211b9
|
@ -46,7 +46,7 @@ class FloodSub(IPubsubRouter):
|
||||||
:param rpc: rpc message
|
:param rpc: rpc message
|
||||||
"""
|
"""
|
||||||
|
|
||||||
async def publish(self, sender_peer_id: ID, rpc_message: rpc_pb2.Message) -> None:
|
async def publish(self, from_peer: ID, pubsub_message: rpc_pb2.Message) -> None:
|
||||||
"""
|
"""
|
||||||
Invoked to forward a new message that has been validated.
|
Invoked to forward a new message that has been validated.
|
||||||
This is where the "flooding" part of floodsub happens
|
This is where the "flooding" part of floodsub happens
|
||||||
|
@ -60,9 +60,14 @@ class FloodSub(IPubsubRouter):
|
||||||
:param sender_peer_id: peer_id of message sender
|
:param sender_peer_id: peer_id of message sender
|
||||||
:param rpc_message: pubsub message in RPC string format
|
:param rpc_message: pubsub message in RPC string format
|
||||||
"""
|
"""
|
||||||
packet = rpc_pb2.RPC()
|
# packet = rpc_pb2.RPC()
|
||||||
packet.ParseFromString(rpc_message)
|
# packet.ParseFromString(rpc_message)
|
||||||
msg_sender = str(sender_peer_id)
|
|
||||||
|
from_peer_str = str(from_peer)
|
||||||
|
for topic in pubsub_message.topicIDs:
|
||||||
|
if topic not in self.pubsub.topics:
|
||||||
|
continue
|
||||||
|
peers = self.pubsub.peer_topics[topic]
|
||||||
# Deliver to self if self was origin
|
# Deliver to self if self was origin
|
||||||
# Note: handle_talk checks if self is subscribed to topics in message
|
# Note: handle_talk checks if self is subscribed to topics in message
|
||||||
for message in packet.publish:
|
for message in packet.publish:
|
||||||
|
|
|
@ -341,16 +341,23 @@ class Pubsub:
|
||||||
from_id=self.host.get_id().to_bytes(),
|
from_id=self.host.get_id().to_bytes(),
|
||||||
seqno=self._next_seqno(),
|
seqno=self._next_seqno(),
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: Sign with our signing key
|
# TODO: Sign with our signing key
|
||||||
|
|
||||||
self.push_msg(self.host.get_id(), msg)
|
self.push_msg(self.host.get_id(), msg)
|
||||||
|
|
||||||
async def push_msg(self, src: ID, msg: rpc_pb2.Message):
|
async def push_msg(self, src: ID, msg: rpc_pb2.Message):
|
||||||
# TODO: - Check if the source is in the blacklist. If yes, reject.
|
# TODO: - Check if the source is in the blacklist. If yes, reject.
|
||||||
|
|
||||||
# TODO: - Check if the `from` is in the blacklist. If yes, reject.
|
# TODO: - Check if the `from` is in the blacklist. If yes, reject.
|
||||||
|
|
||||||
# TODO: - Check if signing is required and if so signature should be attached.
|
# TODO: - Check if signing is required and if so signature should be attached.
|
||||||
|
|
||||||
if self._is_msg_seen(msg):
|
if self._is_msg_seen(msg):
|
||||||
return
|
return
|
||||||
|
|
||||||
# TODO: - Validate the message. If failed, reject it.
|
# TODO: - Validate the message. If failed, reject it.
|
||||||
|
|
||||||
self._mark_msg_seen(msg)
|
self._mark_msg_seen(msg)
|
||||||
await self.handle_talk(msg)
|
await self.handle_talk(msg)
|
||||||
await self.router.publish(src, msg)
|
await self.router.publish(src, msg)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user