mirror of
https://github.com/fluencelabs/rust-libp2p
synced 2025-05-29 18:51:22 +00:00
feat(gossipsub): add getter function to obtain TopicScoreParams
Added a getter function to obtain `TopicScoreParams`. I need this function for testing which checks if scoring parameters are updated as expected. Pull-Request: #4231.
This commit is contained in:
parent
4b9c1e5e48
commit
f95f39f634
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -2723,7 +2723,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libp2p-gossipsub"
|
name = "libp2p-gossipsub"
|
||||||
version = "0.45.0"
|
version = "0.45.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-std",
|
"async-std",
|
||||||
"asynchronous-codec",
|
"asynchronous-codec",
|
||||||
|
@ -70,7 +70,7 @@ libp2p-dcutr = { version = "0.10.0", path = "protocols/dcutr" }
|
|||||||
libp2p-deflate = { version = "0.40.0", path = "transports/deflate" }
|
libp2p-deflate = { version = "0.40.0", path = "transports/deflate" }
|
||||||
libp2p-dns = { version = "0.40.0", path = "transports/dns" }
|
libp2p-dns = { version = "0.40.0", path = "transports/dns" }
|
||||||
libp2p-floodsub = { version = "0.43.0", path = "protocols/floodsub" }
|
libp2p-floodsub = { version = "0.43.0", path = "protocols/floodsub" }
|
||||||
libp2p-gossipsub = { version = "0.45.0", path = "protocols/gossipsub" }
|
libp2p-gossipsub = { version = "0.45.1", path = "protocols/gossipsub" }
|
||||||
libp2p-identify = { version = "0.43.0", path = "protocols/identify" }
|
libp2p-identify = { version = "0.43.0", path = "protocols/identify" }
|
||||||
libp2p-identity = { version = "0.2.2" }
|
libp2p-identity = { version = "0.2.2" }
|
||||||
libp2p-kad = { version = "0.44.4", path = "protocols/kad" }
|
libp2p-kad = { version = "0.44.4", path = "protocols/kad" }
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
## 0.45.0
|
## 0.45.1 - unreleased
|
||||||
|
|
||||||
|
- Add getter function to obtain `TopicScoreParams`.
|
||||||
|
See [PR 4231].
|
||||||
|
|
||||||
|
[PR 4231]: https://github.com/libp2p/rust-libp2p/pull/4231
|
||||||
|
|
||||||
|
## 0.45.0
|
||||||
|
|
||||||
- Raise MSRV to 1.65.
|
- Raise MSRV to 1.65.
|
||||||
See [PR 3715].
|
See [PR 3715].
|
||||||
|
@ -3,7 +3,7 @@ name = "libp2p-gossipsub"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = { workspace = true }
|
rust-version = { workspace = true }
|
||||||
description = "Gossipsub protocol for libp2p"
|
description = "Gossipsub protocol for libp2p"
|
||||||
version = "0.45.0"
|
version = "0.45.1"
|
||||||
authors = ["Age Manning <Age@AgeManning.com>"]
|
authors = ["Age Manning <Age@AgeManning.com>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/libp2p/rust-libp2p"
|
repository = "https://github.com/libp2p/rust-libp2p"
|
||||||
|
@ -930,6 +930,11 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a scoring parameters for a topic if existent.
|
||||||
|
pub fn get_topic_params<H: Hasher>(&self, topic: &Topic<H>) -> Option<&TopicScoreParams> {
|
||||||
|
self.peer_score.as_ref()?.0.get_topic_params(&topic.hash())
|
||||||
|
}
|
||||||
|
|
||||||
/// Sets the application specific score for a peer. Returns true if scoring is active and
|
/// Sets the application specific score for a peer. Returns true if scoring is active and
|
||||||
/// the peer is connected or if the score of the peer is not yet expired, false otherwise.
|
/// the peer is connected or if the score of the peer is not yet expired, false otherwise.
|
||||||
pub fn set_application_score(&mut self, peer_id: &PeerId, new_score: f64) -> bool {
|
pub fn set_application_score(&mut self, peer_id: &PeerId, new_score: f64) -> bool {
|
||||||
|
@ -780,6 +780,11 @@ impl PeerScore {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a scoring parameters for a topic if existent.
|
||||||
|
pub(crate) fn get_topic_params(&self, topic_hash: &TopicHash) -> Option<&TopicScoreParams> {
|
||||||
|
self.params.topics.get(topic_hash)
|
||||||
|
}
|
||||||
|
|
||||||
/// Increments the "invalid message deliveries" counter for all scored topics the message
|
/// Increments the "invalid message deliveries" counter for all scored topics the message
|
||||||
/// is published in.
|
/// is published in.
|
||||||
fn mark_invalid_message_delivery(&mut self, peer_id: &PeerId, topic_hash: &TopicHash) {
|
fn mark_invalid_message_delivery(&mut self, peer_id: &PeerId, topic_hash: &TopicHash) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user