Gossipsub fast message id change (#3755)
For improved consistency, this mixes in the topic into our fast message id for more consistent tracking of messages across topics.
This commit is contained in:
parent
c881b80367
commit
2779017076
@ -288,9 +288,11 @@ impl From<u8> for NetworkLoad {
|
|||||||
/// Return a Lighthouse specific `GossipsubConfig` where the `message_id_fn` depends on the current fork.
|
/// Return a Lighthouse specific `GossipsubConfig` where the `message_id_fn` depends on the current fork.
|
||||||
pub fn gossipsub_config(network_load: u8, fork_context: Arc<ForkContext>) -> GossipsubConfig {
|
pub fn gossipsub_config(network_load: u8, fork_context: Arc<ForkContext>) -> GossipsubConfig {
|
||||||
// The function used to generate a gossipsub message id
|
// The function used to generate a gossipsub message id
|
||||||
// We use the first 8 bytes of SHA256(data) for content addressing
|
// We use the first 8 bytes of SHA256(topic, data) for content addressing
|
||||||
let fast_gossip_message_id =
|
let fast_gossip_message_id = |message: &RawGossipsubMessage| {
|
||||||
|message: &RawGossipsubMessage| FastMessageId::from(&Sha256::digest(&message.data)[..8]);
|
let data = [message.topic.as_str().as_bytes(), &message.data].concat();
|
||||||
|
FastMessageId::from(&Sha256::digest(data)[..8])
|
||||||
|
};
|
||||||
fn prefix(
|
fn prefix(
|
||||||
prefix: [u8; 4],
|
prefix: [u8; 4],
|
||||||
message: &GossipsubMessage,
|
message: &GossipsubMessage,
|
||||||
|
Loading…
Reference in New Issue
Block a user