diff --git a/core/Cargo.toml b/core/Cargo.toml index 2b3a7cfc96b..2fd64f54cc5 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -23,7 +23,7 @@ multihash = { package = "parity-multihash", version = "0.1.0", path = "../misc/m multistream-select = { version = "0.5.0", path = "../misc/multistream-select" } futures = "0.1" parking_lot = "0.8" -protobuf = "2.3" +protobuf = "2.8" quick-error = "1.2" rand = "0.6" rw-stream-sink = { version = "0.1.1", path = "../misc/rw-stream-sink" } diff --git a/core/regen_structs_proto.sh b/core/regen_structs_proto.sh index 7a0caead6c5..0dd24a5402f 100755 --- a/core/regen_structs_proto.sh +++ b/core/regen_structs_proto.sh @@ -1,13 +1,3 @@ #!/bin/sh -# This script regenerates the `src/structs_proto.rs` and `src/keys_proto.rs` files from -# `structs.proto` and `keys.proto`. - -sudo docker run --rm -v `pwd`:/usr/code:z -w /usr/code rust /bin/bash -c " \ - apt-get update; \ - apt-get install -y protobuf-compiler; \ - cargo install --version 2.3.0 protobuf-codegen; \ - protoc --rust_out . keys.proto" - -sudo chown $USER:$USER keys.rs -mv -f keys.rs ./src/keys_proto.rs +../scripts/protobuf/gen.sh src/keys.proto diff --git a/core/keys.proto b/core/src/keys.proto similarity index 91% rename from core/keys.proto rename to core/src/keys.proto index 786c7a74251..ac0bca8bcdd 100644 --- a/core/keys.proto +++ b/core/src/keys.proto @@ -1,3 +1,5 @@ +syntax = "proto2"; + enum KeyType { RSA = 0; Ed25519 = 1; diff --git a/core/src/keys_proto.rs b/core/src/keys_proto.rs index f7460bd446d..9afba37130b 100644 --- a/core/src/keys_proto.rs +++ b/core/src/keys_proto.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 2.3.0. Do not edit +// This file is generated by rust-protobuf 2.8.1. Do not edit // @generated // https://github.com/Manishearth/rust-clippy/issues/702 @@ -17,10 +17,15 @@ #![allow(unsafe_code)] #![allow(unused_imports)] #![allow(unused_results)] +//! Generated file from `src/keys.proto` use protobuf::Message as Message_imported_for_functions; use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_8_1; + #[derive(PartialEq,Clone,Default)] pub struct PublicKey { // message fields @@ -31,6 +36,12 @@ pub struct PublicKey { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a PublicKey { + fn default() -> &'a PublicKey { + ::default_instance() + } +} + impl PublicKey { pub fn new() -> PublicKey { ::std::default::Default::default() @@ -38,6 +49,10 @@ impl PublicKey { // required .KeyType Type = 1; + + pub fn get_Type(&self) -> KeyType { + self.Type.unwrap_or(KeyType::RSA) + } pub fn clear_Type(&mut self) { self.Type = ::std::option::Option::None; } @@ -51,12 +66,15 @@ impl PublicKey { self.Type = ::std::option::Option::Some(v); } - pub fn get_Type(&self) -> KeyType { - self.Type.unwrap_or(KeyType::RSA) - } - // required bytes Data = 2; + + pub fn get_Data(&self) -> &[u8] { + match self.Data.as_ref() { + Some(v) => &v, + None => &[], + } + } pub fn clear_Data(&mut self) { self.Data.clear(); } @@ -83,13 +101,6 @@ impl PublicKey { pub fn take_Data(&mut self) -> ::std::vec::Vec { self.Data.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - - pub fn get_Data(&self) -> &[u8] { - match self.Data.as_ref() { - Some(v) => &v, - None => &[], - } - } } impl ::protobuf::Message for PublicKey { @@ -217,8 +228,8 @@ impl ::protobuf::Message for PublicKey { impl ::protobuf::Clear for PublicKey { fn clear(&mut self) { - self.clear_Type(); - self.clear_Data(); + self.Type = ::std::option::Option::None; + self.Data.clear(); self.unknown_fields.clear(); } } @@ -230,7 +241,7 @@ impl ::std::fmt::Debug for PublicKey { } impl ::protobuf::reflect::ProtobufValue for PublicKey { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Message(self) } } @@ -245,6 +256,12 @@ pub struct PrivateKey { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a PrivateKey { + fn default() -> &'a PrivateKey { + ::default_instance() + } +} + impl PrivateKey { pub fn new() -> PrivateKey { ::std::default::Default::default() @@ -252,6 +269,10 @@ impl PrivateKey { // required .KeyType Type = 1; + + pub fn get_Type(&self) -> KeyType { + self.Type.unwrap_or(KeyType::RSA) + } pub fn clear_Type(&mut self) { self.Type = ::std::option::Option::None; } @@ -265,12 +286,15 @@ impl PrivateKey { self.Type = ::std::option::Option::Some(v); } - pub fn get_Type(&self) -> KeyType { - self.Type.unwrap_or(KeyType::RSA) - } - // required bytes Data = 2; + + pub fn get_Data(&self) -> &[u8] { + match self.Data.as_ref() { + Some(v) => &v, + None => &[], + } + } pub fn clear_Data(&mut self) { self.Data.clear(); } @@ -297,13 +321,6 @@ impl PrivateKey { pub fn take_Data(&mut self) -> ::std::vec::Vec { self.Data.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - - pub fn get_Data(&self) -> &[u8] { - match self.Data.as_ref() { - Some(v) => &v, - None => &[], - } - } } impl ::protobuf::Message for PrivateKey { @@ -431,8 +448,8 @@ impl ::protobuf::Message for PrivateKey { impl ::protobuf::Clear for PrivateKey { fn clear(&mut self) { - self.clear_Type(); - self.clear_Data(); + self.Type = ::std::option::Option::None; + self.Data.clear(); self.unknown_fields.clear(); } } @@ -444,7 +461,7 @@ impl ::std::fmt::Debug for PrivateKey { } impl ::protobuf::reflect::ProtobufValue for PrivateKey { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Message(self) } } @@ -502,41 +519,41 @@ impl ::std::default::Default for KeyType { } impl ::protobuf::reflect::ProtobufValue for KeyType { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) } } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\nkeys.proto\"=\n\tPublicKey\x12\x1c\n\x04Type\x18\x01\x20\x02(\x0e2\ - \x08.KeyTypeR\x04type\x12\x12\n\x04Data\x18\x02\x20\x02(\x0cR\x04data\">\ - \n\nPrivateKey\x12\x1c\n\x04Type\x18\x01\x20\x02(\x0e2\x08.KeyTypeR\x04t\ - ype\x12\x12\n\x04Data\x18\x02\x20\x02(\x0cR\x04data*.\n\x07KeyType\x12\ - \x07\n\x03RSA\x10\0\x12\x0b\n\x07Ed25519\x10\x01\x12\r\n\tSecp256k1\x10\ - \x02J\xdf\x03\n\x06\x12\x04\0\0\x0e\x01\n\n\n\x02\x05\0\x12\x04\0\0\x04\ - \x01\n\n\n\x03\x05\0\x01\x12\x03\0\x05\x0c\n\x0b\n\x04\x05\0\x02\0\x12\ - \x03\x01\x02\n\n\x0c\n\x05\x05\0\x02\0\x01\x12\x03\x01\x02\x05\n\x0c\n\ - \x05\x05\0\x02\0\x02\x12\x03\x01\x08\t\n\x0b\n\x04\x05\0\x02\x01\x12\x03\ - \x02\x02\x0e\n\x0c\n\x05\x05\0\x02\x01\x01\x12\x03\x02\x02\t\n\x0c\n\x05\ - \x05\0\x02\x01\x02\x12\x03\x02\x0c\r\n\x0b\n\x04\x05\0\x02\x02\x12\x03\ - \x03\x02\x10\n\x0c\n\x05\x05\0\x02\x02\x01\x12\x03\x03\x02\x0b\n\x0c\n\ - \x05\x05\0\x02\x02\x02\x12\x03\x03\x0e\x0f\n\n\n\x02\x04\0\x12\x04\x06\0\ - \t\x01\n\n\n\x03\x04\0\x01\x12\x03\x06\x08\x11\n\x0b\n\x04\x04\0\x02\0\ - \x12\x03\x07\x02\x1c\n\x0c\n\x05\x04\0\x02\0\x04\x12\x03\x07\x02\n\n\x0c\ - \n\x05\x04\0\x02\0\x06\x12\x03\x07\x0b\x12\n\x0c\n\x05\x04\0\x02\0\x01\ - \x12\x03\x07\x13\x17\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x07\x1a\x1b\n\ - \x0b\n\x04\x04\0\x02\x01\x12\x03\x08\x02\x1a\n\x0c\n\x05\x04\0\x02\x01\ - \x04\x12\x03\x08\x02\n\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x08\x0b\x10\ - \n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x08\x11\x15\n\x0c\n\x05\x04\0\x02\ - \x01\x03\x12\x03\x08\x18\x19\n\n\n\x02\x04\x01\x12\x04\x0b\0\x0e\x01\n\n\ - \n\x03\x04\x01\x01\x12\x03\x0b\x08\x12\n\x0b\n\x04\x04\x01\x02\0\x12\x03\ - \x0c\x02\x1c\n\x0c\n\x05\x04\x01\x02\0\x04\x12\x03\x0c\x02\n\n\x0c\n\x05\ - \x04\x01\x02\0\x06\x12\x03\x0c\x0b\x12\n\x0c\n\x05\x04\x01\x02\0\x01\x12\ - \x03\x0c\x13\x17\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\x0c\x1a\x1b\n\x0b\ - \n\x04\x04\x01\x02\x01\x12\x03\r\x02\x1a\n\x0c\n\x05\x04\x01\x02\x01\x04\ - \x12\x03\r\x02\n\n\x0c\n\x05\x04\x01\x02\x01\x05\x12\x03\r\x0b\x10\n\x0c\ - \n\x05\x04\x01\x02\x01\x01\x12\x03\r\x11\x15\n\x0c\n\x05\x04\x01\x02\x01\ - \x03\x12\x03\r\x18\x19\ + \n\x0esrc/keys.proto\"=\n\tPublicKey\x12\x1c\n\x04Type\x18\x01\x20\x02(\ + \x0e2\x08.KeyTypeR\x04Type\x12\x12\n\x04Data\x18\x02\x20\x02(\x0cR\x04Da\ + ta\">\n\nPrivateKey\x12\x1c\n\x04Type\x18\x01\x20\x02(\x0e2\x08.KeyTypeR\ + \x04Type\x12\x12\n\x04Data\x18\x02\x20\x02(\x0cR\x04Data*.\n\x07KeyType\ + \x12\x07\n\x03RSA\x10\0\x12\x0b\n\x07Ed25519\x10\x01\x12\r\n\tSecp256k1\ + \x10\x02J\xe9\x03\n\x06\x12\x04\0\0\x10\x01\n\x08\n\x01\x0c\x12\x03\0\0\ + \x12\n\n\n\x02\x05\0\x12\x04\x02\0\x06\x01\n\n\n\x03\x05\0\x01\x12\x03\ + \x02\x05\x0c\n\x0b\n\x04\x05\0\x02\0\x12\x03\x03\x02\n\n\x0c\n\x05\x05\0\ + \x02\0\x01\x12\x03\x03\x02\x05\n\x0c\n\x05\x05\0\x02\0\x02\x12\x03\x03\ + \x08\t\n\x0b\n\x04\x05\0\x02\x01\x12\x03\x04\x02\x0e\n\x0c\n\x05\x05\0\ + \x02\x01\x01\x12\x03\x04\x02\t\n\x0c\n\x05\x05\0\x02\x01\x02\x12\x03\x04\ + \x0c\r\n\x0b\n\x04\x05\0\x02\x02\x12\x03\x05\x02\x10\n\x0c\n\x05\x05\0\ + \x02\x02\x01\x12\x03\x05\x02\x0b\n\x0c\n\x05\x05\0\x02\x02\x02\x12\x03\ + \x05\x0e\x0f\n\n\n\x02\x04\0\x12\x04\x08\0\x0b\x01\n\n\n\x03\x04\0\x01\ + \x12\x03\x08\x08\x11\n\x0b\n\x04\x04\0\x02\0\x12\x03\t\x02\x1c\n\x0c\n\ + \x05\x04\0\x02\0\x04\x12\x03\t\x02\n\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\ + \t\x0b\x12\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\t\x13\x17\n\x0c\n\x05\x04\ + \0\x02\0\x03\x12\x03\t\x1a\x1b\n\x0b\n\x04\x04\0\x02\x01\x12\x03\n\x02\ + \x1a\n\x0c\n\x05\x04\0\x02\x01\x04\x12\x03\n\x02\n\n\x0c\n\x05\x04\0\x02\ + \x01\x05\x12\x03\n\x0b\x10\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\n\x11\ + \x15\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\n\x18\x19\n\n\n\x02\x04\x01\ + \x12\x04\r\0\x10\x01\n\n\n\x03\x04\x01\x01\x12\x03\r\x08\x12\n\x0b\n\x04\ + \x04\x01\x02\0\x12\x03\x0e\x02\x1c\n\x0c\n\x05\x04\x01\x02\0\x04\x12\x03\ + \x0e\x02\n\n\x0c\n\x05\x04\x01\x02\0\x06\x12\x03\x0e\x0b\x12\n\x0c\n\x05\ + \x04\x01\x02\0\x01\x12\x03\x0e\x13\x17\n\x0c\n\x05\x04\x01\x02\0\x03\x12\ + \x03\x0e\x1a\x1b\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\x0f\x02\x1a\n\x0c\n\ + \x05\x04\x01\x02\x01\x04\x12\x03\x0f\x02\n\n\x0c\n\x05\x04\x01\x02\x01\ + \x05\x12\x03\x0f\x0b\x10\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\x0f\x11\ + \x15\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\x0f\x18\x19\ "; static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { diff --git a/protocols/floodsub/Cargo.toml b/protocols/floodsub/Cargo.toml index 87ba4ab0403..08ebce8ffaa 100644 --- a/protocols/floodsub/Cargo.toml +++ b/protocols/floodsub/Cargo.toml @@ -17,7 +17,7 @@ fnv = "1.0" futures = "0.1" libp2p-core = { version = "0.12.0", path = "../../core" } libp2p-swarm = { version = "0.2.0", path = "../../swarm" } -protobuf = "2.3" +protobuf = "2.8" rand = "0.6" smallvec = "0.6.5" tokio-io = "0.1" diff --git a/protocols/floodsub/regen_structs_proto.sh b/protocols/floodsub/regen_structs_proto.sh index fa7048178ae..95a6bda2674 100755 --- a/protocols/floodsub/regen_structs_proto.sh +++ b/protocols/floodsub/regen_structs_proto.sh @@ -1,13 +1,3 @@ #!/bin/sh -# This script regenerates the `src/rpc_proto.rs` file from `rpc.proto`. - -docker run --rm -v `pwd`:/usr/code:z -w /usr/code rust /bin/bash -c " \ - apt-get update; \ - apt-get install -y protobuf-compiler; \ - cargo install --version 2.3.0 protobuf-codegen; \ - protoc --rust_out . rpc.proto" - -sudo chown $USER:$USER *.rs - -mv -f rpc.rs ./src/rpc_proto.rs +../../scripts/protobuf/gen.sh src/rpc.proto diff --git a/protocols/floodsub/rpc.proto b/protocols/floodsub/src/rpc.proto similarity index 98% rename from protocols/floodsub/rpc.proto rename to protocols/floodsub/src/rpc.proto index f43d3c16332..08d137ade55 100644 --- a/protocols/floodsub/rpc.proto +++ b/protocols/floodsub/src/rpc.proto @@ -1,3 +1,5 @@ +syntax = "proto2"; + package floodsub.pb; message RPC { diff --git a/protocols/floodsub/src/rpc_proto.rs b/protocols/floodsub/src/rpc_proto.rs index 2cfc54e4caf..522d097c08e 100644 --- a/protocols/floodsub/src/rpc_proto.rs +++ b/protocols/floodsub/src/rpc_proto.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 2.3.0. Do not edit +// This file is generated by rust-protobuf 2.8.1. Do not edit // @generated // https://github.com/Manishearth/rust-clippy/issues/702 @@ -17,10 +17,15 @@ #![allow(unsafe_code)] #![allow(unused_imports)] #![allow(unused_results)] +//! Generated file from `src/rpc.proto` use protobuf::Message as Message_imported_for_functions; use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_8_1; + #[derive(PartialEq,Clone,Default)] pub struct RPC { // message fields @@ -31,6 +36,12 @@ pub struct RPC { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a RPC { + fn default() -> &'a RPC { + ::default_instance() + } +} + impl RPC { pub fn new() -> RPC { ::std::default::Default::default() @@ -38,6 +49,10 @@ impl RPC { // repeated .floodsub.pb.RPC.SubOpts subscriptions = 1; + + pub fn get_subscriptions(&self) -> &[RPC_SubOpts] { + &self.subscriptions + } pub fn clear_subscriptions(&mut self) { self.subscriptions.clear(); } @@ -57,12 +72,12 @@ impl RPC { ::std::mem::replace(&mut self.subscriptions, ::protobuf::RepeatedField::new()) } - pub fn get_subscriptions(&self) -> &[RPC_SubOpts] { - &self.subscriptions - } - // repeated .floodsub.pb.Message publish = 2; + + pub fn get_publish(&self) -> &[Message] { + &self.publish + } pub fn clear_publish(&mut self) { self.publish.clear(); } @@ -81,10 +96,6 @@ impl RPC { pub fn take_publish(&mut self) -> ::protobuf::RepeatedField { ::std::mem::replace(&mut self.publish, ::protobuf::RepeatedField::new()) } - - pub fn get_publish(&self) -> &[Message] { - &self.publish - } } impl ::protobuf::Message for RPC { @@ -222,8 +233,8 @@ impl ::protobuf::Message for RPC { impl ::protobuf::Clear for RPC { fn clear(&mut self) { - self.clear_subscriptions(); - self.clear_publish(); + self.subscriptions.clear(); + self.publish.clear(); self.unknown_fields.clear(); } } @@ -235,7 +246,7 @@ impl ::std::fmt::Debug for RPC { } impl ::protobuf::reflect::ProtobufValue for RPC { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Message(self) } } @@ -250,6 +261,12 @@ pub struct RPC_SubOpts { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a RPC_SubOpts { + fn default() -> &'a RPC_SubOpts { + ::default_instance() + } +} + impl RPC_SubOpts { pub fn new() -> RPC_SubOpts { ::std::default::Default::default() @@ -257,6 +274,10 @@ impl RPC_SubOpts { // optional bool subscribe = 1; + + pub fn get_subscribe(&self) -> bool { + self.subscribe.unwrap_or(false) + } pub fn clear_subscribe(&mut self) { self.subscribe = ::std::option::Option::None; } @@ -270,12 +291,15 @@ impl RPC_SubOpts { self.subscribe = ::std::option::Option::Some(v); } - pub fn get_subscribe(&self) -> bool { - self.subscribe.unwrap_or(false) - } - // optional string topicid = 2; + + pub fn get_topicid(&self) -> &str { + match self.topicid.as_ref() { + Some(v) => &v, + None => "", + } + } pub fn clear_topicid(&mut self) { self.topicid.clear(); } @@ -302,13 +326,6 @@ impl RPC_SubOpts { pub fn take_topicid(&mut self) -> ::std::string::String { self.topicid.take().unwrap_or_else(|| ::std::string::String::new()) } - - pub fn get_topicid(&self) -> &str { - match self.topicid.as_ref() { - Some(v) => &v, - None => "", - } - } } impl ::protobuf::Message for RPC_SubOpts { @@ -434,8 +451,8 @@ impl ::protobuf::Message for RPC_SubOpts { impl ::protobuf::Clear for RPC_SubOpts { fn clear(&mut self) { - self.clear_subscribe(); - self.clear_topicid(); + self.subscribe = ::std::option::Option::None; + self.topicid.clear(); self.unknown_fields.clear(); } } @@ -447,7 +464,7 @@ impl ::std::fmt::Debug for RPC_SubOpts { } impl ::protobuf::reflect::ProtobufValue for RPC_SubOpts { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Message(self) } } @@ -464,6 +481,12 @@ pub struct Message { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a Message { + fn default() -> &'a Message { + ::default_instance() + } +} + impl Message { pub fn new() -> Message { ::std::default::Default::default() @@ -471,6 +494,13 @@ impl Message { // optional bytes from = 1; + + pub fn get_from(&self) -> &[u8] { + match self.from.as_ref() { + Some(v) => &v, + None => &[], + } + } pub fn clear_from(&mut self) { self.from.clear(); } @@ -498,15 +528,15 @@ impl Message { self.from.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - pub fn get_from(&self) -> &[u8] { - match self.from.as_ref() { + // optional bytes data = 2; + + + pub fn get_data(&self) -> &[u8] { + match self.data.as_ref() { Some(v) => &v, None => &[], } } - - // optional bytes data = 2; - pub fn clear_data(&mut self) { self.data.clear(); } @@ -534,15 +564,15 @@ impl Message { self.data.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - pub fn get_data(&self) -> &[u8] { - match self.data.as_ref() { + // optional bytes seqno = 3; + + + pub fn get_seqno(&self) -> &[u8] { + match self.seqno.as_ref() { Some(v) => &v, None => &[], } } - - // optional bytes seqno = 3; - pub fn clear_seqno(&mut self) { self.seqno.clear(); } @@ -570,15 +600,12 @@ impl Message { self.seqno.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - pub fn get_seqno(&self) -> &[u8] { - match self.seqno.as_ref() { - Some(v) => &v, - None => &[], - } - } - // repeated string topicIDs = 4; + + pub fn get_topicIDs(&self) -> &[::std::string::String] { + &self.topicIDs + } pub fn clear_topicIDs(&mut self) { self.topicIDs.clear(); } @@ -597,10 +624,6 @@ impl Message { pub fn take_topicIDs(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { ::std::mem::replace(&mut self.topicIDs, ::protobuf::RepeatedField::new()) } - - pub fn get_topicIDs(&self) -> &[::std::string::String] { - &self.topicIDs - } } impl ::protobuf::Message for Message { @@ -750,10 +773,10 @@ impl ::protobuf::Message for Message { impl ::protobuf::Clear for Message { fn clear(&mut self) { - self.clear_from(); - self.clear_data(); - self.clear_seqno(); - self.clear_topicIDs(); + self.from.clear(); + self.data.clear(); + self.seqno.clear(); + self.topicIDs.clear(); self.unknown_fields.clear(); } } @@ -765,7 +788,7 @@ impl ::std::fmt::Debug for Message { } impl ::protobuf::reflect::ProtobufValue for Message { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Message(self) } } @@ -781,6 +804,12 @@ pub struct TopicDescriptor { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a TopicDescriptor { + fn default() -> &'a TopicDescriptor { + ::default_instance() + } +} + impl TopicDescriptor { pub fn new() -> TopicDescriptor { ::std::default::Default::default() @@ -788,6 +817,13 @@ impl TopicDescriptor { // optional string name = 1; + + pub fn get_name(&self) -> &str { + match self.name.as_ref() { + Some(v) => &v, + None => "", + } + } pub fn clear_name(&mut self) { self.name.clear(); } @@ -815,15 +851,12 @@ impl TopicDescriptor { self.name.take().unwrap_or_else(|| ::std::string::String::new()) } - pub fn get_name(&self) -> &str { - match self.name.as_ref() { - Some(v) => &v, - None => "", - } - } - // optional .floodsub.pb.TopicDescriptor.AuthOpts auth = 2; + + pub fn get_auth(&self) -> &TopicDescriptor_AuthOpts { + self.auth.as_ref().unwrap_or_else(|| TopicDescriptor_AuthOpts::default_instance()) + } pub fn clear_auth(&mut self) { self.auth.clear(); } @@ -851,12 +884,12 @@ impl TopicDescriptor { self.auth.take().unwrap_or_else(|| TopicDescriptor_AuthOpts::new()) } - pub fn get_auth(&self) -> &TopicDescriptor_AuthOpts { - self.auth.as_ref().unwrap_or_else(|| TopicDescriptor_AuthOpts::default_instance()) - } - // optional .floodsub.pb.TopicDescriptor.EncOpts enc = 3; + + pub fn get_enc(&self) -> &TopicDescriptor_EncOpts { + self.enc.as_ref().unwrap_or_else(|| TopicDescriptor_EncOpts::default_instance()) + } pub fn clear_enc(&mut self) { self.enc.clear(); } @@ -883,10 +916,6 @@ impl TopicDescriptor { pub fn take_enc(&mut self) -> TopicDescriptor_EncOpts { self.enc.take().unwrap_or_else(|| TopicDescriptor_EncOpts::new()) } - - pub fn get_enc(&self) -> &TopicDescriptor_EncOpts { - self.enc.as_ref().unwrap_or_else(|| TopicDescriptor_EncOpts::default_instance()) - } } impl ::protobuf::Message for TopicDescriptor { @@ -1038,9 +1067,9 @@ impl ::protobuf::Message for TopicDescriptor { impl ::protobuf::Clear for TopicDescriptor { fn clear(&mut self) { - self.clear_name(); - self.clear_auth(); - self.clear_enc(); + self.name.clear(); + self.auth.clear(); + self.enc.clear(); self.unknown_fields.clear(); } } @@ -1052,7 +1081,7 @@ impl ::std::fmt::Debug for TopicDescriptor { } impl ::protobuf::reflect::ProtobufValue for TopicDescriptor { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Message(self) } } @@ -1067,6 +1096,12 @@ pub struct TopicDescriptor_AuthOpts { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a TopicDescriptor_AuthOpts { + fn default() -> &'a TopicDescriptor_AuthOpts { + ::default_instance() + } +} + impl TopicDescriptor_AuthOpts { pub fn new() -> TopicDescriptor_AuthOpts { ::std::default::Default::default() @@ -1074,6 +1109,10 @@ impl TopicDescriptor_AuthOpts { // optional .floodsub.pb.TopicDescriptor.AuthOpts.AuthMode mode = 1; + + pub fn get_mode(&self) -> TopicDescriptor_AuthOpts_AuthMode { + self.mode.unwrap_or(TopicDescriptor_AuthOpts_AuthMode::NONE) + } pub fn clear_mode(&mut self) { self.mode = ::std::option::Option::None; } @@ -1087,12 +1126,12 @@ impl TopicDescriptor_AuthOpts { self.mode = ::std::option::Option::Some(v); } - pub fn get_mode(&self) -> TopicDescriptor_AuthOpts_AuthMode { - self.mode.unwrap_or(TopicDescriptor_AuthOpts_AuthMode::NONE) - } - // repeated bytes keys = 2; + + pub fn get_keys(&self) -> &[::std::vec::Vec] { + &self.keys + } pub fn clear_keys(&mut self) { self.keys.clear(); } @@ -1111,10 +1150,6 @@ impl TopicDescriptor_AuthOpts { pub fn take_keys(&mut self) -> ::protobuf::RepeatedField<::std::vec::Vec> { ::std::mem::replace(&mut self.keys, ::protobuf::RepeatedField::new()) } - - pub fn get_keys(&self) -> &[::std::vec::Vec] { - &self.keys - } } impl ::protobuf::Message for TopicDescriptor_AuthOpts { @@ -1236,8 +1271,8 @@ impl ::protobuf::Message for TopicDescriptor_AuthOpts { impl ::protobuf::Clear for TopicDescriptor_AuthOpts { fn clear(&mut self) { - self.clear_mode(); - self.clear_keys(); + self.mode = ::std::option::Option::None; + self.keys.clear(); self.unknown_fields.clear(); } } @@ -1249,7 +1284,7 @@ impl ::std::fmt::Debug for TopicDescriptor_AuthOpts { } impl ::protobuf::reflect::ProtobufValue for TopicDescriptor_AuthOpts { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Message(self) } } @@ -1307,7 +1342,7 @@ impl ::std::default::Default for TopicDescriptor_AuthOpts_AuthMode { } impl ::protobuf::reflect::ProtobufValue for TopicDescriptor_AuthOpts_AuthMode { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) } } @@ -1322,6 +1357,12 @@ pub struct TopicDescriptor_EncOpts { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a TopicDescriptor_EncOpts { + fn default() -> &'a TopicDescriptor_EncOpts { + ::default_instance() + } +} + impl TopicDescriptor_EncOpts { pub fn new() -> TopicDescriptor_EncOpts { ::std::default::Default::default() @@ -1329,6 +1370,10 @@ impl TopicDescriptor_EncOpts { // optional .floodsub.pb.TopicDescriptor.EncOpts.EncMode mode = 1; + + pub fn get_mode(&self) -> TopicDescriptor_EncOpts_EncMode { + self.mode.unwrap_or(TopicDescriptor_EncOpts_EncMode::NONE) + } pub fn clear_mode(&mut self) { self.mode = ::std::option::Option::None; } @@ -1342,12 +1387,12 @@ impl TopicDescriptor_EncOpts { self.mode = ::std::option::Option::Some(v); } - pub fn get_mode(&self) -> TopicDescriptor_EncOpts_EncMode { - self.mode.unwrap_or(TopicDescriptor_EncOpts_EncMode::NONE) - } - // repeated bytes keyHashes = 2; + + pub fn get_keyHashes(&self) -> &[::std::vec::Vec] { + &self.keyHashes + } pub fn clear_keyHashes(&mut self) { self.keyHashes.clear(); } @@ -1366,10 +1411,6 @@ impl TopicDescriptor_EncOpts { pub fn take_keyHashes(&mut self) -> ::protobuf::RepeatedField<::std::vec::Vec> { ::std::mem::replace(&mut self.keyHashes, ::protobuf::RepeatedField::new()) } - - pub fn get_keyHashes(&self) -> &[::std::vec::Vec] { - &self.keyHashes - } } impl ::protobuf::Message for TopicDescriptor_EncOpts { @@ -1491,8 +1532,8 @@ impl ::protobuf::Message for TopicDescriptor_EncOpts { impl ::protobuf::Clear for TopicDescriptor_EncOpts { fn clear(&mut self) { - self.clear_mode(); - self.clear_keyHashes(); + self.mode = ::std::option::Option::None; + self.keyHashes.clear(); self.unknown_fields.clear(); } } @@ -1504,7 +1545,7 @@ impl ::std::fmt::Debug for TopicDescriptor_EncOpts { } impl ::protobuf::reflect::ProtobufValue for TopicDescriptor_EncOpts { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Message(self) } } @@ -1562,119 +1603,120 @@ impl ::std::default::Default for TopicDescriptor_EncOpts_EncMode { } impl ::protobuf::reflect::ProtobufValue for TopicDescriptor_EncOpts_EncMode { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Enum(self.descriptor()) } } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\trpc.proto\x12\x0bfloodsub.pb\"\xb8\x01\n\x03RPC\x12>\n\rsubscription\ - s\x18\x01\x20\x03(\x0b2\x18.floodsub.pb.RPC.SubOptsR\rsubscriptions\x12.\ - \n\x07publish\x18\x02\x20\x03(\x0b2\x14.floodsub.pb.MessageR\x07publish\ - \x1aA\n\x07SubOpts\x12\x1c\n\tsubscribe\x18\x01\x20\x01(\x08R\tsubscribe\ - \x12\x18\n\x07topicid\x18\x02\x20\x01(\tR\x07topicid\"c\n\x07Message\x12\ - \x12\n\x04from\x18\x01\x20\x01(\x0cR\x04from\x12\x12\n\x04data\x18\x02\ - \x20\x01(\x0cR\x04data\x12\x14\n\x05seqno\x18\x03\x20\x01(\x0cR\x05seqno\ - \x12\x1a\n\x08topicIDs\x18\x04\x20\x03(\tR\x08topicIDs\"\xbe\x03\n\x0fTo\ - picDescriptor\x12\x12\n\x04name\x18\x01\x20\x01(\tR\x04name\x129\n\x04au\ - th\x18\x02\x20\x01(\x0b2%.floodsub.pb.TopicDescriptor.AuthOptsR\x04auth\ - \x126\n\x03enc\x18\x03\x20\x01(\x0b2$.floodsub.pb.TopicDescriptor.EncOpt\ - sR\x03enc\x1a\x8a\x01\n\x08AuthOpts\x12B\n\x04mode\x18\x01\x20\x01(\x0e2\ - ..floodsub.pb.TopicDescriptor.AuthOpts.AuthModeR\x04mode\x12\x12\n\x04ke\ - ys\x18\x02\x20\x03(\x0cR\x04keys\"&\n\x08AuthMode\x12\x08\n\x04NONE\x10\ - \0\x12\x07\n\x03KEY\x10\x01\x12\x07\n\x03WOT\x10\x02\x1a\x96\x01\n\x07En\ - cOpts\x12@\n\x04mode\x18\x01\x20\x01(\x0e2,.floodsub.pb.TopicDescriptor.\ - EncOpts.EncModeR\x04mode\x12\x1c\n\tkeyHashes\x18\x02\x20\x03(\x0cR\tkey\ - Hashes\"+\n\x07EncMode\x12\x08\n\x04NONE\x10\0\x12\r\n\tSHAREDKEY\x10\ - \x01\x12\x07\n\x03WOT\x10\x02J\xc2\x10\n\x06\x12\x04\0\0.\x01\n\x08\n\ - \x01\x02\x12\x03\0\x08\x13\n\n\n\x02\x04\0\x12\x04\x02\0\n\x01\n\n\n\x03\ - \x04\0\x01\x12\x03\x02\x08\x0b\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x08+\ - \n\x0c\n\x05\x04\0\x02\0\x04\x12\x03\x03\x08\x10\n\x0c\n\x05\x04\0\x02\0\ - \x06\x12\x03\x03\x11\x18\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x19&\n\ - \x0c\n\x05\x04\0\x02\0\x03\x12\x03\x03)*\n\x0b\n\x04\x04\0\x02\x01\x12\ - \x03\x04\x08%\n\x0c\n\x05\x04\0\x02\x01\x04\x12\x03\x04\x08\x10\n\x0c\n\ - \x05\x04\0\x02\x01\x06\x12\x03\x04\x11\x18\n\x0c\n\x05\x04\0\x02\x01\x01\ - \x12\x03\x04\x19\x20\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04#$\n\x0c\n\ - \x04\x04\0\x03\0\x12\x04\x06\x08\t\t\n\x0c\n\x05\x04\0\x03\0\x01\x12\x03\ - \x06\x10\x17\n(\n\x06\x04\0\x03\0\x02\0\x12\x03\x07\x10,\"\x19\x20subscr\ - ibe\x20or\x20unsubcribe\n\n\x0e\n\x07\x04\0\x03\0\x02\0\x04\x12\x03\x07\ - \x10\x18\n\x0e\n\x07\x04\0\x03\0\x02\0\x05\x12\x03\x07\x19\x1d\n\x0e\n\ - \x07\x04\0\x03\0\x02\0\x01\x12\x03\x07\x1e'\n\x0e\n\x07\x04\0\x03\0\x02\ - \0\x03\x12\x03\x07*+\n\r\n\x06\x04\0\x03\0\x02\x01\x12\x03\x08\x10,\n\ - \x0e\n\x07\x04\0\x03\0\x02\x01\x04\x12\x03\x08\x10\x18\n\x0e\n\x07\x04\0\ - \x03\0\x02\x01\x05\x12\x03\x08\x19\x1f\n\x0e\n\x07\x04\0\x03\0\x02\x01\ - \x01\x12\x03\x08\x20'\n\x0e\n\x07\x04\0\x03\0\x02\x01\x03\x12\x03\x08*+\ - \n\n\n\x02\x04\x01\x12\x04\x0c\0\x11\x01\n\n\n\x03\x04\x01\x01\x12\x03\ - \x0c\x08\x0f\n\x0b\n\x04\x04\x01\x02\0\x12\x03\r\x08\x20\n\x0c\n\x05\x04\ - \x01\x02\0\x04\x12\x03\r\x08\x10\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\r\ - \x11\x16\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\r\x17\x1b\n\x0c\n\x05\x04\ - \x01\x02\0\x03\x12\x03\r\x1e\x1f\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\x0e\ - \x08\x20\n\x0c\n\x05\x04\x01\x02\x01\x04\x12\x03\x0e\x08\x10\n\x0c\n\x05\ - \x04\x01\x02\x01\x05\x12\x03\x0e\x11\x16\n\x0c\n\x05\x04\x01\x02\x01\x01\ - \x12\x03\x0e\x17\x1b\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\x0e\x1e\x1f\ - \n\x0b\n\x04\x04\x01\x02\x02\x12\x03\x0f\x08!\n\x0c\n\x05\x04\x01\x02\ - \x02\x04\x12\x03\x0f\x08\x10\n\x0c\n\x05\x04\x01\x02\x02\x05\x12\x03\x0f\ - \x11\x16\n\x0c\n\x05\x04\x01\x02\x02\x01\x12\x03\x0f\x17\x1c\n\x0c\n\x05\ - \x04\x01\x02\x02\x03\x12\x03\x0f\x1f\x20\n\x0b\n\x04\x04\x01\x02\x03\x12\ - \x03\x10\x08%\n\x0c\n\x05\x04\x01\x02\x03\x04\x12\x03\x10\x08\x10\n\x0c\ - \n\x05\x04\x01\x02\x03\x05\x12\x03\x10\x11\x17\n\x0c\n\x05\x04\x01\x02\ - \x03\x01\x12\x03\x10\x18\x20\n\x0c\n\x05\x04\x01\x02\x03\x03\x12\x03\x10\ - #$\nC\n\x02\x04\x02\x12\x04\x14\0.\x01\x1a7\x20topicID\x20=\x20hash(topi\ - cDescriptor);\x20(not\x20the\x20topic.name)\n\n\n\n\x03\x04\x02\x01\x12\ - \x03\x14\x08\x17\n\x0b\n\x04\x04\x02\x02\0\x12\x03\x15\x08!\n\x0c\n\x05\ - \x04\x02\x02\0\x04\x12\x03\x15\x08\x10\n\x0c\n\x05\x04\x02\x02\0\x05\x12\ - \x03\x15\x11\x17\n\x0c\n\x05\x04\x02\x02\0\x01\x12\x03\x15\x18\x1c\n\x0c\ - \n\x05\x04\x02\x02\0\x03\x12\x03\x15\x1f\x20\n\x0b\n\x04\x04\x02\x02\x01\ - \x12\x03\x16\x08#\n\x0c\n\x05\x04\x02\x02\x01\x04\x12\x03\x16\x08\x10\n\ - \x0c\n\x05\x04\x02\x02\x01\x06\x12\x03\x16\x11\x19\n\x0c\n\x05\x04\x02\ - \x02\x01\x01\x12\x03\x16\x1a\x1e\n\x0c\n\x05\x04\x02\x02\x01\x03\x12\x03\ - \x16!\"\n\x0b\n\x04\x04\x02\x02\x02\x12\x03\x17\x08!\n\x0c\n\x05\x04\x02\ - \x02\x02\x04\x12\x03\x17\x08\x10\n\x0c\n\x05\x04\x02\x02\x02\x06\x12\x03\ - \x17\x11\x18\n\x0c\n\x05\x04\x02\x02\x02\x01\x12\x03\x17\x19\x1c\n\x0c\n\ - \x05\x04\x02\x02\x02\x03\x12\x03\x17\x1f\x20\n\x0c\n\x04\x04\x02\x03\0\ - \x12\x04\x19\x08\"\t\n\x0c\n\x05\x04\x02\x03\0\x01\x12\x03\x19\x10\x18\n\ - \r\n\x06\x04\x02\x03\0\x02\0\x12\x03\x1a\x10+\n\x0e\n\x07\x04\x02\x03\0\ - \x02\0\x04\x12\x03\x1a\x10\x18\n\x0e\n\x07\x04\x02\x03\0\x02\0\x06\x12\ - \x03\x1a\x19!\n\x0e\n\x07\x04\x02\x03\0\x02\0\x01\x12\x03\x1a\"&\n\x0e\n\ - \x07\x04\x02\x03\0\x02\0\x03\x12\x03\x1a)*\n#\n\x06\x04\x02\x03\0\x02\ - \x01\x12\x03\x1b\x10(\"\x14\x20root\x20keys\x20to\x20trust\n\n\x0e\n\x07\ - \x04\x02\x03\0\x02\x01\x04\x12\x03\x1b\x10\x18\n\x0e\n\x07\x04\x02\x03\0\ - \x02\x01\x05\x12\x03\x1b\x19\x1e\n\x0e\n\x07\x04\x02\x03\0\x02\x01\x01\ - \x12\x03\x1b\x1f#\n\x0e\n\x07\x04\x02\x03\0\x02\x01\x03\x12\x03\x1b&'\n\ - \x0e\n\x06\x04\x02\x03\0\x04\0\x12\x04\x1d\x10!\x11\n\x0e\n\x07\x04\x02\ - \x03\0\x04\0\x01\x12\x03\x1d\x15\x1d\n8\n\x08\x04\x02\x03\0\x04\0\x02\0\ - \x12\x03\x1e\x18!\"'\x20no\x20authentication,\x20anyone\x20can\x20publis\ - h\n\n\x10\n\t\x04\x02\x03\0\x04\0\x02\0\x01\x12\x03\x1e\x18\x1c\n\x10\n\ - \t\x04\x02\x03\0\x04\0\x02\0\x02\x12\x03\x1e\x1f\x20\nT\n\x08\x04\x02\ - \x03\0\x04\0\x02\x01\x12\x03\x1f\x18\x20\"C\x20only\x20messages\x20signe\ - d\x20by\x20keys\x20in\x20the\x20topic\x20descriptor\x20are\x20accepted\n\ - \n\x10\n\t\x04\x02\x03\0\x04\0\x02\x01\x01\x12\x03\x1f\x18\x1b\n\x10\n\t\ - \x04\x02\x03\0\x04\0\x02\x01\x02\x12\x03\x1f\x1e\x1f\nM\n\x08\x04\x02\ - \x03\0\x04\0\x02\x02\x12\x03\x20\x18\x20\"<\x20web\x20of\x20trust,\x20ce\ - rtificates\x20can\x20allow\x20publisher\x20set\x20to\x20grow\n\n\x10\n\t\ - \x04\x02\x03\0\x04\0\x02\x02\x01\x12\x03\x20\x18\x1b\n\x10\n\t\x04\x02\ - \x03\0\x04\0\x02\x02\x02\x12\x03\x20\x1e\x1f\n\x0c\n\x04\x04\x02\x03\x01\ - \x12\x04$\x08-\t\n\x0c\n\x05\x04\x02\x03\x01\x01\x12\x03$\x10\x17\n\r\n\ - \x06\x04\x02\x03\x01\x02\0\x12\x03%\x10*\n\x0e\n\x07\x04\x02\x03\x01\x02\ - \0\x04\x12\x03%\x10\x18\n\x0e\n\x07\x04\x02\x03\x01\x02\0\x06\x12\x03%\ - \x19\x20\n\x0e\n\x07\x04\x02\x03\x01\x02\0\x01\x12\x03%!%\n\x0e\n\x07\ - \x04\x02\x03\x01\x02\0\x03\x12\x03%()\n<\n\x06\x04\x02\x03\x01\x02\x01\ - \x12\x03&\x10-\"-\x20the\x20hashes\x20of\x20the\x20shared\x20keys\x20use\ - d\x20(salted)\n\n\x0e\n\x07\x04\x02\x03\x01\x02\x01\x04\x12\x03&\x10\x18\ - \n\x0e\n\x07\x04\x02\x03\x01\x02\x01\x05\x12\x03&\x19\x1e\n\x0e\n\x07\ - \x04\x02\x03\x01\x02\x01\x01\x12\x03&\x1f(\n\x0e\n\x07\x04\x02\x03\x01\ - \x02\x01\x03\x12\x03&+,\n\x0e\n\x06\x04\x02\x03\x01\x04\0\x12\x04(\x10,\ - \x11\n\x0e\n\x07\x04\x02\x03\x01\x04\0\x01\x12\x03(\x15\x1c\n1\n\x08\x04\ - \x02\x03\x01\x04\0\x02\0\x12\x03)\x18!\"\x20\x20no\x20encryption,\x20any\ - one\x20can\x20read\n\n\x10\n\t\x04\x02\x03\x01\x04\0\x02\0\x01\x12\x03)\ - \x18\x1c\n\x10\n\t\x04\x02\x03\x01\x04\0\x02\0\x02\x12\x03)\x1f\x20\n9\n\ - \x08\x04\x02\x03\x01\x04\0\x02\x01\x12\x03*\x18&\"(\x20messages\x20are\ - \x20encrypted\x20with\x20shared\x20key\n\n\x10\n\t\x04\x02\x03\x01\x04\0\ - \x02\x01\x01\x12\x03*\x18!\n\x10\n\t\x04\x02\x03\x01\x04\0\x02\x01\x02\ - \x12\x03*$%\nM\n\x08\x04\x02\x03\x01\x04\0\x02\x02\x12\x03+\x18\x20\"<\ - \x20web\x20of\x20trust,\x20certificates\x20can\x20allow\x20publisher\x20\ - set\x20to\x20grow\n\n\x10\n\t\x04\x02\x03\x01\x04\0\x02\x02\x01\x12\x03+\ - \x18\x1b\n\x10\n\t\x04\x02\x03\x01\x04\0\x02\x02\x02\x12\x03+\x1e\x1f\ + \n\rsrc/rpc.proto\x12\x0bfloodsub.pb\"\xb8\x01\n\x03RPC\x12>\n\rsubscrip\ + tions\x18\x01\x20\x03(\x0b2\x18.floodsub.pb.RPC.SubOptsR\rsubscriptions\ + \x12.\n\x07publish\x18\x02\x20\x03(\x0b2\x14.floodsub.pb.MessageR\x07pub\ + lish\x1aA\n\x07SubOpts\x12\x1c\n\tsubscribe\x18\x01\x20\x01(\x08R\tsubsc\ + ribe\x12\x18\n\x07topicid\x18\x02\x20\x01(\tR\x07topicid\"c\n\x07Message\ + \x12\x12\n\x04from\x18\x01\x20\x01(\x0cR\x04from\x12\x12\n\x04data\x18\ + \x02\x20\x01(\x0cR\x04data\x12\x14\n\x05seqno\x18\x03\x20\x01(\x0cR\x05s\ + eqno\x12\x1a\n\x08topicIDs\x18\x04\x20\x03(\tR\x08topicIDs\"\xbe\x03\n\ + \x0fTopicDescriptor\x12\x12\n\x04name\x18\x01\x20\x01(\tR\x04name\x129\n\ + \x04auth\x18\x02\x20\x01(\x0b2%.floodsub.pb.TopicDescriptor.AuthOptsR\ + \x04auth\x126\n\x03enc\x18\x03\x20\x01(\x0b2$.floodsub.pb.TopicDescripto\ + r.EncOptsR\x03enc\x1a\x8a\x01\n\x08AuthOpts\x12B\n\x04mode\x18\x01\x20\ + \x01(\x0e2..floodsub.pb.TopicDescriptor.AuthOpts.AuthModeR\x04mode\x12\ + \x12\n\x04keys\x18\x02\x20\x03(\x0cR\x04keys\"&\n\x08AuthMode\x12\x08\n\ + \x04NONE\x10\0\x12\x07\n\x03KEY\x10\x01\x12\x07\n\x03WOT\x10\x02\x1a\x96\ + \x01\n\x07EncOpts\x12@\n\x04mode\x18\x01\x20\x01(\x0e2,.floodsub.pb.Topi\ + cDescriptor.EncOpts.EncModeR\x04mode\x12\x1c\n\tkeyHashes\x18\x02\x20\ + \x03(\x0cR\tkeyHashes\"+\n\x07EncMode\x12\x08\n\x04NONE\x10\0\x12\r\n\tS\ + HAREDKEY\x10\x01\x12\x07\n\x03WOT\x10\x02J\xcc\x10\n\x06\x12\x04\0\00\ + \x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\x08\n\x01\x02\x12\x03\x02\x08\x13\ + \n\n\n\x02\x04\0\x12\x04\x04\0\x0c\x01\n\n\n\x03\x04\0\x01\x12\x03\x04\ + \x08\x0b\n\x0b\n\x04\x04\0\x02\0\x12\x03\x05\x08+\n\x0c\n\x05\x04\0\x02\ + \0\x04\x12\x03\x05\x08\x10\n\x0c\n\x05\x04\0\x02\0\x06\x12\x03\x05\x11\ + \x18\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x05\x19&\n\x0c\n\x05\x04\0\x02\ + \0\x03\x12\x03\x05)*\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x06\x08%\n\x0c\n\ + \x05\x04\0\x02\x01\x04\x12\x03\x06\x08\x10\n\x0c\n\x05\x04\0\x02\x01\x06\ + \x12\x03\x06\x11\x18\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x06\x19\x20\n\ + \x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x06#$\n\x0c\n\x04\x04\0\x03\0\x12\ + \x04\x08\x08\x0b\t\n\x0c\n\x05\x04\0\x03\0\x01\x12\x03\x08\x10\x17\n(\n\ + \x06\x04\0\x03\0\x02\0\x12\x03\t\x10,\"\x19\x20subscribe\x20or\x20unsubc\ + ribe\n\n\x0e\n\x07\x04\0\x03\0\x02\0\x04\x12\x03\t\x10\x18\n\x0e\n\x07\ + \x04\0\x03\0\x02\0\x05\x12\x03\t\x19\x1d\n\x0e\n\x07\x04\0\x03\0\x02\0\ + \x01\x12\x03\t\x1e'\n\x0e\n\x07\x04\0\x03\0\x02\0\x03\x12\x03\t*+\n\r\n\ + \x06\x04\0\x03\0\x02\x01\x12\x03\n\x10,\n\x0e\n\x07\x04\0\x03\0\x02\x01\ + \x04\x12\x03\n\x10\x18\n\x0e\n\x07\x04\0\x03\0\x02\x01\x05\x12\x03\n\x19\ + \x1f\n\x0e\n\x07\x04\0\x03\0\x02\x01\x01\x12\x03\n\x20'\n\x0e\n\x07\x04\ + \0\x03\0\x02\x01\x03\x12\x03\n*+\n\n\n\x02\x04\x01\x12\x04\x0e\0\x13\x01\ + \n\n\n\x03\x04\x01\x01\x12\x03\x0e\x08\x0f\n\x0b\n\x04\x04\x01\x02\0\x12\ + \x03\x0f\x08\x20\n\x0c\n\x05\x04\x01\x02\0\x04\x12\x03\x0f\x08\x10\n\x0c\ + \n\x05\x04\x01\x02\0\x05\x12\x03\x0f\x11\x16\n\x0c\n\x05\x04\x01\x02\0\ + \x01\x12\x03\x0f\x17\x1b\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\x0f\x1e\ + \x1f\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\x10\x08\x20\n\x0c\n\x05\x04\x01\ + \x02\x01\x04\x12\x03\x10\x08\x10\n\x0c\n\x05\x04\x01\x02\x01\x05\x12\x03\ + \x10\x11\x16\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\x10\x17\x1b\n\x0c\n\ + \x05\x04\x01\x02\x01\x03\x12\x03\x10\x1e\x1f\n\x0b\n\x04\x04\x01\x02\x02\ + \x12\x03\x11\x08!\n\x0c\n\x05\x04\x01\x02\x02\x04\x12\x03\x11\x08\x10\n\ + \x0c\n\x05\x04\x01\x02\x02\x05\x12\x03\x11\x11\x16\n\x0c\n\x05\x04\x01\ + \x02\x02\x01\x12\x03\x11\x17\x1c\n\x0c\n\x05\x04\x01\x02\x02\x03\x12\x03\ + \x11\x1f\x20\n\x0b\n\x04\x04\x01\x02\x03\x12\x03\x12\x08%\n\x0c\n\x05\ + \x04\x01\x02\x03\x04\x12\x03\x12\x08\x10\n\x0c\n\x05\x04\x01\x02\x03\x05\ + \x12\x03\x12\x11\x17\n\x0c\n\x05\x04\x01\x02\x03\x01\x12\x03\x12\x18\x20\ + \n\x0c\n\x05\x04\x01\x02\x03\x03\x12\x03\x12#$\nC\n\x02\x04\x02\x12\x04\ + \x16\00\x01\x1a7\x20topicID\x20=\x20hash(topicDescriptor);\x20(not\x20th\ + e\x20topic.name)\n\n\n\n\x03\x04\x02\x01\x12\x03\x16\x08\x17\n\x0b\n\x04\ + \x04\x02\x02\0\x12\x03\x17\x08!\n\x0c\n\x05\x04\x02\x02\0\x04\x12\x03\ + \x17\x08\x10\n\x0c\n\x05\x04\x02\x02\0\x05\x12\x03\x17\x11\x17\n\x0c\n\ + \x05\x04\x02\x02\0\x01\x12\x03\x17\x18\x1c\n\x0c\n\x05\x04\x02\x02\0\x03\ + \x12\x03\x17\x1f\x20\n\x0b\n\x04\x04\x02\x02\x01\x12\x03\x18\x08#\n\x0c\ + \n\x05\x04\x02\x02\x01\x04\x12\x03\x18\x08\x10\n\x0c\n\x05\x04\x02\x02\ + \x01\x06\x12\x03\x18\x11\x19\n\x0c\n\x05\x04\x02\x02\x01\x01\x12\x03\x18\ + \x1a\x1e\n\x0c\n\x05\x04\x02\x02\x01\x03\x12\x03\x18!\"\n\x0b\n\x04\x04\ + \x02\x02\x02\x12\x03\x19\x08!\n\x0c\n\x05\x04\x02\x02\x02\x04\x12\x03\ + \x19\x08\x10\n\x0c\n\x05\x04\x02\x02\x02\x06\x12\x03\x19\x11\x18\n\x0c\n\ + \x05\x04\x02\x02\x02\x01\x12\x03\x19\x19\x1c\n\x0c\n\x05\x04\x02\x02\x02\ + \x03\x12\x03\x19\x1f\x20\n\x0c\n\x04\x04\x02\x03\0\x12\x04\x1b\x08$\t\n\ + \x0c\n\x05\x04\x02\x03\0\x01\x12\x03\x1b\x10\x18\n\r\n\x06\x04\x02\x03\0\ + \x02\0\x12\x03\x1c\x10+\n\x0e\n\x07\x04\x02\x03\0\x02\0\x04\x12\x03\x1c\ + \x10\x18\n\x0e\n\x07\x04\x02\x03\0\x02\0\x06\x12\x03\x1c\x19!\n\x0e\n\ + \x07\x04\x02\x03\0\x02\0\x01\x12\x03\x1c\"&\n\x0e\n\x07\x04\x02\x03\0\ + \x02\0\x03\x12\x03\x1c)*\n#\n\x06\x04\x02\x03\0\x02\x01\x12\x03\x1d\x10(\ + \"\x14\x20root\x20keys\x20to\x20trust\n\n\x0e\n\x07\x04\x02\x03\0\x02\ + \x01\x04\x12\x03\x1d\x10\x18\n\x0e\n\x07\x04\x02\x03\0\x02\x01\x05\x12\ + \x03\x1d\x19\x1e\n\x0e\n\x07\x04\x02\x03\0\x02\x01\x01\x12\x03\x1d\x1f#\ + \n\x0e\n\x07\x04\x02\x03\0\x02\x01\x03\x12\x03\x1d&'\n\x0e\n\x06\x04\x02\ + \x03\0\x04\0\x12\x04\x1f\x10#\x11\n\x0e\n\x07\x04\x02\x03\0\x04\0\x01\ + \x12\x03\x1f\x15\x1d\n8\n\x08\x04\x02\x03\0\x04\0\x02\0\x12\x03\x20\x18!\ + \"'\x20no\x20authentication,\x20anyone\x20can\x20publish\n\n\x10\n\t\x04\ + \x02\x03\0\x04\0\x02\0\x01\x12\x03\x20\x18\x1c\n\x10\n\t\x04\x02\x03\0\ + \x04\0\x02\0\x02\x12\x03\x20\x1f\x20\nT\n\x08\x04\x02\x03\0\x04\0\x02\ + \x01\x12\x03!\x18\x20\"C\x20only\x20messages\x20signed\x20by\x20keys\x20\ + in\x20the\x20topic\x20descriptor\x20are\x20accepted\n\n\x10\n\t\x04\x02\ + \x03\0\x04\0\x02\x01\x01\x12\x03!\x18\x1b\n\x10\n\t\x04\x02\x03\0\x04\0\ + \x02\x01\x02\x12\x03!\x1e\x1f\nM\n\x08\x04\x02\x03\0\x04\0\x02\x02\x12\ + \x03\"\x18\x20\"<\x20web\x20of\x20trust,\x20certificates\x20can\x20allow\ + \x20publisher\x20set\x20to\x20grow\n\n\x10\n\t\x04\x02\x03\0\x04\0\x02\ + \x02\x01\x12\x03\"\x18\x1b\n\x10\n\t\x04\x02\x03\0\x04\0\x02\x02\x02\x12\ + \x03\"\x1e\x1f\n\x0c\n\x04\x04\x02\x03\x01\x12\x04&\x08/\t\n\x0c\n\x05\ + \x04\x02\x03\x01\x01\x12\x03&\x10\x17\n\r\n\x06\x04\x02\x03\x01\x02\0\ + \x12\x03'\x10*\n\x0e\n\x07\x04\x02\x03\x01\x02\0\x04\x12\x03'\x10\x18\n\ + \x0e\n\x07\x04\x02\x03\x01\x02\0\x06\x12\x03'\x19\x20\n\x0e\n\x07\x04\ + \x02\x03\x01\x02\0\x01\x12\x03'!%\n\x0e\n\x07\x04\x02\x03\x01\x02\0\x03\ + \x12\x03'()\n<\n\x06\x04\x02\x03\x01\x02\x01\x12\x03(\x10-\"-\x20the\x20\ + hashes\x20of\x20the\x20shared\x20keys\x20used\x20(salted)\n\n\x0e\n\x07\ + \x04\x02\x03\x01\x02\x01\x04\x12\x03(\x10\x18\n\x0e\n\x07\x04\x02\x03\ + \x01\x02\x01\x05\x12\x03(\x19\x1e\n\x0e\n\x07\x04\x02\x03\x01\x02\x01\ + \x01\x12\x03(\x1f(\n\x0e\n\x07\x04\x02\x03\x01\x02\x01\x03\x12\x03(+,\n\ + \x0e\n\x06\x04\x02\x03\x01\x04\0\x12\x04*\x10.\x11\n\x0e\n\x07\x04\x02\ + \x03\x01\x04\0\x01\x12\x03*\x15\x1c\n1\n\x08\x04\x02\x03\x01\x04\0\x02\0\ + \x12\x03+\x18!\"\x20\x20no\x20encryption,\x20anyone\x20can\x20read\n\n\ + \x10\n\t\x04\x02\x03\x01\x04\0\x02\0\x01\x12\x03+\x18\x1c\n\x10\n\t\x04\ + \x02\x03\x01\x04\0\x02\0\x02\x12\x03+\x1f\x20\n9\n\x08\x04\x02\x03\x01\ + \x04\0\x02\x01\x12\x03,\x18&\"(\x20messages\x20are\x20encrypted\x20with\ + \x20shared\x20key\n\n\x10\n\t\x04\x02\x03\x01\x04\0\x02\x01\x01\x12\x03,\ + \x18!\n\x10\n\t\x04\x02\x03\x01\x04\0\x02\x01\x02\x12\x03,$%\nM\n\x08\ + \x04\x02\x03\x01\x04\0\x02\x02\x12\x03-\x18\x20\"<\x20web\x20of\x20trust\ + ,\x20certificates\x20can\x20allow\x20publisher\x20set\x20to\x20grow\n\n\ + \x10\n\t\x04\x02\x03\x01\x04\0\x02\x02\x01\x12\x03-\x18\x1b\n\x10\n\t\ + \x04\x02\x03\x01\x04\0\x02\x02\x02\x12\x03-\x1e\x1f\ "; static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { diff --git a/protocols/identify/Cargo.toml b/protocols/identify/Cargo.toml index 8292c4a1214..4b0b4238d88 100644 --- a/protocols/identify/Cargo.toml +++ b/protocols/identify/Cargo.toml @@ -16,7 +16,7 @@ libp2p-core = { version = "0.12.0", path = "../../core" } libp2p-swarm = { version = "0.2.0", path = "../../swarm" } log = "0.4.1" multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../../misc/multiaddr" } -protobuf = "2.3" +protobuf = "2.8" smallvec = "0.6" tokio-codec = "0.1" tokio-io = "0.1.0" diff --git a/protocols/identify/regen_structs_proto.sh b/protocols/identify/regen_structs_proto.sh index 621f0313414..603ec9a8ebb 100755 --- a/protocols/identify/regen_structs_proto.sh +++ b/protocols/identify/regen_structs_proto.sh @@ -1,13 +1,3 @@ #!/bin/sh -# This script regenerates the `src/structs_proto.rs` file from `structs.proto`. - -sudo docker run --rm -v `pwd`:/usr/code:z -w /usr/code rust /bin/bash -c " \ - apt-get update; \ - apt-get install -y protobuf-compiler; \ - cargo install --version 2.3.0 protobuf-codegen; \ - protoc --rust_out . structs.proto" - -sudo chown $USER:$USER *.rs - -mv -f structs.rs ./src/structs_proto.rs +../../scripts/protobuf/gen.sh src/structs.proto diff --git a/protocols/identify/structs.proto b/protocols/identify/src/structs.proto similarity index 98% rename from protocols/identify/structs.proto rename to protocols/identify/src/structs.proto index 0ff074e6205..ab01a1c3dbe 100644 --- a/protocols/identify/structs.proto +++ b/protocols/identify/src/structs.proto @@ -1,3 +1,5 @@ +syntax = "proto2"; + message Identify { // protocolVersion determines compatibility between peers optional string protocolVersion = 5; // e.g. ipfs/1.0.0 diff --git a/protocols/identify/src/structs_proto.rs b/protocols/identify/src/structs_proto.rs index 6524cebf1ee..6a9e10c78bb 100644 --- a/protocols/identify/src/structs_proto.rs +++ b/protocols/identify/src/structs_proto.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 2.3.0. Do not edit +// This file is generated by rust-protobuf 2.8.1. Do not edit // @generated // https://github.com/Manishearth/rust-clippy/issues/702 @@ -17,10 +17,15 @@ #![allow(unsafe_code)] #![allow(unused_imports)] #![allow(unused_results)] +//! Generated file from `src/structs.proto` use protobuf::Message as Message_imported_for_functions; use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_8_1; + #[derive(PartialEq,Clone,Default)] pub struct Identify { // message fields @@ -35,6 +40,12 @@ pub struct Identify { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a Identify { + fn default() -> &'a Identify { + ::default_instance() + } +} + impl Identify { pub fn new() -> Identify { ::std::default::Default::default() @@ -42,6 +53,13 @@ impl Identify { // optional string protocolVersion = 5; + + pub fn get_protocolVersion(&self) -> &str { + match self.protocolVersion.as_ref() { + Some(v) => &v, + None => "", + } + } pub fn clear_protocolVersion(&mut self) { self.protocolVersion.clear(); } @@ -69,15 +87,15 @@ impl Identify { self.protocolVersion.take().unwrap_or_else(|| ::std::string::String::new()) } - pub fn get_protocolVersion(&self) -> &str { - match self.protocolVersion.as_ref() { + // optional string agentVersion = 6; + + + pub fn get_agentVersion(&self) -> &str { + match self.agentVersion.as_ref() { Some(v) => &v, None => "", } } - - // optional string agentVersion = 6; - pub fn clear_agentVersion(&mut self) { self.agentVersion.clear(); } @@ -105,15 +123,15 @@ impl Identify { self.agentVersion.take().unwrap_or_else(|| ::std::string::String::new()) } - pub fn get_agentVersion(&self) -> &str { - match self.agentVersion.as_ref() { + // optional bytes publicKey = 1; + + + pub fn get_publicKey(&self) -> &[u8] { + match self.publicKey.as_ref() { Some(v) => &v, - None => "", + None => &[], } } - - // optional bytes publicKey = 1; - pub fn clear_publicKey(&mut self) { self.publicKey.clear(); } @@ -141,15 +159,12 @@ impl Identify { self.publicKey.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - pub fn get_publicKey(&self) -> &[u8] { - match self.publicKey.as_ref() { - Some(v) => &v, - None => &[], - } - } - // repeated bytes listenAddrs = 2; + + pub fn get_listenAddrs(&self) -> &[::std::vec::Vec] { + &self.listenAddrs + } pub fn clear_listenAddrs(&mut self) { self.listenAddrs.clear(); } @@ -169,12 +184,15 @@ impl Identify { ::std::mem::replace(&mut self.listenAddrs, ::protobuf::RepeatedField::new()) } - pub fn get_listenAddrs(&self) -> &[::std::vec::Vec] { - &self.listenAddrs - } - // optional bytes observedAddr = 4; + + pub fn get_observedAddr(&self) -> &[u8] { + match self.observedAddr.as_ref() { + Some(v) => &v, + None => &[], + } + } pub fn clear_observedAddr(&mut self) { self.observedAddr.clear(); } @@ -202,15 +220,12 @@ impl Identify { self.observedAddr.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - pub fn get_observedAddr(&self) -> &[u8] { - match self.observedAddr.as_ref() { - Some(v) => &v, - None => &[], - } - } - // repeated string protocols = 3; + + pub fn get_protocols(&self) -> &[::std::string::String] { + &self.protocols + } pub fn clear_protocols(&mut self) { self.protocols.clear(); } @@ -229,10 +244,6 @@ impl Identify { pub fn take_protocols(&mut self) -> ::protobuf::RepeatedField<::std::string::String> { ::std::mem::replace(&mut self.protocols, ::protobuf::RepeatedField::new()) } - - pub fn get_protocols(&self) -> &[::std::string::String] { - &self.protocols - } } impl ::protobuf::Message for Identify { @@ -410,12 +421,12 @@ impl ::protobuf::Message for Identify { impl ::protobuf::Clear for Identify { fn clear(&mut self) { - self.clear_protocolVersion(); - self.clear_agentVersion(); - self.clear_publicKey(); - self.clear_listenAddrs(); - self.clear_observedAddr(); - self.clear_protocols(); + self.protocolVersion.clear(); + self.agentVersion.clear(); + self.publicKey.clear(); + self.listenAddrs.clear(); + self.observedAddr.clear(); + self.protocols.clear(); self.unknown_fields.clear(); } } @@ -427,56 +438,57 @@ impl ::std::fmt::Debug for Identify { } impl ::protobuf::reflect::ProtobufValue for Identify { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Message(self) } } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\rstructs.proto\"\xda\x01\n\x08Identify\x12(\n\x0fprotocolVersion\x18\ - \x05\x20\x01(\tR\x0fprotocolVersion\x12\"\n\x0cagentVersion\x18\x06\x20\ - \x01(\tR\x0cagentVersion\x12\x1c\n\tpublicKey\x18\x01\x20\x01(\x0cR\tpub\ - licKey\x12\x20\n\x0blistenAddrs\x18\x02\x20\x03(\x0cR\x0blistenAddrs\x12\ - \"\n\x0cobservedAddr\x18\x04\x20\x01(\x0cR\x0cobservedAddr\x12\x1c\n\tpr\ - otocols\x18\x03\x20\x03(\tR\tprotocolsJ\xc2\t\n\x06\x12\x04\0\0\x16\x01\ - \n\n\n\x02\x04\0\x12\x04\0\0\x16\x01\n\n\n\x03\x04\0\x01\x12\x03\0\x08\ - \x10\nX\n\x04\x04\0\x02\0\x12\x03\x02\x02&\x1a8\x20protocolVersion\x20de\ - termines\x20compatibility\x20between\x20peers\n\"\x11\x20e.g.\x20ipfs/1.\ - 0.0\n\n\x0c\n\x05\x04\0\x02\0\x04\x12\x03\x02\x02\n\n\x0c\n\x05\x04\0\ - \x02\0\x05\x12\x03\x02\x0b\x11\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x02\ - \x12!\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x02$%\n\x9f\x01\n\x04\x04\0\ - \x02\x01\x12\x03\x06\x02#\x1a|\x20agentVersion\x20is\x20like\x20a\x20Use\ - rAgent\x20string\x20in\x20browsers,\x20or\x20client\x20version\x20in\x20\ - bittorrent\n\x20includes\x20the\x20client\x20name\x20and\x20client.\n\"\ - \x14\x20e.g.\x20go-ipfs/0.1.0\n\n\x0c\n\x05\x04\0\x02\x01\x04\x12\x03\ - \x06\x02\n\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x06\x0b\x11\n\x0c\n\x05\ - \x04\0\x02\x01\x01\x12\x03\x06\x12\x1e\n\x0c\n\x05\x04\0\x02\x01\x03\x12\ - \x03\x06!\"\n\xe3\x01\n\x04\x04\0\x02\x02\x12\x03\x0b\x02\x1f\x1a\xd5\ - \x01\x20publicKey\x20is\x20this\x20node's\x20public\x20key\x20(which\x20\ - also\x20gives\x20its\x20node.ID)\n\x20-\x20may\x20not\x20need\x20to\x20b\ - e\x20sent,\x20as\x20secure\x20channel\x20implies\x20it\x20has\x20been\ - \x20sent.\n\x20-\x20then\x20again,\x20if\x20we\x20change\x20/\x20disable\ - \x20secure\x20channel,\x20may\x20still\x20want\x20it.\n\n\x0c\n\x05\x04\ - \0\x02\x02\x04\x12\x03\x0b\x02\n\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\ - \x0b\x0b\x10\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x0b\x11\x1a\n\x0c\n\ - \x05\x04\0\x02\x02\x03\x12\x03\x0b\x1d\x1e\n]\n\x04\x04\0\x02\x03\x12\ - \x03\x0e\x02!\x1aP\x20listenAddrs\x20are\x20the\x20multiaddrs\x20the\x20\ - sender\x20node\x20listens\x20for\x20open\x20connections\x20on\n\n\x0c\n\ - \x05\x04\0\x02\x03\x04\x12\x03\x0e\x02\n\n\x0c\n\x05\x04\0\x02\x03\x05\ - \x12\x03\x0e\x0b\x10\n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03\x0e\x11\x1c\n\ - \x0c\n\x05\x04\0\x02\x03\x03\x12\x03\x0e\x1f\x20\n\x81\x02\n\x04\x04\0\ - \x02\x04\x12\x03\x13\x02\"\x1a\xf3\x01\x20oservedAddr\x20is\x20the\x20mu\ - ltiaddr\x20of\x20the\x20remote\x20endpoint\x20that\x20the\x20sender\x20n\ - ode\x20perceives\n\x20this\x20is\x20useful\x20information\x20to\x20conve\ - y\x20to\x20the\x20other\x20side,\x20as\x20it\x20helps\x20the\x20remote\ - \x20endpoint\n\x20determine\x20whether\x20its\x20connection\x20to\x20the\ - \x20local\x20peer\x20goes\x20through\x20NAT.\n\n\x0c\n\x05\x04\0\x02\x04\ - \x04\x12\x03\x13\x02\n\n\x0c\n\x05\x04\0\x02\x04\x05\x12\x03\x13\x0b\x10\ - \n\x0c\n\x05\x04\0\x02\x04\x01\x12\x03\x13\x11\x1d\n\x0c\n\x05\x04\0\x02\ - \x04\x03\x12\x03\x13\x20!\n\x0b\n\x04\x04\0\x02\x05\x12\x03\x15\x02\x20\ - \n\x0c\n\x05\x04\0\x02\x05\x04\x12\x03\x15\x02\n\n\x0c\n\x05\x04\0\x02\ - \x05\x05\x12\x03\x15\x0b\x11\n\x0c\n\x05\x04\0\x02\x05\x01\x12\x03\x15\ - \x12\x1b\n\x0c\n\x05\x04\0\x02\x05\x03\x12\x03\x15\x1e\x1f\ + \n\x11src/structs.proto\"\xda\x01\n\x08Identify\x12(\n\x0fprotocolVersio\ + n\x18\x05\x20\x01(\tR\x0fprotocolVersion\x12\"\n\x0cagentVersion\x18\x06\ + \x20\x01(\tR\x0cagentVersion\x12\x1c\n\tpublicKey\x18\x01\x20\x01(\x0cR\ + \tpublicKey\x12\x20\n\x0blistenAddrs\x18\x02\x20\x03(\x0cR\x0blistenAddr\ + s\x12\"\n\x0cobservedAddr\x18\x04\x20\x01(\x0cR\x0cobservedAddr\x12\x1c\ + \n\tprotocols\x18\x03\x20\x03(\tR\tprotocolsJ\xcc\t\n\x06\x12\x04\0\0\ + \x18\x01\n\x08\n\x01\x0c\x12\x03\0\0\x12\n\n\n\x02\x04\0\x12\x04\x02\0\ + \x18\x01\n\n\n\x03\x04\0\x01\x12\x03\x02\x08\x10\nX\n\x04\x04\0\x02\0\ + \x12\x03\x04\x02&\x1a8\x20protocolVersion\x20determines\x20compatibility\ + \x20between\x20peers\n\"\x11\x20e.g.\x20ipfs/1.0.0\n\n\x0c\n\x05\x04\0\ + \x02\0\x04\x12\x03\x04\x02\n\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x04\x0b\ + \x11\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x04\x12!\n\x0c\n\x05\x04\0\x02\ + \0\x03\x12\x03\x04$%\n\x9f\x01\n\x04\x04\0\x02\x01\x12\x03\x08\x02#\x1a|\ + \x20agentVersion\x20is\x20like\x20a\x20UserAgent\x20string\x20in\x20brow\ + sers,\x20or\x20client\x20version\x20in\x20bittorrent\n\x20includes\x20th\ + e\x20client\x20name\x20and\x20client.\n\"\x14\x20e.g.\x20go-ipfs/0.1.0\n\ + \n\x0c\n\x05\x04\0\x02\x01\x04\x12\x03\x08\x02\n\n\x0c\n\x05\x04\0\x02\ + \x01\x05\x12\x03\x08\x0b\x11\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x08\ + \x12\x1e\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x08!\"\n\xe3\x01\n\x04\ + \x04\0\x02\x02\x12\x03\r\x02\x1f\x1a\xd5\x01\x20publicKey\x20is\x20this\ + \x20node's\x20public\x20key\x20(which\x20also\x20gives\x20its\x20node.ID\ + )\n\x20-\x20may\x20not\x20need\x20to\x20be\x20sent,\x20as\x20secure\x20c\ + hannel\x20implies\x20it\x20has\x20been\x20sent.\n\x20-\x20then\x20again,\ + \x20if\x20we\x20change\x20/\x20disable\x20secure\x20channel,\x20may\x20s\ + till\x20want\x20it.\n\n\x0c\n\x05\x04\0\x02\x02\x04\x12\x03\r\x02\n\n\ + \x0c\n\x05\x04\0\x02\x02\x05\x12\x03\r\x0b\x10\n\x0c\n\x05\x04\0\x02\x02\ + \x01\x12\x03\r\x11\x1a\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\r\x1d\x1e\n\ + ]\n\x04\x04\0\x02\x03\x12\x03\x10\x02!\x1aP\x20listenAddrs\x20are\x20the\ + \x20multiaddrs\x20the\x20sender\x20node\x20listens\x20for\x20open\x20con\ + nections\x20on\n\n\x0c\n\x05\x04\0\x02\x03\x04\x12\x03\x10\x02\n\n\x0c\n\ + \x05\x04\0\x02\x03\x05\x12\x03\x10\x0b\x10\n\x0c\n\x05\x04\0\x02\x03\x01\ + \x12\x03\x10\x11\x1c\n\x0c\n\x05\x04\0\x02\x03\x03\x12\x03\x10\x1f\x20\n\ + \x81\x02\n\x04\x04\0\x02\x04\x12\x03\x15\x02\"\x1a\xf3\x01\x20oservedAdd\ + r\x20is\x20the\x20multiaddr\x20of\x20the\x20remote\x20endpoint\x20that\ + \x20the\x20sender\x20node\x20perceives\n\x20this\x20is\x20useful\x20info\ + rmation\x20to\x20convey\x20to\x20the\x20other\x20side,\x20as\x20it\x20he\ + lps\x20the\x20remote\x20endpoint\n\x20determine\x20whether\x20its\x20con\ + nection\x20to\x20the\x20local\x20peer\x20goes\x20through\x20NAT.\n\n\x0c\ + \n\x05\x04\0\x02\x04\x04\x12\x03\x15\x02\n\n\x0c\n\x05\x04\0\x02\x04\x05\ + \x12\x03\x15\x0b\x10\n\x0c\n\x05\x04\0\x02\x04\x01\x12\x03\x15\x11\x1d\n\ + \x0c\n\x05\x04\0\x02\x04\x03\x12\x03\x15\x20!\n\x0b\n\x04\x04\0\x02\x05\ + \x12\x03\x17\x02\x20\n\x0c\n\x05\x04\0\x02\x05\x04\x12\x03\x17\x02\n\n\ + \x0c\n\x05\x04\0\x02\x05\x05\x12\x03\x17\x0b\x11\n\x0c\n\x05\x04\0\x02\ + \x05\x01\x12\x03\x17\x12\x1b\n\x0c\n\x05\x04\0\x02\x05\x03\x12\x03\x17\ + \x1e\x1f\ "; static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { diff --git a/protocols/kad/Cargo.toml b/protocols/kad/Cargo.toml index 6be0b952313..1307b7ad0f3 100644 --- a/protocols/kad/Cargo.toml +++ b/protocols/kad/Cargo.toml @@ -20,7 +20,7 @@ libp2p-core = { version = "0.12.0", path = "../../core" } libp2p-swarm = { version = "0.2.0", path = "../../swarm" } multiaddr = { package = "parity-multiaddr", version = "0.5.0", path = "../../misc/multiaddr" } multihash = { package = "parity-multihash", version = "0.1.0", path = "../../misc/multihash" } -protobuf = "2.3" +protobuf = "2.8" rand = "0.6.0" sha2 = "0.8.0" smallvec = "0.6" diff --git a/protocols/kad/regen_dht_proto.sh b/protocols/kad/regen_dht_proto.sh index 703ed009435..0747c2a6c6c 100755 --- a/protocols/kad/regen_dht_proto.sh +++ b/protocols/kad/regen_dht_proto.sh @@ -1,13 +1,3 @@ #!/bin/sh -# This script regenerates the `src/dht_proto.rs` file from `dht.proto`. - -docker run --rm -v `pwd`:/usr/code:z -w /usr/code rust /bin/bash -c " \ - apt-get update; \ - apt-get install -y protobuf-compiler; \ - cargo install --version 2.6.0 protobuf-codegen; \ - protoc --rust_out . dht.proto;" - -sudo chown $USER:$USER *.rs - -mv -f dht.rs ./src/protobuf_structs/dht.rs +../../scripts/protobuf/gen.sh src/dht.proto diff --git a/protocols/kad/dht.proto b/protocols/kad/src/dht.proto similarity index 100% rename from protocols/kad/dht.proto rename to protocols/kad/src/dht.proto diff --git a/protocols/kad/src/protobuf_structs/dht.rs b/protocols/kad/src/dht_proto.rs similarity index 90% rename from protocols/kad/src/protobuf_structs/dht.rs rename to protocols/kad/src/dht_proto.rs index 97dcf1052d4..3154d78be35 100644 --- a/protocols/kad/src/protobuf_structs/dht.rs +++ b/protocols/kad/src/dht_proto.rs @@ -1,9 +1,9 @@ -// This file is generated by rust-protobuf 2.6.0. Do not edit +// This file is generated by rust-protobuf 2.8.1. Do not edit // @generated // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] @@ -17,10 +17,15 @@ #![allow(unsafe_code)] #![allow(unused_imports)] #![allow(unused_results)] +//! Generated file from `src/dht.proto` use protobuf::Message as Message_imported_for_functions; use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_8_1; + #[derive(PartialEq,Clone,Default)] pub struct Record { // message fields @@ -170,7 +175,7 @@ impl ::protobuf::Message for Record { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -225,7 +230,7 @@ impl ::protobuf::Message for Record { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if !self.key.is_empty() { os.write_bytes(1, &self.key)?; } @@ -257,13 +262,13 @@ impl ::protobuf::Message for Record { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { self } @@ -340,7 +345,7 @@ impl ::protobuf::Clear for Record { } impl ::std::fmt::Debug for Record { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } @@ -536,7 +541,7 @@ impl ::protobuf::Message for Message { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -600,7 +605,7 @@ impl ::protobuf::Message for Message { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if self.field_type != Message_MessageType::PUT_VALUE { os.write_enum(1, self.field_type.value())?; } @@ -641,13 +646,13 @@ impl ::protobuf::Message for Message { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { self } @@ -730,7 +735,7 @@ impl ::protobuf::Clear for Message { } impl ::std::fmt::Debug for Message { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } @@ -835,7 +840,7 @@ impl ::protobuf::Message for Message_Peer { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -874,7 +879,7 @@ impl ::protobuf::Message for Message_Peer { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if !self.id.is_empty() { os.write_bytes(1, &self.id)?; } @@ -900,13 +905,13 @@ impl ::protobuf::Message for Message_Peer { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { self } @@ -971,7 +976,7 @@ impl ::protobuf::Clear for Message_Peer { } impl ::std::fmt::Debug for Message_Peer { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } @@ -1111,43 +1116,43 @@ impl ::protobuf::reflect::ProtobufValue for Message_ConnectionType { } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\tdht.proto\x12\x06dht.pb\"\x86\x01\n\x06Record\x12\x10\n\x03key\x18\ - \x01\x20\x01(\x0cR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\x0cR\x05va\ - lue\x12\"\n\x0ctimeReceived\x18\x05\x20\x01(\tR\x0ctimeReceived\x12\x1d\ - \n\tpublisher\x18\x9a\x05\x20\x01(\x0cR\tpublisher\x12\x11\n\x03ttl\x18\ - \x89\x06\x20\x01(\rR\x03ttl\"\xc4\x04\n\x07Message\x12/\n\x04type\x18\ - \x01\x20\x01(\x0e2\x1b.dht.pb.Message.MessageTypeR\x04type\x12(\n\x0fclu\ - sterLevelRaw\x18\n\x20\x01(\x05R\x0fclusterLevelRaw\x12\x10\n\x03key\x18\ - \x02\x20\x01(\x0cR\x03key\x12&\n\x06record\x18\x03\x20\x01(\x0b2\x0e.dht\ - .pb.RecordR\x06record\x126\n\x0bcloserPeers\x18\x08\x20\x03(\x0b2\x14.dh\ - t.pb.Message.PeerR\x0bcloserPeers\x12:\n\rproviderPeers\x18\t\x20\x03(\ - \x0b2\x14.dht.pb.Message.PeerR\rproviderPeers\x1al\n\x04Peer\x12\x0e\n\ - \x02id\x18\x01\x20\x01(\x0cR\x02id\x12\x14\n\x05addrs\x18\x02\x20\x03(\ - \x0cR\x05addrs\x12>\n\nconnection\x18\x03\x20\x01(\x0e2\x1e.dht.pb.Messa\ - ge.ConnectionTypeR\nconnection\"i\n\x0bMessageType\x12\r\n\tPUT_VALUE\ - \x10\0\x12\r\n\tGET_VALUE\x10\x01\x12\x10\n\x0cADD_PROVIDER\x10\x02\x12\ - \x11\n\rGET_PROVIDERS\x10\x03\x12\r\n\tFIND_NODE\x10\x04\x12\x08\n\x04PI\ - NG\x10\x05\"W\n\x0eConnectionType\x12\x11\n\rNOT_CONNECTED\x10\0\x12\r\n\ - \tCONNECTED\x10\x01\x12\x0f\n\x0bCAN_CONNECT\x10\x02\x12\x12\n\x0eCANNOT\ - _CONNECT\x10\x03J\xbe\x18\n\x06\x12\x04\0\0X\x01\n\x08\n\x01\x0c\x12\x03\ - \0\0\x12\n\x08\n\x01\x02\x12\x03\x01\x08\x0e\nX\n\x02\x04\0\x12\x04\x05\ - \0\x1c\x01\x1aL\x20Record\x20represents\x20a\x20dht\x20record\x20that\ - \x20contains\x20a\x20value\n\x20for\x20a\x20key\x20value\x20pair\n\n\n\n\ - \x03\x04\0\x01\x12\x03\x05\x08\x0e\n2\n\x04\x04\0\x02\0\x12\x03\x07\x08\ - \x16\x1a%\x20The\x20key\x20that\x20references\x20this\x20record\n\n\r\n\ - \x05\x04\0\x02\0\x04\x12\x04\x07\x08\x05\x10\n\x0c\n\x05\x04\0\x02\0\x05\ - \x12\x03\x07\x08\r\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x07\x0e\x11\n\x0c\ - \n\x05\x04\0\x02\0\x03\x12\x03\x07\x14\x15\n6\n\x04\x04\0\x02\x01\x12\ - \x03\n\x08\x18\x1a)\x20The\x20actual\x20value\x20this\x20record\x20is\ - \x20storing\n\n\r\n\x05\x04\0\x02\x01\x04\x12\x04\n\x08\x07\x16\n\x0c\n\ - \x05\x04\0\x02\x01\x05\x12\x03\n\x08\r\n\x0c\n\x05\x04\0\x02\x01\x01\x12\ - \x03\n\x0e\x13\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\n\x16\x17\n\xfc\x01\ - \n\x04\x04\0\x02\x02\x12\x03\x13\x08\x20\x1a/\x20Time\x20the\x20record\ - \x20was\x20received,\x20set\x20by\x20receiver\n2\xbd\x01\x20Note:\x20The\ - se\x20fields\x20were\x20removed\x20from\x20the\x20Record\x20message\n\ - \x20hash\x20of\x20the\x20authors\x20public\x20key\noptional\x20string\ - \x20author\x20=\x203;\n\x20A\x20PKI\x20signature\x20for\x20the\x20key+va\ - lue+author\noptional\x20bytes\x20signature\x20=\x204;\n\n\r\n\x05\x04\0\ + \n\rsrc/dht.proto\x12\x06dht.pb\"\x86\x01\n\x06Record\x12\x10\n\x03key\ + \x18\x01\x20\x01(\x0cR\x03key\x12\x14\n\x05value\x18\x02\x20\x01(\x0cR\ + \x05value\x12\"\n\x0ctimeReceived\x18\x05\x20\x01(\tR\x0ctimeReceived\ + \x12\x1d\n\tpublisher\x18\x9a\x05\x20\x01(\x0cR\tpublisher\x12\x11\n\x03\ + ttl\x18\x89\x06\x20\x01(\rR\x03ttl\"\xc4\x04\n\x07Message\x12/\n\x04type\ + \x18\x01\x20\x01(\x0e2\x1b.dht.pb.Message.MessageTypeR\x04type\x12(\n\ + \x0fclusterLevelRaw\x18\n\x20\x01(\x05R\x0fclusterLevelRaw\x12\x10\n\x03\ + key\x18\x02\x20\x01(\x0cR\x03key\x12&\n\x06record\x18\x03\x20\x01(\x0b2\ + \x0e.dht.pb.RecordR\x06record\x126\n\x0bcloserPeers\x18\x08\x20\x03(\x0b\ + 2\x14.dht.pb.Message.PeerR\x0bcloserPeers\x12:\n\rproviderPeers\x18\t\ + \x20\x03(\x0b2\x14.dht.pb.Message.PeerR\rproviderPeers\x1al\n\x04Peer\ + \x12\x0e\n\x02id\x18\x01\x20\x01(\x0cR\x02id\x12\x14\n\x05addrs\x18\x02\ + \x20\x03(\x0cR\x05addrs\x12>\n\nconnection\x18\x03\x20\x01(\x0e2\x1e.dht\ + .pb.Message.ConnectionTypeR\nconnection\"i\n\x0bMessageType\x12\r\n\tPUT\ + _VALUE\x10\0\x12\r\n\tGET_VALUE\x10\x01\x12\x10\n\x0cADD_PROVIDER\x10\ + \x02\x12\x11\n\rGET_PROVIDERS\x10\x03\x12\r\n\tFIND_NODE\x10\x04\x12\x08\ + \n\x04PING\x10\x05\"W\n\x0eConnectionType\x12\x11\n\rNOT_CONNECTED\x10\0\ + \x12\r\n\tCONNECTED\x10\x01\x12\x0f\n\x0bCAN_CONNECT\x10\x02\x12\x12\n\ + \x0eCANNOT_CONNECT\x10\x03J\xbe\x18\n\x06\x12\x04\0\0X\x01\n\x08\n\x01\ + \x0c\x12\x03\0\0\x12\n\x08\n\x01\x02\x12\x03\x01\x08\x0e\nX\n\x02\x04\0\ + \x12\x04\x05\0\x1c\x01\x1aL\x20Record\x20represents\x20a\x20dht\x20recor\ + d\x20that\x20contains\x20a\x20value\n\x20for\x20a\x20key\x20value\x20pai\ + r\n\n\n\n\x03\x04\0\x01\x12\x03\x05\x08\x0e\n2\n\x04\x04\0\x02\0\x12\x03\ + \x07\x08\x16\x1a%\x20The\x20key\x20that\x20references\x20this\x20record\ + \n\n\r\n\x05\x04\0\x02\0\x04\x12\x04\x07\x08\x05\x10\n\x0c\n\x05\x04\0\ + \x02\0\x05\x12\x03\x07\x08\r\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x07\x0e\ + \x11\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x07\x14\x15\n6\n\x04\x04\0\x02\ + \x01\x12\x03\n\x08\x18\x1a)\x20The\x20actual\x20value\x20this\x20record\ + \x20is\x20storing\n\n\r\n\x05\x04\0\x02\x01\x04\x12\x04\n\x08\x07\x16\n\ + \x0c\n\x05\x04\0\x02\x01\x05\x12\x03\n\x08\r\n\x0c\n\x05\x04\0\x02\x01\ + \x01\x12\x03\n\x0e\x13\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\n\x16\x17\n\ + \xfc\x01\n\x04\x04\0\x02\x02\x12\x03\x13\x08\x20\x1a/\x20Time\x20the\x20\ + record\x20was\x20received,\x20set\x20by\x20receiver\n2\xbd\x01\x20Note:\ + \x20These\x20fields\x20were\x20removed\x20from\x20the\x20Record\x20messa\ + ge\n\x20hash\x20of\x20the\x20authors\x20public\x20key\noptional\x20strin\ + g\x20author\x20=\x203;\n\x20A\x20PKI\x20signature\x20for\x20the\x20key+v\ + alue+author\noptional\x20bytes\x20signature\x20=\x204;\n\n\r\n\x05\x04\0\ \x02\x02\x04\x12\x04\x13\x08\n\x18\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\ \x13\x08\x0e\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x13\x0f\x1b\n\x0c\n\ \x05\x04\0\x02\x02\x03\x12\x03\x13\x1e\x1f\nX\n\x04\x04\0\x02\x03\x12\ diff --git a/protocols/kad/src/lib.rs b/protocols/kad/src/lib.rs index e5ee1b69d21..b20a6e023ae 100644 --- a/protocols/kad/src/lib.rs +++ b/protocols/kad/src/lib.rs @@ -32,7 +32,7 @@ pub mod record; mod addresses; mod behaviour; mod jobs; -mod protobuf_structs; +mod dht_proto; mod query; pub use addresses::Addresses; diff --git a/protocols/kad/src/protobuf_structs/mod.rs b/protocols/kad/src/protobuf_structs/mod.rs deleted file mode 100644 index 614bc875fd7..00000000000 --- a/protocols/kad/src/protobuf_structs/mod.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2017 Parity Technologies (UK) Ltd. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS IN THE SOFTWARE. - -pub mod dht; diff --git a/protocols/kad/src/protocol.rs b/protocols/kad/src/protocol.rs index ad5b8894a30..5a5110531f0 100644 --- a/protocols/kad/src/protocol.rs +++ b/protocols/kad/src/protocol.rs @@ -32,7 +32,7 @@ use bytes::BytesMut; use codec::UviBytes; -use crate::protobuf_structs::dht as proto; +use crate::dht_proto as proto; use crate::record::{self, Record}; use futures::{future::{self, FutureResult}, sink, stream, Sink, Stream}; use libp2p_core::{Multiaddr, PeerId}; diff --git a/protocols/noise/Cargo.toml b/protocols/noise/Cargo.toml index f3e20a255cc..feeacacf46a 100644 --- a/protocols/noise/Cargo.toml +++ b/protocols/noise/Cargo.toml @@ -14,7 +14,7 @@ futures = "0.1" lazy_static = "1.2" libp2p-core = { version = "0.12.0", path = "../../core" } log = "0.4" -protobuf = "2.3" +protobuf = "2.8" rand = "^0.7" ring = { version = "^0.16", features = ["alloc"], default-features = false } snow = { version = "0.6.1", features = ["ring-resolver"], default-features = false } diff --git a/protocols/noise/make_proto.sh b/protocols/noise/make_proto.sh deleted file mode 100755 index 5819ebfad8b..00000000000 --- a/protocols/noise/make_proto.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -sudo docker run --rm -v `pwd`:/usr/code:z -w /usr/code rust /bin/bash -c " \ - apt-get update; \ - apt-get install -y protobuf-compiler; \ - cargo install --version 2.3.0 protobuf-codegen; \ - protoc --rust_out ./src/io/handshake/ ./src/io/handshake/payload.proto" - -sudo chown $USER:$USER ./src/io/handshake/payload.rs diff --git a/protocols/noise/regen_structs_proto.sh b/protocols/noise/regen_structs_proto.sh new file mode 100755 index 00000000000..3e694f56f65 --- /dev/null +++ b/protocols/noise/regen_structs_proto.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +../../scripts/protobuf/gen.sh ./src/io/handshake/payload.proto diff --git a/protocols/noise/src/io/handshake.rs b/protocols/noise/src/io/handshake.rs index 781d9095c44..bdb40981f37 100644 --- a/protocols/noise/src/io/handshake.rs +++ b/protocols/noise/src/io/handshake.rs @@ -20,7 +20,7 @@ //! Noise protocol handshake I/O. -mod payload; +mod payload_proto; use crate::error::NoiseError; use crate::protocol::{Protocol, PublicKey, KeypairIdentity}; @@ -496,7 +496,7 @@ where }, RecvIdentityState::ReadPayload(mut read_payload) => { if let Async::Ready((mut st, bytes)) = read_payload.poll()? { - let pb: payload::Identity = protobuf::parse_from_bytes(&bytes)?; + let pb: payload_proto::Identity = protobuf::parse_from_bytes(&bytes)?; if !pb.pubkey.is_empty() { let pk = identity::PublicKey::from_protobuf_encoding(pb.get_pubkey()) .map_err(|_| NoiseError::InvalidKey)?; @@ -551,7 +551,7 @@ where loop { match mem::replace(&mut self.state, SendIdentityState::Done) { SendIdentityState::Init(st) => { - let mut pb = payload::Identity::new(); + let mut pb = payload_proto::Identity::new(); if st.send_identity { pb.set_pubkey(st.identity.public.clone().into_protobuf_encoding()); } diff --git a/protocols/noise/src/io/handshake/payload.rs b/protocols/noise/src/io/handshake/payload_proto.rs similarity index 89% rename from protocols/noise/src/io/handshake/payload.rs rename to protocols/noise/src/io/handshake/payload_proto.rs index 3e9bdb342e5..14583f54525 100644 --- a/protocols/noise/src/io/handshake/payload.rs +++ b/protocols/noise/src/io/handshake/payload_proto.rs @@ -1,9 +1,9 @@ -// This file is generated by rust-protobuf 2.3.0. Do not edit +// This file is generated by rust-protobuf 2.8.1. Do not edit // @generated // https://github.com/Manishearth/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(clippy)] +#![allow(clippy::all)] #![cfg_attr(rustfmt, rustfmt_skip)] @@ -17,10 +17,15 @@ #![allow(unsafe_code)] #![allow(unused_imports)] #![allow(unused_results)] +//! Generated file from `src/io/handshake/payload.proto` use protobuf::Message as Message_imported_for_functions; use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_8_1; + #[derive(PartialEq,Clone,Default)] pub struct Identity { // message fields @@ -31,6 +36,12 @@ pub struct Identity { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a Identity { + fn default() -> &'a Identity { + ::default_instance() + } +} + impl Identity { pub fn new() -> Identity { ::std::default::Default::default() @@ -38,6 +49,10 @@ impl Identity { // bytes pubkey = 1; + + pub fn get_pubkey(&self) -> &[u8] { + &self.pubkey + } pub fn clear_pubkey(&mut self) { self.pubkey.clear(); } @@ -58,12 +73,12 @@ impl Identity { ::std::mem::replace(&mut self.pubkey, ::std::vec::Vec::new()) } - pub fn get_pubkey(&self) -> &[u8] { - &self.pubkey - } - // bytes signature = 2; + + pub fn get_signature(&self) -> &[u8] { + &self.signature + } pub fn clear_signature(&mut self) { self.signature.clear(); } @@ -83,10 +98,6 @@ impl Identity { pub fn take_signature(&mut self) -> ::std::vec::Vec { ::std::mem::replace(&mut self.signature, ::std::vec::Vec::new()) } - - pub fn get_signature(&self) -> &[u8] { - &self.signature - } } impl ::protobuf::Message for Identity { @@ -94,7 +105,7 @@ impl ::protobuf::Message for Identity { true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -127,7 +138,7 @@ impl ::protobuf::Message for Identity { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if !self.pubkey.is_empty() { os.write_bytes(1, &self.pubkey)?; } @@ -150,13 +161,13 @@ impl ::protobuf::Message for Identity { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) } - fn as_any_mut(&mut self) -> &mut ::std::any::Any { - self as &mut ::std::any::Any + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) } - fn into_any(self: Box) -> ::std::boxed::Box<::std::any::Any> { + fn into_any(self: Box) -> ::std::boxed::Box { self } @@ -208,14 +219,14 @@ impl ::protobuf::Message for Identity { impl ::protobuf::Clear for Identity { fn clear(&mut self) { - self.clear_pubkey(); - self.clear_signature(); + self.pubkey.clear(); + self.signature.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for Identity { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } diff --git a/protocols/secio/Cargo.toml b/protocols/secio/Cargo.toml index e7121e4ad09..a45074c04ff 100644 --- a/protocols/secio/Cargo.toml +++ b/protocols/secio/Cargo.toml @@ -14,7 +14,7 @@ bytes = "0.4" futures = "0.1" libp2p-core = { version = "0.12.0", path = "../../core" } log = "0.4.6" -protobuf = "2.3" +protobuf = "2.8" rand = "0.6.5" aes-ctr = "0.3" aesni = { version = "0.6", features = ["nocheck"], optional = true } diff --git a/protocols/secio/regen_structs_proto.sh b/protocols/secio/regen_structs_proto.sh index 621f0313414..603ec9a8ebb 100755 --- a/protocols/secio/regen_structs_proto.sh +++ b/protocols/secio/regen_structs_proto.sh @@ -1,13 +1,3 @@ #!/bin/sh -# This script regenerates the `src/structs_proto.rs` file from `structs.proto`. - -sudo docker run --rm -v `pwd`:/usr/code:z -w /usr/code rust /bin/bash -c " \ - apt-get update; \ - apt-get install -y protobuf-compiler; \ - cargo install --version 2.3.0 protobuf-codegen; \ - protoc --rust_out . structs.proto" - -sudo chown $USER:$USER *.rs - -mv -f structs.rs ./src/structs_proto.rs +../../scripts/protobuf/gen.sh src/structs.proto diff --git a/protocols/secio/structs.proto b/protocols/secio/src/structs.proto similarity index 92% rename from protocols/secio/structs.proto rename to protocols/secio/src/structs.proto index bdd1eeccc45..a35de4c8ec5 100644 --- a/protocols/secio/structs.proto +++ b/protocols/secio/src/structs.proto @@ -1,3 +1,5 @@ +syntax = "proto2"; + package spipe.pb; message Propose { diff --git a/protocols/secio/src/structs_proto.rs b/protocols/secio/src/structs_proto.rs index fdc4316ac95..a5bb19e778a 100644 --- a/protocols/secio/src/structs_proto.rs +++ b/protocols/secio/src/structs_proto.rs @@ -1,4 +1,4 @@ -// This file is generated by rust-protobuf 2.3.0. Do not edit +// This file is generated by rust-protobuf 2.8.1. Do not edit // @generated // https://github.com/Manishearth/rust-clippy/issues/702 @@ -17,10 +17,15 @@ #![allow(unsafe_code)] #![allow(unused_imports)] #![allow(unused_results)] +//! Generated file from `src/structs.proto` use protobuf::Message as Message_imported_for_functions; use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; +/// Generated files are compatible only with the same version +/// of protobuf runtime. +const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_8_1; + #[derive(PartialEq,Clone,Default)] pub struct Propose { // message fields @@ -34,6 +39,12 @@ pub struct Propose { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a Propose { + fn default() -> &'a Propose { + ::default_instance() + } +} + impl Propose { pub fn new() -> Propose { ::std::default::Default::default() @@ -41,6 +52,13 @@ impl Propose { // optional bytes rand = 1; + + pub fn get_rand(&self) -> &[u8] { + match self.rand.as_ref() { + Some(v) => &v, + None => &[], + } + } pub fn clear_rand(&mut self) { self.rand.clear(); } @@ -68,15 +86,15 @@ impl Propose { self.rand.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - pub fn get_rand(&self) -> &[u8] { - match self.rand.as_ref() { + // optional bytes pubkey = 2; + + + pub fn get_pubkey(&self) -> &[u8] { + match self.pubkey.as_ref() { Some(v) => &v, None => &[], } } - - // optional bytes pubkey = 2; - pub fn clear_pubkey(&mut self) { self.pubkey.clear(); } @@ -104,15 +122,15 @@ impl Propose { self.pubkey.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - pub fn get_pubkey(&self) -> &[u8] { - match self.pubkey.as_ref() { + // optional string exchanges = 3; + + + pub fn get_exchanges(&self) -> &str { + match self.exchanges.as_ref() { Some(v) => &v, - None => &[], + None => "", } } - - // optional string exchanges = 3; - pub fn clear_exchanges(&mut self) { self.exchanges.clear(); } @@ -140,15 +158,15 @@ impl Propose { self.exchanges.take().unwrap_or_else(|| ::std::string::String::new()) } - pub fn get_exchanges(&self) -> &str { - match self.exchanges.as_ref() { + // optional string ciphers = 4; + + + pub fn get_ciphers(&self) -> &str { + match self.ciphers.as_ref() { Some(v) => &v, None => "", } } - - // optional string ciphers = 4; - pub fn clear_ciphers(&mut self) { self.ciphers.clear(); } @@ -176,15 +194,15 @@ impl Propose { self.ciphers.take().unwrap_or_else(|| ::std::string::String::new()) } - pub fn get_ciphers(&self) -> &str { - match self.ciphers.as_ref() { + // optional string hashes = 5; + + + pub fn get_hashes(&self) -> &str { + match self.hashes.as_ref() { Some(v) => &v, None => "", } } - - // optional string hashes = 5; - pub fn clear_hashes(&mut self) { self.hashes.clear(); } @@ -211,13 +229,6 @@ impl Propose { pub fn take_hashes(&mut self) -> ::std::string::String { self.hashes.take().unwrap_or_else(|| ::std::string::String::new()) } - - pub fn get_hashes(&self) -> &str { - match self.hashes.as_ref() { - Some(v) => &v, - None => "", - } - } } impl ::protobuf::Message for Propose { @@ -381,11 +392,11 @@ impl ::protobuf::Message for Propose { impl ::protobuf::Clear for Propose { fn clear(&mut self) { - self.clear_rand(); - self.clear_pubkey(); - self.clear_exchanges(); - self.clear_ciphers(); - self.clear_hashes(); + self.rand.clear(); + self.pubkey.clear(); + self.exchanges.clear(); + self.ciphers.clear(); + self.hashes.clear(); self.unknown_fields.clear(); } } @@ -397,7 +408,7 @@ impl ::std::fmt::Debug for Propose { } impl ::protobuf::reflect::ProtobufValue for Propose { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Message(self) } } @@ -412,6 +423,12 @@ pub struct Exchange { pub cached_size: ::protobuf::CachedSize, } +impl<'a> ::std::default::Default for &'a Exchange { + fn default() -> &'a Exchange { + ::default_instance() + } +} + impl Exchange { pub fn new() -> Exchange { ::std::default::Default::default() @@ -419,6 +436,13 @@ impl Exchange { // optional bytes epubkey = 1; + + pub fn get_epubkey(&self) -> &[u8] { + match self.epubkey.as_ref() { + Some(v) => &v, + None => &[], + } + } pub fn clear_epubkey(&mut self) { self.epubkey.clear(); } @@ -446,15 +470,15 @@ impl Exchange { self.epubkey.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - pub fn get_epubkey(&self) -> &[u8] { - match self.epubkey.as_ref() { + // optional bytes signature = 2; + + + pub fn get_signature(&self) -> &[u8] { + match self.signature.as_ref() { Some(v) => &v, None => &[], } } - - // optional bytes signature = 2; - pub fn clear_signature(&mut self) { self.signature.clear(); } @@ -481,13 +505,6 @@ impl Exchange { pub fn take_signature(&mut self) -> ::std::vec::Vec { self.signature.take().unwrap_or_else(|| ::std::vec::Vec::new()) } - - pub fn get_signature(&self) -> &[u8] { - match self.signature.as_ref() { - Some(v) => &v, - None => &[], - } - } } impl ::protobuf::Message for Exchange { @@ -609,8 +626,8 @@ impl ::protobuf::Message for Exchange { impl ::protobuf::Clear for Exchange { fn clear(&mut self) { - self.clear_epubkey(); - self.clear_signature(); + self.epubkey.clear(); + self.signature.clear(); self.unknown_fields.clear(); } } @@ -622,45 +639,46 @@ impl ::std::fmt::Debug for Exchange { } impl ::protobuf::reflect::ProtobufValue for Exchange { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef<'_> { + fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { ::protobuf::reflect::ProtobufValueRef::Message(self) } } static file_descriptor_proto_data: &'static [u8] = b"\ - \n\rstructs.proto\x12\x08spipe.pb\"\x85\x01\n\x07Propose\x12\x12\n\x04ra\ - nd\x18\x01\x20\x01(\x0cR\x04rand\x12\x16\n\x06pubkey\x18\x02\x20\x01(\ - \x0cR\x06pubkey\x12\x1c\n\texchanges\x18\x03\x20\x01(\tR\texchanges\x12\ - \x18\n\x07ciphers\x18\x04\x20\x01(\tR\x07ciphers\x12\x16\n\x06hashes\x18\ - \x05\x20\x01(\tR\x06hashes\"B\n\x08Exchange\x12\x18\n\x07epubkey\x18\x01\ - \x20\x01(\x0cR\x07epubkey\x12\x1c\n\tsignature\x18\x02\x20\x01(\x0cR\tsi\ - gnatureJ\xa5\x04\n\x06\x12\x04\0\0\r\x01\n\x08\n\x01\x02\x12\x03\0\x08\ - \x10\n\n\n\x02\x04\0\x12\x04\x02\0\x08\x01\n\n\n\x03\x04\0\x01\x12\x03\ - \x02\x08\x0f\n\x0b\n\x04\x04\0\x02\0\x12\x03\x03\x08\x20\n\x0c\n\x05\x04\ - \0\x02\0\x04\x12\x03\x03\x08\x10\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x03\ - \x11\x16\n\x0c\n\x05\x04\0\x02\0\x01\x12\x03\x03\x17\x1b\n\x0c\n\x05\x04\ - \0\x02\0\x03\x12\x03\x03\x1e\x1f\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x04\ - \x08\"\n\x0c\n\x05\x04\0\x02\x01\x04\x12\x03\x04\x08\x10\n\x0c\n\x05\x04\ - \0\x02\x01\x05\x12\x03\x04\x11\x16\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\ - \x04\x17\x1d\n\x0c\n\x05\x04\0\x02\x01\x03\x12\x03\x04\x20!\n\x0b\n\x04\ - \x04\0\x02\x02\x12\x03\x05\x08&\n\x0c\n\x05\x04\0\x02\x02\x04\x12\x03\ - \x05\x08\x10\n\x0c\n\x05\x04\0\x02\x02\x05\x12\x03\x05\x11\x17\n\x0c\n\ - \x05\x04\0\x02\x02\x01\x12\x03\x05\x18!\n\x0c\n\x05\x04\0\x02\x02\x03\ - \x12\x03\x05$%\n\x0b\n\x04\x04\0\x02\x03\x12\x03\x06\x08$\n\x0c\n\x05\ - \x04\0\x02\x03\x04\x12\x03\x06\x08\x10\n\x0c\n\x05\x04\0\x02\x03\x05\x12\ - \x03\x06\x11\x17\n\x0c\n\x05\x04\0\x02\x03\x01\x12\x03\x06\x18\x1f\n\x0c\ - \n\x05\x04\0\x02\x03\x03\x12\x03\x06\"#\n\x0b\n\x04\x04\0\x02\x04\x12\ - \x03\x07\x08#\n\x0c\n\x05\x04\0\x02\x04\x04\x12\x03\x07\x08\x10\n\x0c\n\ - \x05\x04\0\x02\x04\x05\x12\x03\x07\x11\x17\n\x0c\n\x05\x04\0\x02\x04\x01\ - \x12\x03\x07\x18\x1e\n\x0c\n\x05\x04\0\x02\x04\x03\x12\x03\x07!\"\n\n\n\ - \x02\x04\x01\x12\x04\n\0\r\x01\n\n\n\x03\x04\x01\x01\x12\x03\n\x08\x10\n\ - \x0b\n\x04\x04\x01\x02\0\x12\x03\x0b\x08#\n\x0c\n\x05\x04\x01\x02\0\x04\ - \x12\x03\x0b\x08\x10\n\x0c\n\x05\x04\x01\x02\0\x05\x12\x03\x0b\x11\x16\n\ - \x0c\n\x05\x04\x01\x02\0\x01\x12\x03\x0b\x17\x1e\n\x0c\n\x05\x04\x01\x02\ - \0\x03\x12\x03\x0b!\"\n\x0b\n\x04\x04\x01\x02\x01\x12\x03\x0c\x08%\n\x0c\ - \n\x05\x04\x01\x02\x01\x04\x12\x03\x0c\x08\x10\n\x0c\n\x05\x04\x01\x02\ - \x01\x05\x12\x03\x0c\x11\x16\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\x0c\ - \x17\x20\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\x0c#$\ + \n\x11src/structs.proto\x12\x08spipe.pb\"\x85\x01\n\x07Propose\x12\x12\n\ + \x04rand\x18\x01\x20\x01(\x0cR\x04rand\x12\x16\n\x06pubkey\x18\x02\x20\ + \x01(\x0cR\x06pubkey\x12\x1c\n\texchanges\x18\x03\x20\x01(\tR\texchanges\ + \x12\x18\n\x07ciphers\x18\x04\x20\x01(\tR\x07ciphers\x12\x16\n\x06hashes\ + \x18\x05\x20\x01(\tR\x06hashes\"B\n\x08Exchange\x12\x18\n\x07epubkey\x18\ + \x01\x20\x01(\x0cR\x07epubkey\x12\x1c\n\tsignature\x18\x02\x20\x01(\x0cR\ + \tsignatureJ\xaf\x04\n\x06\x12\x04\0\0\x0f\x01\n\x08\n\x01\x0c\x12\x03\0\ + \0\x12\n\x08\n\x01\x02\x12\x03\x02\x08\x10\n\n\n\x02\x04\0\x12\x04\x04\0\ + \n\x01\n\n\n\x03\x04\0\x01\x12\x03\x04\x08\x0f\n\x0b\n\x04\x04\0\x02\0\ + \x12\x03\x05\x08\x20\n\x0c\n\x05\x04\0\x02\0\x04\x12\x03\x05\x08\x10\n\ + \x0c\n\x05\x04\0\x02\0\x05\x12\x03\x05\x11\x16\n\x0c\n\x05\x04\0\x02\0\ + \x01\x12\x03\x05\x17\x1b\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x05\x1e\x1f\ + \n\x0b\n\x04\x04\0\x02\x01\x12\x03\x06\x08\"\n\x0c\n\x05\x04\0\x02\x01\ + \x04\x12\x03\x06\x08\x10\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x06\x11\ + \x16\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x06\x17\x1d\n\x0c\n\x05\x04\0\ + \x02\x01\x03\x12\x03\x06\x20!\n\x0b\n\x04\x04\0\x02\x02\x12\x03\x07\x08&\ + \n\x0c\n\x05\x04\0\x02\x02\x04\x12\x03\x07\x08\x10\n\x0c\n\x05\x04\0\x02\ + \x02\x05\x12\x03\x07\x11\x17\n\x0c\n\x05\x04\0\x02\x02\x01\x12\x03\x07\ + \x18!\n\x0c\n\x05\x04\0\x02\x02\x03\x12\x03\x07$%\n\x0b\n\x04\x04\0\x02\ + \x03\x12\x03\x08\x08$\n\x0c\n\x05\x04\0\x02\x03\x04\x12\x03\x08\x08\x10\ + \n\x0c\n\x05\x04\0\x02\x03\x05\x12\x03\x08\x11\x17\n\x0c\n\x05\x04\0\x02\ + \x03\x01\x12\x03\x08\x18\x1f\n\x0c\n\x05\x04\0\x02\x03\x03\x12\x03\x08\"\ + #\n\x0b\n\x04\x04\0\x02\x04\x12\x03\t\x08#\n\x0c\n\x05\x04\0\x02\x04\x04\ + \x12\x03\t\x08\x10\n\x0c\n\x05\x04\0\x02\x04\x05\x12\x03\t\x11\x17\n\x0c\ + \n\x05\x04\0\x02\x04\x01\x12\x03\t\x18\x1e\n\x0c\n\x05\x04\0\x02\x04\x03\ + \x12\x03\t!\"\n\n\n\x02\x04\x01\x12\x04\x0c\0\x0f\x01\n\n\n\x03\x04\x01\ + \x01\x12\x03\x0c\x08\x10\n\x0b\n\x04\x04\x01\x02\0\x12\x03\r\x08#\n\x0c\ + \n\x05\x04\x01\x02\0\x04\x12\x03\r\x08\x10\n\x0c\n\x05\x04\x01\x02\0\x05\ + \x12\x03\r\x11\x16\n\x0c\n\x05\x04\x01\x02\0\x01\x12\x03\r\x17\x1e\n\x0c\ + \n\x05\x04\x01\x02\0\x03\x12\x03\r!\"\n\x0b\n\x04\x04\x01\x02\x01\x12\ + \x03\x0e\x08%\n\x0c\n\x05\x04\x01\x02\x01\x04\x12\x03\x0e\x08\x10\n\x0c\ + \n\x05\x04\x01\x02\x01\x05\x12\x03\x0e\x11\x16\n\x0c\n\x05\x04\x01\x02\ + \x01\x01\x12\x03\x0e\x17\x20\n\x0c\n\x05\x04\x01\x02\x01\x03\x12\x03\x0e\ + #$\ "; static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { diff --git a/scripts/protobuf/Dockerfile b/scripts/protobuf/Dockerfile new file mode 100644 index 00000000000..48ac8c05e35 --- /dev/null +++ b/scripts/protobuf/Dockerfile @@ -0,0 +1,5 @@ +FROM rust:1.38 + +RUN apt-get update && apt-get install -y protobuf-compiler + +RUN cargo install --version 2.8.1 protobuf-codegen diff --git a/scripts/protobuf/gen.sh b/scripts/protobuf/gen.sh new file mode 100755 index 00000000000..9fcf0626b09 --- /dev/null +++ b/scripts/protobuf/gen.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# exit immediately when a command fails +set -e +# only exit with zero if all commands of the pipeline exit successfully +set -o pipefail +# error on unset variables +set -u +# print each command before executing it +set -x + + +# The source .proto file. +SOURCE_PROTO_FILE=$1 + +DEST_FOLDER=$(dirname "$SOURCE_PROTO_FILE") + +# The .rs file generated via protoc. +TMP_GEN_RUST_FILE=${SOURCE_PROTO_FILE/proto/rs} + +# The above with `_proto` injected. +FINAL_GEN_RUST_FILE=${TMP_GEN_RUST_FILE/.rs/_proto.rs} + + +sudo docker build -t rust-libp2p-protobuf-builder $(dirname "$0") + +sudo docker run --rm \ + -v `pwd`:/usr/code:z \ + -u="$(id -u):$(id -g)" \ + -w /usr/code \ + rust-libp2p-protobuf-builder \ + /bin/bash -c " \ + protoc --rust_out $DEST_FOLDER $SOURCE_PROTO_FILE" + + +mv $TMP_GEN_RUST_FILE $FINAL_GEN_RUST_FILE