diff options
| author | murilo ijanc | 2026-03-27 21:54:25 -0300 |
|---|---|---|
| committer | murilo ijanc | 2026-03-27 21:54:25 -0300 |
| commit | b4228aa74f6ef4720167236cb072b84d94aa6d2a (patch) | |
| tree | 5a43a68455a06009d0c288e786a4bc000a406a8c /src/paste.rs | |
| parent | 75fddf425102369828f7e8366ebdad4ea086fd07 (diff) | |
| download | tesseras-paste-b4228aa74f6ef4720167236cb072b84d94aa6d2a.tar.gz | |
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
Diffstat (limited to 'src/paste.rs')
| -rw-r--r-- | src/paste.rs | 21 |
1 files changed, 17 insertions, 4 deletions
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; |