Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 58 additions & 45 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ members = [
"misc/metrics",
"misc/multistream-select",
"misc/peer-store",
"misc/quick-protobuf-codec",
"misc/prost-codec",
"misc/quickcheck-ext",
"misc/rw-stream-sink",
"misc/server",
Expand Down Expand Up @@ -131,7 +131,8 @@ multiaddr = "0.18.1"
multihash = "0.19.1"
multistream-select = { version = "0.14.0", path = "misc/multistream-select" }
prometheus-client = "0.24"
quick-protobuf-codec = { version = "0.4.0", path = "misc/quick-protobuf-codec" }
prost-codec = { version = "0.4.0", path = "misc/prost-codec" }
prost = "0.14"
quickcheck = { package = "quickcheck-ext", path = "misc/quickcheck-ext" }
rcgen = "0.13"
ring = "0.17.12"
Expand Down
2 changes: 1 addition & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ multihash = { workspace = true }
multistream-select = { workspace = true }
parking_lot = "0.12.3"
pin-project = "1.1.11"
quick-protobuf = "0.8"
prost = { workspace = true }
rand = "0.8"
rw-stream-sink = { workspace = true }
thiserror = { workspace = true }
Expand Down
82 changes: 25 additions & 57 deletions core/src/generated/envelope_proto.rs
Original file line number Diff line number Diff line change
@@ -1,59 +1,27 @@
// Automatically generated rust module for 'envelope.proto' file

#![allow(non_snake_case)]
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(unused_imports)]
#![allow(unknown_lints)]
#![allow(clippy::all)]
#![cfg_attr(rustfmt, rustfmt_skip)]


use quick_protobuf::{MessageInfo, MessageRead, MessageWrite, BytesReader, Writer, WriterBackend, Result};
use quick_protobuf::sizeofs::*;
use super::*;

#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Debug, Default, PartialEq, Clone)]
// This file is @generated by prost-build.
/// Envelope encloses a signed payload produced by a peer, along with the public
/// key of the keypair it was signed with so that it can be statelessly validated
/// by the receiver.
///
/// The payload is prefixed with a byte string that determines the type, so it
/// can be deserialized deterministically. Often, this byte string is a
/// multicodec.
#[derive(Clone, PartialEq, Eq, Hash, ::prost::Message)]
pub struct Envelope {
pub public_key: Vec<u8>,
pub payload_type: Vec<u8>,
pub payload: Vec<u8>,
pub signature: Vec<u8>,
/// public_key is the public key of the keypair the enclosed payload was
/// signed with.
#[prost(bytes = "vec", tag = "1")]
pub public_key: ::prost::alloc::vec::Vec<u8>,
/// payload_type encodes the type of payload, so that it can be deserialized
/// deterministically.
#[prost(bytes = "vec", tag = "2")]
pub payload_type: ::prost::alloc::vec::Vec<u8>,
/// payload is the actual payload carried inside this envelope.
#[prost(bytes = "vec", tag = "3")]
pub payload: ::prost::alloc::vec::Vec<u8>,
/// signature is the signature produced by the private key corresponding to
/// the enclosed public key, over the payload, prefixing a domain string for
/// additional security.
#[prost(bytes = "vec", tag = "5")]
pub signature: ::prost::alloc::vec::Vec<u8>,
}

impl<'a> MessageRead<'a> for Envelope {
fn from_reader(r: &mut BytesReader, bytes: &'a [u8]) -> Result<Self> {
let mut msg = Self::default();
while !r.is_eof() {
match r.next_tag(bytes) {
Ok(10) => msg.public_key = r.read_bytes(bytes)?.to_owned(),
Ok(18) => msg.payload_type = r.read_bytes(bytes)?.to_owned(),
Ok(26) => msg.payload = r.read_bytes(bytes)?.to_owned(),
Ok(42) => msg.signature = r.read_bytes(bytes)?.to_owned(),
Ok(t) => { r.read_unknown(bytes, t)?; }
Err(e) => return Err(e),
}
}
Ok(msg)
}
}

impl MessageWrite for Envelope {
fn get_size(&self) -> usize {
0
+ if self.public_key.is_empty() { 0 } else { 1 + sizeof_len((&self.public_key).len()) }
+ if self.payload_type.is_empty() { 0 } else { 1 + sizeof_len((&self.payload_type).len()) }
+ if self.payload.is_empty() { 0 } else { 1 + sizeof_len((&self.payload).len()) }
+ if self.signature.is_empty() { 0 } else { 1 + sizeof_len((&self.signature).len()) }
}

fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> Result<()> {
if !self.public_key.is_empty() { w.write_with_tag(10, |w| w.write_bytes(&**&self.public_key))?; }
if !self.payload_type.is_empty() { w.write_with_tag(18, |w| w.write_bytes(&**&self.payload_type))?; }
if !self.payload.is_empty() { w.write_with_tag(26, |w| w.write_bytes(&**&self.payload))?; }
if !self.signature.is_empty() { w.write_with_tag(42, |w| w.write_bytes(&**&self.signature))?; }
Ok(())
}
}

2 changes: 1 addition & 1 deletion core/src/generated/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Automatically generated mod.rs
// Automatically generated by gen-proto. DO NOT EDIT.
pub mod envelope_proto;
pub mod peer_record_proto;
Loading
Loading