Export low level functions for feeds and soc
Hi, currently some very useful low level functions are not exported. To list few: makeSingleOwnerChunkFromData, uploadSingleOwnerChunkData, recoverChunkOwner and downloadSingleOwnerChunk from the soc api, and makeFeedIdentifier, uploadFeedUpdate, downloadFeedUpdate, etc, from the feeds api.
Have those functions exported could allow developers to create more powerful dapps using bee-js. For instance, I want to control the index of a feed, but I cannot do that with the current api. On the other hand, if functions like findNextIndex and uploadFeedUpdate were exported I could do that.
Some dapps will have a different way to create and manage chunks and would be nice if bee-js was flexible enough to allow that.
So I'm wondering if these functions can be exported. Currently, I'm forced to basically replicate most of the feed and soc functions in my own code just to be able to manipulate few parameters like the index since most of these functions have a high level of dependencies between themselves and they are not exported. This seems to remove the necessity to use bee-js as a library for my app.
There is any way that I can manipulate the index of a feed for example? Or get the owner of a soc in the current api?
Indeed the low-level details of soc and feeds are not exposed because we did not see clearly how people would use them and what would be a good level of abstraction.
Could you please share an example of what exactly you are trying to do?
Without knowing that I can suggest that manipulating the index of a feed can be done by writing single owner chunks with the SOCWriter interface because that is the underlying primitive for feeds. The owner of a soc can be get by invoking owner() on the SingleOwnerChunk interface, but I assume you need something else.
Could you please share an example of what exactly you are trying to do?
Sure, I want to download a feed update at a specific index. I know that it is possible to do using the downloadFeedUpdate method, but it is not exposed.
This function would allow me to do range queries in my feeds, which are necessary for my application to fetch a list of "email chunks" (each one is a feed update) in a specific interval.
Without knowing that I can suggest that manipulating the index of a feed can be done by writing single owner chunks with the
SOCWriterinterface because that is the underlying primitive for feeds.
Hum... so if I understand it correctly, I could read a feed update in a specific index using the SOCReader, since I can control the identifier and thus the index, right?
Like, to read a interval using the SOCReader I would need to retrieve the feed update in the last index in my interval, and incrementally query each previous update until the beginning of the interval.
There is any plans to support stream of feed updates?
The owner of a soc can be get by invoking
owner()on theSingleOwnerChunkinterface, but I assume you need something else.
But given that I have the data of a chunk how to get the owner? I would need to create a SingleOwnerChunk type from this data to use the owner method, but makeSingleOwnerChunkFromData is not exposed, so I cannot create one.
Hum... so if I understand it correctly, I could read a feed update in a specific index using the
SOCReader, since I can control the identifier and thus the index, right? Like, to read a interval using theSOCReaderI would need to retrieve the feed update in the last index in my interval, and incrementally query each previous update until the beginning of the interval.
Right now the only type of feeds that are implemented in Bee are sequential type, meaning that if you know the index of the latest feed update you will immediately know how many updates were and can easily fetch any of them by using their numeric id.
In bee-js there is only one utility function regarding working with sequential feed indexes (makeSequentialFeedIdentifier), but if you want to do the above functionality for incrementing/decrementing for now maybe it's better to roll your own.
There is any plans to support stream of feed updates?
There is ongoing work to add stream uploading of chunks but not downloading them as far as I know. The best option right now is to issue multiple requests parallely.
But given that I have the data of a chunk how to get the owner? I would need to create a
SingleOwnerChunktype from this data to use theownermethod, butmakeSingleOwnerChunkFromDatais not exposed, so I cannot create one.
That's correct, this functionality is not yet exposed. We are currently researching how it would be best to expose this functionality, we are considering creating separating packages that could be possibly used without even using bee-js. Stay tuned!
Thank you very much. Yeah, I just started to do my own implementation of it here, but I'll definitely keep a eye on the next releases.
@r0qs we plan splitting of bee-js into several modules to better support low level operations as you would need. Please have a look https://github.com/ethersphere/bee-js/issues/413 and leave your feedback!