|
1 | 1 | //! Request-Response [`Behaviour`] and [`NetworkBehaviour`] for the P2P protocol. |
2 | 2 |
|
3 | | -use std::collections::HashSet; |
| 3 | +use std::{collections::HashSet, time::Duration}; |
4 | 4 |
|
5 | 5 | use blake3::hash; |
6 | 6 | use libp2p::{ |
@@ -69,19 +69,15 @@ impl Behaviour { |
69 | 69 | .validate_messages() |
70 | 70 | .max_transmit_size(MAX_TRANSMIT_SIZE) |
71 | 71 | // Avoids spamming the network and nodes with messages |
72 | | - .idontwant_on_publish(true) |
73 | | - // We want a unique message id for each message, so we use the hash of the |
74 | | - // message data instead of the default one, that is the concatenation of the |
75 | | - // PeerId and the sequence number of the message. |
76 | | - // |
77 | | - // NOTE(@storopoli): I don't trust the default one, since we are not using the |
78 | | - // LibP2P's Message template, hence the sequence number might |
79 | | - // not exist, and in that case it is always be set to 0 by |
80 | | - // default. |
81 | | - .message_id_fn(|msg| { |
82 | | - let hash = hash(msg.data.as_ref()); |
83 | | - MessageId::new(hash.as_bytes()) |
84 | | - }) |
| 72 | + .duplicate_cache_time(Duration::from_secs(60 * 5)) // default is 1 min |
| 73 | + .published_message_ids_cache_time(Duration::from_secs(60)) // default is 10 |
| 74 | + .max_ihave_messages(100) // default is 10 |
| 75 | + .gossip_retransimission(1) // default is 3 |
| 76 | + .iwant_followup_time(Duration::from_secs(2)) // default is 3 |
| 77 | + .gossip_lazy(2) // default is 6 |
| 78 | + .gossip_factor(0.1) // default is 0.25 |
| 79 | + .history_gossip(1) // default is 3 |
| 80 | + .history_length(3) // default is 5 |
85 | 81 | .build() |
86 | 82 | .expect("gossipsub config at this stage must be valid"), |
87 | 83 | None, |
|
0 commit comments