aboutsummaryrefslogtreecommitdiffstats
path: root/src/paste.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/paste.rs')
-rw-r--r--src/paste.rs21
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;