diff --git a/libp2p/pubsub/pb/rpc.proto b/libp2p/pubsub/pb/rpc.proto index f07da200..df38bad4 100644 --- a/libp2p/pubsub/pb/rpc.proto +++ b/libp2p/pubsub/pb/rpc.proto @@ -1,3 +1,5 @@ +// Modified from https://github.com/libp2p/go-libp2p-pubsub/blob/master/pb/rpc.proto + syntax = "proto2"; package pubsub.pb; diff --git a/libp2p/pubsub/pubsub.py b/libp2p/pubsub/pubsub.py index d8fb3c00..40c4036e 100644 --- a/libp2p/pubsub/pubsub.py +++ b/libp2p/pubsub/pubsub.py @@ -1,5 +1,4 @@ import asyncio -import uuid from .pb import rpc_pb2 from .pubsub_notifee import PubsubNotifee @@ -203,10 +202,6 @@ class Pubsub(): # Create subscribe message packet = rpc_pb2.RPC() - # packet.publish.extend([rpc_pb2.Message( - # from_id=str(self.host.get_id()).encode('utf-8'), - # seqno=str(generate_message_id()).encode('utf-8') - # )]) packet.subscriptions.extend([rpc_pb2.RPC.SubOpts( subscribe=True, topicid=topic_id.encode('utf-8') @@ -256,10 +251,3 @@ class Pubsub(): # Write message to stream await stream.write(rpc_msg) - -def generate_message_id(): - """ - Generate a unique message id - :return: messgae id - """ - return str(uuid.uuid1()) diff --git a/rpc.proto b/rpc.proto deleted file mode 100644 index 2ae2ef2a..00000000 --- a/rpc.proto +++ /dev/null @@ -1,78 +0,0 @@ -// Borrowed from https://github.com/libp2p/go-libp2p-pubsub/blob/master/pb/rpc.proto - -syntax = "proto2"; - -package pubsub.pb; - -message RPC { - repeated SubOpts subscriptions = 1; - repeated Message publish = 2; - - message SubOpts { - optional bool subscribe = 1; // subscribe or unsubcribe - optional string topicid = 2; - } - - optional ControlMessage control = 3; -} - -message Message { - optional bytes from = 1; - optional bytes data = 2; - optional bytes seqno = 3; - repeated string topicIDs = 4; - optional bytes signature = 5; - optional bytes key = 6; -} - -message ControlMessage { - repeated ControlIHave ihave = 1; - repeated ControlIWant iwant = 2; - repeated ControlGraft graft = 3; - repeated ControlPrune prune = 4; -} - -message ControlIHave { - optional string topicID = 1; - repeated string messageIDs = 2; -} - -message ControlIWant { - repeated string messageIDs = 1; -} - -message ControlGraft { - optional string topicID = 1; -} - -message ControlPrune { - optional string topicID = 1; -} - -message TopicDescriptor { - optional string name = 1; - optional AuthOpts auth = 2; - optional EncOpts enc = 3; - - message AuthOpts { - optional AuthMode mode = 1; - repeated bytes keys = 2; // root keys to trust - - enum AuthMode { - NONE = 0; // no authentication, anyone can publish - KEY = 1; // only messages signed by keys in the topic descriptor are accepted - WOT = 2; // web of trust, certificates can allow publisher set to grow - } - } - - message EncOpts { - optional EncMode mode = 1; - repeated bytes keyHashes = 2; // the hashes of the shared keys used (salted) - - enum EncMode { - NONE = 0; // no encryption, anyone can read - SHAREDKEY = 1; // messages are encrypted with shared key - WOT = 2; // web of trust, certificates can allow publisher set to grow - } - } -} \ No newline at end of file diff --git a/tests/pubsub/test_floodsub.py b/tests/pubsub/test_floodsub.py index 2d4ed8d0..69b2f8cc 100644 --- a/tests/pubsub/test_floodsub.py +++ b/tests/pubsub/test_floodsub.py @@ -55,8 +55,6 @@ async def test_simple_two_nodes_RPC(): # as the message sent by node_a assert res_b.SerializeToString() == msg.publish[0].SerializeToString() - - # Success, terminate pending tasks. await cleanup()