Consumer/Producer and server client



I have an app idea but I have some conceptual problem with Blockstack given I come from a relatively centralized background and I have no past experience with the platform.

My first problem is a classical consumer/producer CS problem. Indeed my app may have multiple producer client and many (but more likely one) consumer client.

The producer client will only produce data. And the consumer client will only read data.

I have looked into the gaia storage system and I have noticed there is only two method regarding file management : get and put. Thus the consumer producer problem : I cannot guarantee two clients won’t write at the same time and loose data.

An obvious solutions would be to write to a different file each time but then another problem is created.

Indeed, my client might write a lot of little data thus creating a lot of files. The consumer client will need to process this data in a timely manner which seems really hard if there’s a ton of files to load and process. Thus it would be great to create some kind of precomputed file each day or such processing all data created between the last pre computer file and current time. Then calculations would be way easier on the consumer client.

However I can’t see any way to create this cron like behavior in blockstack.

My second problem is that the producer client is not a browser : thus I need a way to generate a token and give it to to the producer client. I saw in the docs blockstack uses JWT token so I guess I can use those by some low level api to generate one with no expiration and give it to the server client a bit like an api key ?. Would it also be possible to restrict permissions of the producer client (can only create a new file…) ?

Re 1. problem:
In the decentralized world, your producer clients do not write to the same gaia storage because the producers have different ids/keys/addresses (do they?)
Therefore, you would need to somehow aggregate the files of all producers. There is Radiks that helps you to achieve that. (There is also a proposal for a p2p Radiks)

Re 2. problem:
Not sure what your setup is, but you could

  • hard code a seed phrase for each producer and then derive the address and authenticate with a gaia storage replying to the challenge. Or
  • use a scoped gaia authentication token so that all producers write to the same gaia bucket.

Note: The gaia storage provider can renew the challenge and therefore, your token could become invalid.

Thanks for your answer.

I forgot to specify one very important aspect of my app.
When I talked about clients I talked about the same blockstack users. I don’t care about gathering all users data, they can keep it encrypted for themselves.

:+1: Can’t be evil!

Haha exactly that’s pretty cool !
However how would you deal with the above problem of consumer/producer in the context of multiple clients acting on behalf of the same users so that data is never lost while keeping good performance for the data consumer/reader ?