Improved DHT publication. Adjust batching, added validation per key

This commit is contained in:
Ultradesu
2026-07-23 16:43:10 +03:00
parent aaaad780f2
commit 512a818a6a
3 changed files with 150 additions and 83 deletions
+7 -4
View File
@@ -8,14 +8,17 @@ use serde::{Deserialize, Serialize};
use crate::record::{DhtKey, StoredRecord};
use crate::routing::{NodeContact, NodeId};
/// Version of the music-dht protocol.
pub const DHT_PROTOCOL_VERSION: u16 = 4;
/// Version of the music-dht protocol. Batch limits are enforced by the
/// receiver, so raising them is a version bump too.
pub const DHT_PROTOCOL_VERSION: u16 = 5;
/// Maximum number of contacts in a single [`PeerExchange`].
pub const MAX_PEER_EXCHANGE_CONTACTS: usize = 32;
/// Maximum number of records in a single [`FindValueResponse`].
pub const MAX_RECORDS_PER_RESPONSE: usize = 256;
/// Maximum number of entries in a single [`StoreBatchRequest`].
pub const MAX_RECORDS_PER_BATCH: usize = 64;
/// Maximum number of entries in a single [`StoreBatchRequest`]. Sized so a
/// batch of typical records nearly fills the byte budget: replicating a
/// 20k-track library takes hundreds of requests, not tens of thousands.
pub const MAX_RECORDS_PER_BATCH: usize = 512;
/// Correlates a response with its request.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]