Skip to content
Merged
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
3 changes: 3 additions & 0 deletions protocols/gossipsub/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
- Refactor gossipsub with in-place negative-score peer removal.
See [PR 6209](https://github.com/libp2p/rust-libp2p/pull/6209).

- Avoid direct casting from u128 to u64.
See [PR 6211](https://github.com/libp2p/rust-libp2p/pull/6211).

## 0.49.2

- Relax `Behaviour::with_metrics` requirements, do not require DataTransform and TopicSubscriptionFilter to also impl Default
Expand Down
7 changes: 5 additions & 2 deletions protocols/gossipsub/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ enum PublishConfig {

/// A strictly linearly increasing sequence number.
///
/// We start from the current time as unix timestamp in milliseconds.
/// We start from the current time as unix timestamp in nanoseconds.
#[derive(Debug)]
struct SequenceNumber(u64);

Expand All @@ -194,7 +194,10 @@ impl SequenceNumber {
.expect("time to be linear")
.as_nanos();

Self(unix_timestamp as u64)
Self(
u64::try_from(unix_timestamp)
.expect("timestamp in nanos since UNIX_EPOCH should fit in u64"),
)
}

fn next(&mut self) -> u64 {
Expand Down