Content Addressed Blob Store
Tools that cache downloaded data, save recurring report snapshots, or archive chart screenshots often end up writing the same bytes to disk under a dozen different filenames, because nothing checks whether that content already exists. This library gives every blob an identity derived from its own bytes rather than a filename the caller invents: Put() a buffer and it comes back with a hash string that is the same every time the same bytes are stored, so storing identical content twice increments a reference count instead of writing a second copy. MQL4 has no cryptographic hash function built in, so the fingerprint here is two passes of the 32-bit FNV-1a algorithm, the second reseeded with the first pass's own output, folded into a 16 hex-digit id. That is a reasonable fingerprint for deduplication at the blob counts a single EA or tool realistically produces - it is not a cryptographic hash, and a determined adversary could construct a collision. Do not use this as an integrity check against tampering, only as a "have I already stored this" lookup. Every blob is refcounted rather than stored once and forgotten: two callers that Put() the same content each get their own reference, and the file on disk is only deleted once every caller has Release()d it. A small manifest file (hash, refcount, size per line) is rewritten in full on every change - simple and correct at the scale this targets, not an index designed for tens of thousands of blobs. Notes and limitations - The content fingerprint is a 16 hex-digit double-pass FNV-1a, not a cryptographic hash - adequate for accidental-duplicate detection, not for tamper-proofing or adversarial contexts. - The manifest is rewritten in full on every Put()/Release(). Fine for the dozens-to-low-thousands of blobs a single tool realistically produces; not designed as a high-volume index. - Storage lives in MQL4's sandboxed Files folder (or Files\Common with useCommonFolder=true) like every MQL4 file operation - it cannot write outside that sandbox. - No money is at risk. This library only reads and writes files.
Script · MT4 · v1.0 · Free
About Content Addressed Blob Store
Content Addressed Blob Store is a script for MetaTrader 4. MQL source code included.
Files in the download: ContentAddressedBlobStore.mqh, ContentAddressedBlobStore.txt, ContentAddressedBlobStoreDemo.mq4.
How to install
- Download the ZIP from your PolyMaria library and unzip it.
- In MetaTrader 4 open File → Open Data Folder, then go to MQL4 → Scripts.
- Copy the .mq4 file(s) there. Put any .mqh files in MQL4 → Include.
- Open the .mq4 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
- Drag the script onto a chart to run it once.
Tags: MT4 Script · MQL4 Source Code