kevacoin-project / kevacoin

Kevacoin source tree
https://www.kevacoin.org
MIT License
32 stars 16 forks source link

Publish and Subscribe APIs for Keva events #8

Open kevacoin-project opened 4 years ago

kevacoin-project commented 4 years ago

When developing applications on Kevacoin, it is handy to be able to subscribe to certain Keva events. For example, a Twitter-like application on Keva blockchain can listen to the event that a user follows the other user. Assume that the follower adds a key to her own namespace (N_follower) to indicate that she is following the other user whose namespace is N_celeb:

keva_put  <N_follower>  <N_celeb>  true

The application listening to this kind of event will be notified, and then when N_celeb publishes a new update, the application will notify the follower.

Similarly, if the follower stops following, she can set the value to false:

keva_put  <N_follower>  <N_celeb>  true

The application will also receive this event and stop send her the updates.

Note that the data is completely on the blockchain and the application can be written by anyone. The developer of the application has no monopoly on the data. The pub/sub APIs make it easier to develop applications, though technically the data on the blockchain provides sufficient information and is the single source of truth.

Bitcoin has APIs like walletnotify and blocknotify, and ZeroMQ for publishing several kinds of events. We can probably build on top the APIs for Keva events.