Skip to content

Commit dbbd2c1

Browse files
committed
fix: encode topic len as LE in compute_message_id
According to the spec, the message ID should encode the topic len in little-endian. Encoding it as big-endian doesn't make a practical difference, but it's better to follow the spec.
1 parent e89b5ee commit dbbd2c1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/net/p2p/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ fn compute_message_id(message: &libp2p::gossipsub::Message) -> libp2p::gossipsub
506506
Err(_) => (MESSAGE_DOMAIN_INVALID_SNAPPY, &message.data),
507507
};
508508
let topic = message.topic.as_str().as_bytes();
509-
let topic_len = (topic.len() as u64).to_be_bytes();
509+
let topic_len = (topic.len() as u64).to_le_bytes();
510510
hasher.update(domain);
511511
hasher.update(topic_len);
512512
hasher.update(topic);

0 commit comments

Comments
 (0)