mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-12 17:41:22 +00:00
Stack allocated PeerId (#1874)
* Stack allocate PeerId. * Update stuff. * Upgrade rusttls to fix build. * Remove unnecessary manual implementations. * Remove PeerId::into_bytes. * Remove bytes dependency. * Perform some cleanup. * Use Into<kbucket::Key<K>>. * Update versions and changelogs. * Fix PR link. * Fix benchmarks. Co-authored-by: Roman S. Borschel <roman@parity.io>
This commit is contained in:
@ -137,7 +137,7 @@ impl GossipsubCodec {
|
||||
}
|
||||
};
|
||||
|
||||
let source = match PeerId::from_bytes(from.clone()) {
|
||||
let source = match PeerId::from_bytes(&from) {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
debug!("Signature verification failed: Invalid Peer Id");
|
||||
@ -161,7 +161,7 @@ impl GossipsubCodec {
|
||||
.map(|key| PublicKey::from_protobuf_encoding(&key))
|
||||
{
|
||||
Some(Ok(key)) => key,
|
||||
_ => match PublicKey::from_protobuf_encoding(&source.as_bytes()[2..]) {
|
||||
_ => match PublicKey::from_protobuf_encoding(&source.to_bytes()[2..]) {
|
||||
Ok(v) => v,
|
||||
Err(_) => {
|
||||
warn!("Signature verification failed: No valid public key supplied");
|
||||
@ -200,7 +200,7 @@ impl Encoder for GossipsubCodec {
|
||||
|
||||
for message in item.messages.into_iter() {
|
||||
let message = rpc_proto::Message {
|
||||
from: message.source.map(|m| m.into_bytes()),
|
||||
from: message.source.map(|m| m.to_bytes()),
|
||||
data: Some(message.data),
|
||||
seqno: message.sequence_number.map(|s| s.to_be_bytes().to_vec()),
|
||||
topic_ids: message.topics.into_iter().map(TopicHash::into).collect(),
|
||||
@ -372,7 +372,7 @@ impl Decoder for GossipsubCodec {
|
||||
|
||||
let source = if verify_source {
|
||||
Some(
|
||||
PeerId::from_bytes(message.from.unwrap_or_default()).map_err(|_| {
|
||||
PeerId::from_bytes(&message.from.unwrap_or_default()).map_err(|_| {
|
||||
io::Error::new(io::ErrorKind::InvalidData, "Invalid Peer Id")
|
||||
})?,
|
||||
)
|
||||
|
Reference in New Issue
Block a user