signed-peer-record transfer integrated with pubsub rpc message trasfer

This commit is contained in:
lla-dane
2025-08-11 18:27:11 +05:30
parent 5c11ac20e7
commit 56526b4870
6 changed files with 266 additions and 346 deletions

View File

@ -15,6 +15,7 @@ from libp2p.custom_types import (
from libp2p.peer.id import (
ID,
)
from libp2p.peer.peerstore import create_signed_peer_record
from .exceptions import (
PubsubRouterError,
@ -103,6 +104,15 @@ class FloodSub(IPubsubRouter):
)
rpc_msg = rpc_pb2.RPC(publish=[pubsub_msg])
# Add the senderRecord of the peer in the RPC msg
if isinstance(self.pubsub, Pubsub):
envelope = create_signed_peer_record(
self.pubsub.host.get_id(),
self.pubsub.host.get_addrs(),
self.pubsub.host.get_private_key(),
)
rpc_msg.senderRecord = envelope.marshal_envelope()
logger.debug("publishing message %s", pubsub_msg)
if self.pubsub is None: