From b4228aa74f6ef4720167236cb072b84d94aa6d2a Mon Sep 17 00:00:00 2001 From: murilo ijanc Date: Fri, 27 Mar 2026 21:54:25 -0300 Subject: Add chunked paste support for content up to 1.44 MB Large pastes are split into 8 KiB chunks on the client side, each stored separately in a dedicated chunks/ directory. A version-2 manifest paste lists the chunk hashes and is announced to the DHT; chunks replicate via periodic republish with per-put throttling to avoid rate-limit bans. - New PUTC/PUTM protocol commands for chunks and manifests - Client-side chunking avoids O(n^2) base58 on large content - HTTP handler reassembles chunks directly from store - DHT sync routes incoming chunks to chunks/ directory - Republish interval reduced to 5 min with 200ms throttle - tp.1 updated with new 1.44 MB limit --- src/paste.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'src/paste.rs') diff --git a/src/paste.rs b/src/paste.rs index 8bfe979..6567b9d 100644 --- a/src/paste.rs +++ b/src/paste.rs @@ -8,12 +8,25 @@ use tesseras_dht::sha2::{Digest, Sha256}; -/// Maximum paste size: 64 KiB. -pub const MAX_PASTE_SIZE: usize = 64 * 1024; - -/// Current format version. +/// Maximum paste size: 1.44 MB (floppy disk). +pub const MAX_PASTE_SIZE: usize = 1_440 * 1024; + +/// Chunk size for large pastes: 8 KiB. +/// The DHT fragments datagrams into 896-byte pieces with a +/// maximum of 10 fragments (~8960 bytes reassembled). After +/// subtracting the Paste header (17 bytes) and StoreMsg overhead, +/// 8 KiB fits comfortably within one DHT message. +/// Pastes larger than this are split into chunks, each stored +/// as a separate DHT value, with a version-2 manifest that +/// lists the chunk hashes. +pub const CHUNK_SIZE: usize = 8 * 1024; + +/// Current format version (single paste). const FORMAT_VERSION: u8 = 1; +/// Format version for chunked paste manifests. +pub const FORMAT_VERSION_CHUNKED: u8 = 2; + /// Header size: version(1) + created_at(8) + ttl(8) = 17. const HEADER_SIZE: usize = 17; -- cgit v1.2.3