Data reactivity / polling

Dear all!

I was wondering how a frontend would know that data was updated, e.g. a scratchpad. Is there some way to listen to changes in autonomi with typescript?

Or should I just poll / frequently query a scratchpad of my interest and if so, what is a reasonable frequency that autonomi can handle?

2 Likes

I’m actually starting to think about this right now :smiley: In my opinion, I don’t think this is a task that should be done purely with Autonomi, especially with the state of scratchpads today. From a high level, the network is handling data reads for free. When we have millions of users spamming reads to check for status updates it will slow the whole network down for very little value for the user and 0 value for the node runners.

I asked on the Veilid discord channel about how I could send out a broadcast message to all instances of Colony and what I got was this:

if there’s a ‘closed group’ that you can associate your notifications with, you could use a dht record for the group. and then when someone in the group writes to the record, others could get a watch_dht_values() notification for when the record change that would limit the blast radius, and get you the effect you’re looking for. people would subscribe to your group by you handing them a dht secret key and then they could write notifications to the record created for your group and subscribe to changes to that record with the lastest announcements. anyway, the magic you’re looking for is watch_dht_values, check the rustdoc and you can read on it.

So instead of a broadcast message, I’m thinking each time a user subscribes to a ‘pod’ (which is basically just a scratchpad), they request being added to this DHT group and they can watch for updates using the veilid system, which is designed for these fast P2P messages. When an update is found, then the user reads the new scratchpad data from Autonomi.

5 Likes

@zettawatt Check out gossipsub which is included in libp2p that autonomi uses:

4 Likes

I am not familiar with what veilid is, and I am not sure that I really understood what you are proposing…

Are you saying that instead of polling (just frequently reading) the scratchpad, I could go one level deeper and listen to broadcasts of a certain type on the autonomi network level? Then, when I receive a message that the scratchpad changed, I can read the scratchpad content?

This avoids unneccessary polling when there were no changes.

Not exactly. What I’m saying is Autonomi doesn’t support this kind of messaging currently, not at the app level at least. Veilid is a different P2P library that does do messaging and it is made such that it is somewhat easy to plug in at the applciation level.

@safemedia rightly points out that libp2p also does this and is the lower level library that Autonomi uses to pass messages around. I haven’t read enough about libp2p to know if this is the right answer or not, I have more reading to do :smiley:

All that to say, you’ll need something else for the time being unless Autonomi adds this messaging capability.

1 Like

I suspect just polling every few seconds is an easy place to start. You could always add something more clever later, if/when it becomes a problem.

2 Likes

And a thought using some of the above. If an App is keeping a lot of scratchpads, then it could be updating them and also updating another scratchpad with which scratchpad was just updated. The users then just poll that one scratchpad every few minutes and then they know which scratchpads were updated without needing to poll multiple scratchpads to see if an update has occurred.

One scratchpad to rule then all, so to speak.

So say for a anttube app, one person’s channel can have a scratchpad per vid and collections and so on. That channel then has one scratchpad that is updated whenever one of the (multitude) of the scratchpads for the channel is updated. So subscribing to the channel has only the need to look at one scratchpad to see if something was updated

4 Likes