hyperspace
hyperspace copied to clipboard
Allow to track sparsely synced hypercores
Currently, the daemon emits an append event if new blocks are appended to a hypercore (either locally or by a remote for synced cores). However, no event is emitted when new blocks are downloaded for a sparsely synced hypercore.
I'd like to explore kappa-style apps on top of hyperspace that would index all downloaded blocks on a set of hypercores. For that to work efficiently, I think two things would be needed:
- [ ]
OnDownloadmethod for the hypercore service that is emitted for each block downloaded with{ id, seq }. Maybe this method should only be called if requested for a hypercore? SoWatchDownloads({ id }),UnwatchDownloads({ id })andOnDownload({ id, seq }). Or just emit it always, asOnAppendis at the moment. See #5 - [ ] A way to quickly access which blocks have been downloaded for a hypercore, so maybe a
GetBitfieldor similar. This can be worked around by iterating and callingHasfor each seq, which might be good enough. (This will be needed on each startup of the indexer client, because it cannot know if download events happened while it wasn't running). See #7