A libp2p protocol for handing a signed dataset to another peer that can serve
it as a verifiable replica of the original publisher.
A publisher proves it holds an IPNS key, sends a signed IPNS record, waits for
the handler to accept it, then streams a CAR of its content. The handler
verifies the signature and the content, then hands the record to your
application to pin and serve. The result is a durable, verifiable copy that
stays available even while the publisher is offline.
The CAR format sets no maximum of any kind, so every size limit is yours to
choose and CarLimits requires all four. maxByteLength and maxBlockCount
are zzzync's own and accept Infinity for no cap. maxCarSectionSize and
maxCarHeaderSize go to @ipld/car, which rejects Infinity, so pass its
own defaults (8MiB and 32MiB) to leave those alone.
consthandler = createZzzyncHandler( helia.libp2p.peerId, car(helia), { // gate which keys may push, and which records to accept multihash: (name) => { constkey = publicKeyFromIpnsMultihash(name) returnkey != null && myAllowList.has(key.toCID().toString()) }, record: (name, record) =>true, }, { maxByteLength:5 * 1024 * 1024, maxBlockCount:10_000, maxCarSectionSize:2 * 1024 * 1024, maxCarHeaderSize:1024, }, async ({ name, record, pinner }) => { // record is signature-verified and its CAR fully validated; // pin the content, persist the record, then serve and announce it }, { // the cap in force is min(maxByteLength, minBytesPerSecond * maxStreamMs), // so the default 1KiB/s floor would hold the 5MiB above to 3.52MiB; // 2KiB/s makes it actually reachable, in ~43min minBytesPerSecond:2048, // byteStream buffers ahead of the importer, so keep this above // maxByteLength or a fast sender trips the buffer before the size limit maxBufferSize:6 * 1024 * 1024, }, )
// sign a record for the content, then push both to a handler peer. Publishing // through @helia/ipns instead gives you a protobuf IPNSEntry, so unmarshal it // before passing it here. constrecord = awaitcreateIPNSRecord(privateKey, cid, 0, 3_600_000)
A libp2p protocol for handing a signed dataset to another peer that can serve it as a verifiable replica of the original publisher.
A publisher proves it holds an IPNS key, sends a signed IPNS record, waits for the handler to accept it, then streams a CAR of its content. The handler verifies the signature and the content, then hands the record to your application to pin and serve. The result is a durable, verifiable copy that stays available even while the publisher is offline.
The CAR format sets no maximum of any kind, so every size limit is yours to choose and
CarLimitsrequires all four.maxByteLengthandmaxBlockCountare zzzync's own and acceptInfinityfor no cap.maxCarSectionSizeandmaxCarHeaderSizego to@ipld/car, which rejectsInfinity, so pass its own defaults (8MiB and 32MiB) to leave those alone.Example: Receive pushes (handler)
Example: Push a dataset (dialer)