Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a publish/subscribe api for blockchain events #2354

Open
ecioppettini opened this issue Jun 11, 2020 · 2 comments
Open

Add a publish/subscribe api for blockchain events #2354

ecioppettini opened this issue Jun 11, 2020 · 2 comments
Assignees
Labels
A-jormungandr Area: Issues affecting jörmungandr enhancement New feature or request

Comments

@ecioppettini
Copy link
Contributor

Add a publish/subscribe api for blockchain events

Idea

Have a node service/module that allows to subscribe to blockchain events
that can be used for things like an external explorer/blockchain indexer, wallet backend, etc.

Interesting Events

  • New block
  • Tip changed

Steps

  1. Create a new message box in the node just like in the explorer, and
    propagate the necessary events (one of those is basically what's done for
    the explorer right now).

  2. Add a new warp handler for websockets at ws://host/notifier

    Basic idea

    • the handler will listen for new connections
    • at each local event will send a message to all the
      connected clients

    The messages will be (for now)

    • NewBlock(blockid): Passing id's here means that the actual block will
      need to be obtained from somewhere else, but that's already needed
      for bootstrapping (getting blocks from 0..tip), so it may be
      enough to solve that problem there
    • NewTip(blockid)

    All messages are one-directional. Node -> Connected clients. Clients can't
    publish things.

  3. Add new settings to configuration.

max_connections: maximum number of subscribers at the same time

Questions

Do we want the clients to be able to subscribe to specific
messages/topics/channels?
How should we encode the messages? Using a binary format? text? If we only send
ids it's not much of a difference, though.

@ecioppettini ecioppettini added enhancement New feature or request A-jormungandr Area: Issues affecting jörmungandr labels Jun 11, 2020
@ecioppettini ecioppettini self-assigned this Jun 11, 2020
@gufmar
Copy link
Contributor

gufmar commented Jun 20, 2020

I have no experience with ws and so not sure if this makes sense, but reading about 'able to subscribe to specific messages/topics/channels' let me think about MQTT. Their clients and brokers already implement topics and subscriptions. There are plenty of client implementations. Lightweight. Standardized.

@gufmar
Copy link
Contributor

gufmar commented Jun 20, 2020

Looks like websockets and mqtt can be combined: http://www.steves-internet-guide.com/mqtt-websockets/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-jormungandr Area: Issues affecting jörmungandr enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants