Open estebanabaroa opened 10 months ago
Are we able to implement this at the moment or do we need to modify Kubo?
Are we able to implement this at the moment or do we need to modify Kubo?
I believe we would implement this in javascript only for now, because writing it in go would be pretty complicated, and most people use the browser/mobile version anyway.
I wrote an example of how to use the fetch protocol here to add persistence to ipns over pubsub (@helia/ipns doesnt have it yet) https://github.com/estebanabaroa/custom-pubsub/blob/master/demo3.js
It works but I wasn't able to make it interoperate with kubo, so I might be doing something wrong. I will write a more direct example of how we would use pubsub and the fetch protocol when I have time, so you could wait for that to start working on it.
I think instant replies is fairly high priority to get a prototype working though, so that plebchan can work more like 4chan. We should work on it soon imo.
the value received is (all peers must store the last answer they have and answer the fetch protocol with it)
CommentUpdate { cid: string signature: Signature sequenceNumber: number (first reply is 0, last reply is the previous children count) }
we probably actually want to send the full {comment, update}
similar to PageComment
type of the protocol, this way peers dont have to fetch the comment from IPFS, though peers probably want to add the comment to IPFS when they receive it, so they can seed it, for people who join the pubsub late and haven't received all the comments.
which means
challenge verifications must contain
challengeVerificationMessage.publication.update
:
challengeVerificationMessage
should probably be something like challengeVerificationMessage.comment
and challengeVerificationMessage.commentUpdate
steps to get instant replies:
assuming the user calls
plebbit.createComment({pubsub: true, cid: 'Qm...'})
andcomment.update()
join pubsub
/last-reply/Qm...
/last-reply/Qm...
using libp2p fetch protocolthe value received is (all peers must store the last answer they have and answer the fetch protocol with it)
validate the sub comment update signature
the last reply has the highest
reply.sequenceNumber
(property added by sub owner)whenever the last reply changes, download all the replies you don't yet have by scrolling
reply.previousCid
emit comment
'update'
event by adding the new replies to thecomment.replies
for as long as the user is joined to the pubsub, keep listening for new replies and emitting updates. possibly implement comment.pubsubStop() or just use comment.stop() which already exists to leave the pubsub.
steps to publish instant replies:
assuming the user calls
plebbit.createComment({pubsub: true, parentCid: 'Qm...'})
andcomment.publish()
publish comment normally, and wait for challenge verification. challenge verifications must contain
challengeVerificationMessage.publication.update
:join pubsub
/last-reply/Qm...
/last-reply/Qm...
using libp2p fetch protocol ifsequenceNumber
is lower than your sequence number, publish your own comment update received from the sub ownerspam mitigation
random people can't spam because all the comment updates are signed by the sub owner and have a sequence number, so not signed or duplicate comments can be ignored/blocked from the pubsub