Prototyping Blob Content
If you haven't read @aljoscha's thoughtful and insightful post on moving message content out of the sigchain, it may be useful backstory. The gist is that #offchain-content has many benefits but that the best possible implementation doesn't involve using the current blob mechanism. I agree wholeheartedly.
Instead, I've built the worst possible implementation, and I'd like to share it.
Private Unboxer
When secure-scuttlebutt sees a message with content
as a string, it passes it off to a function that translates that into an object by decrypting the content string. This means that you can query for messages with the type chess_chat
and you don't need to worry about whether the message was public, unboxed privately, or something else. Emphasis on the something else.
My first move was to create the ability to chain unboxers, so that multiple unboxers can work on the same message. My original intention was to add a blob_unboxer
that made a call to multiblob, but multiblob's async methods don't mesh well with flumelog-offset.
Blob Unboxer
I'm calling this the worst possible implementation for a reason: instead, I wrote a hacky reimplementation of multiblob.get
and added it as an unboxer. This does three simple things:
- Looks for a
content
property that starts with the blob sigil (&
). - Reads that blob into memory and attempts to parse it as JSON.
- Passes the result onto the next unboxer, and then to the database.
Gross
Yeah. It's gross. But it works! I want to be very clear about the fact that this is a hacky prototype that I hope will be immediately made obsolete, but if nothing else it's an interesting experiment in ergonomics. I've only prototyped viewing blob content, but my workflow for adding blob content is even worse:
- Attaching a JSON file.
- Copying the hash.
- Patching ssb-validate to allow my terrible message.
- Running
sbot publish $hash
. - Viewing the message.
I may be able to get away with skipping the first step, but I'm not very familiar with the specifics of blob replication and I want to make completely sure that my prototype blob is replicated for this post.
???
In the interest of iterative development, I'd love to hear some input on what my next steps should be (or whether this works for you). I think this can be tested by running npm i --save https://github.com/ssbc/secure-scuttlebutt#blob-unboxer
in your client directory. Unless the consensus is an overwhelming \"delete it\", I think my next steps will likely either:
- an asynchronous flumelog-offset codec
- a synchronous multiblob option/implementation
Anyway, that's all I've got. What do you think?
Note: It turns out that posting the proof-of-concept message actually crashed Scuttlebot for anyone who tried to replicate with me. I've opened an issue for the bug and deleted the post from my feed until I'm confident I can re-post without getting #marooned again.