mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-06-30 10:11:33 +00:00
*: Add Serialize and Deserialize to PeerId gossipsub MessageId and kad Key (#2408)
Co-authored-by: Max Inden <mail@max-inden.de>
This commit is contained in:
@ -9,11 +9,14 @@
|
||||
- Improve bandwidth performance by tracking IWANTs and reducing duplicate sends
|
||||
(see [PR 2327]).
|
||||
|
||||
- Implement `Serialize` and `Deserialize` for `MessageId` and `FastMessageId` (see [PR 2408])
|
||||
|
||||
- Fix `GossipsubConfigBuilder::build()` requiring `&self` to live for `'static` (see [PR 2409])
|
||||
|
||||
[PR 2346]: https://github.com/libp2p/rust-libp2p/pull/2346
|
||||
[PR 2339]: https://github.com/libp2p/rust-libp2p/pull/2339
|
||||
[PR 2327]: https://github.com/libp2p/rust-libp2p/pull/2327
|
||||
[PR 2408]: https://github.com/libp2p/rust-libp2p/pull/2408
|
||||
[PR 2409]: https://github.com/libp2p/rust-libp2p/pull/2409
|
||||
|
||||
# 0.34.0 [2021-11-16]
|
||||
|
@ -30,6 +30,7 @@ regex = "1.4.0"
|
||||
futures-timer = "3.0.2"
|
||||
pin-project = "1.0.8"
|
||||
instant = "0.1.11"
|
||||
serde = { version = "1", optional = true, features = ["derive"] }
|
||||
# Metrics dependencies
|
||||
open-metrics-client = "0.14.0"
|
||||
|
||||
|
@ -27,6 +27,9 @@ use prost::Message;
|
||||
use std::fmt;
|
||||
use std::fmt::Debug;
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Validation kinds from the application for received messages.
|
||||
pub enum MessageAcceptance {
|
||||
@ -42,6 +45,7 @@ pub enum MessageAcceptance {
|
||||
/// Macro for declaring message id types
|
||||
macro_rules! declare_message_id_type {
|
||||
($name: ident, $name_string: expr) => {
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
pub struct $name(pub Vec<u8>);
|
||||
|
||||
|
@ -6,8 +6,11 @@
|
||||
|
||||
- Derive `Clone` for `KademliaEvent` (see [PR 2411])
|
||||
|
||||
- Derive `Serialize`, `Deserialize` for `store::record::Key` (see [PR 2408])
|
||||
|
||||
[PR 2339]: https://github.com/libp2p/rust-libp2p/pull/2339
|
||||
[PR 2411]: https://github.com/libp2p/rust-libp2p/pull/2411
|
||||
[PR 2408]: https://github.com/libp2p/rust-libp2p/pull/2408
|
||||
|
||||
# 0.33.0 [2021-11-16]
|
||||
|
||||
|
@ -29,6 +29,7 @@ unsigned-varint = { version = "0.7", features = ["asynchronous_codec"] }
|
||||
void = "1.0"
|
||||
futures-timer = "3.0.2"
|
||||
instant = "0.1.11"
|
||||
_serde = { package = "serde", version = "1.0", optional = true, features = ["derive"] }
|
||||
thiserror = "1"
|
||||
|
||||
[dev-dependencies]
|
||||
@ -40,3 +41,6 @@ quickcheck = "0.9.0"
|
||||
|
||||
[build-dependencies]
|
||||
prost-build = "0.9"
|
||||
|
||||
[features]
|
||||
serde = ["_serde", "bytes/serde"]
|
||||
|
@ -24,6 +24,9 @@
|
||||
// be useful later for record store
|
||||
#![allow(dead_code)]
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
extern crate _serde as serde;
|
||||
|
||||
pub mod handler;
|
||||
pub mod kbucket;
|
||||
pub mod protocol;
|
||||
|
@ -25,10 +25,14 @@ pub mod store;
|
||||
use bytes::Bytes;
|
||||
use instant::Instant;
|
||||
use libp2p_core::{multihash::Multihash, Multiaddr, PeerId};
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::borrow::Borrow;
|
||||
use std::hash::{Hash, Hasher};
|
||||
|
||||
/// The (opaque) key of a record.
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(crate = "_serde"))]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct Key(Bytes);
|
||||
|
||||
|
Reference in New Issue
Block a user