Open guilhermelawless opened 5 years ago
Thanks for testing the WebSockets feature and initiating the discussion! The possibility of using it as an RPC came up earlier. Given the full duplex nature of WS we'd need a common request/reply correlation system, or look into something like the WAMP sub protocol.
For reference, I have the vote subscription here: https://github.com/guilhermelawless/nano-node/commit/5a40e4e379181fe896579656d6ad4f6de5d39611
Surprisingly easy to set it up; can PR whenever.
The vote subscription only provides a subset of the votes in the node, and does not separate by vote type (e.g. a replay, a locally generated vote, etc).
One idea would be to have multiple subscriptions to votes, possibly using the same options for each one.
Further ideas:
should_filter()
method for a vote message. Use-case example: analysing vote behavior during spam without getting huge amounts of data.PoW-related notifications: https://github.com/nanocurrency/nano-node/pull/2289
This adds the idea of incremental filter updates: https://github.com/nanocurrency/nano-node/pull/2566
The socket replacing HTTP callback is well built and can immediately support extensions with little development effort.
One way to extend will likely be to add account filters in order to minimize the number of unnecessary messages broadcasted to clients.
I would like to discuss if it is possible to add other kinds of extensions. One example I have already built is broadcasting all vote messages received:
Other extensions in mind:
In my opinion, having the power of getting notifications of any kind from the node to any service is quite powerful.
The discussion falls into the usual "Should we have addons in the node?". I would argue that developers have enjoyed the benefits of having a thorough RPC and by extension, this could help people analyze data by not requiring them to build a packet sniffer (and keep it updated with the protocol).
It is inherently optional as I have to actually subscribe to it through the websocket, specifying a topic.