plebbit / plebbit-js

A Javascript API to build applications using plebbit
GNU General Public License v2.0
41 stars 7 forks source link

Implement design to reduce amount of CIDs needed to reprovide #45

Open estebanabaroa opened 2 weeks ago

estebanabaroa commented 2 weeks ago

At the moment, each nested reply, and each subplebbit page is another IPFS CID that needs to be reprovided to the DHT every 24 hours.

To reduce this amount of CIDs to reprovide, we can make pages that few people consume (e.g. page 5+) very large, they could be 10-100mb each, and contain thousands of posts. They will be slower to load, but since few people need them, it's not a big deal. They can also be updated less often, it could be once a month e.g. for several years old posts.

We can also avoid making each nested reply a CID to reprovide by never fetching replies directly by their CID, we only fetch replies using post.replies pages.

Also most posts on reddit never have more than a dozen replies, so it's actually not necessary to create replies page cids, all the replies can simply be stored in post.replies.pages.top. For different sorts, they can be sorted by the client (since all replies are known).

It seems to work for all scenarios:

1. Fetch a seedit post

2. Fetch a plebchan post

3. Fetch a group chat like UI post (newest first, scrolling up)

4. Fetch update (votes/replies/etc) of your own nested reply

Rinse12 commented 2 weeks ago

Shouldn't we wait before thinking of a design until we figure out how to fix the DHT issues? Maybe we won't even need a DHT, iroh for example has a key-value document design that we can use for subplebbit record. The subplebbit would have all of its comment/page cids in the document, and the sub would update the page cids frequently within the document, without having to announce to a DHT.

The user can selectively load keys within a document, if they don't want to load the whole subplebbit record with all its pages/comments.

The question is how would the user discover the node ID of the publisher(s)? For that I think we can have a tracker-like system, or good old bittorrent DHT

https://www.iroh.computer/docs/components/docs