Reasons for another notification interface
- Currently there is no interface that could be extended to “private” notification secured behind the authorization (like peers connected/disconnected or a new wallet relevant transaction notification)
- HTTP long poll notifications are very easy to set up and require almost no dependencies
- HTTP long poll notifications can easily pushed over the internet using httpd reverse proxy together with a popper authentication method (certs or http auth digest) together with TLS.
- HTTP long poll would allow connecting applications to do all kinds of things with just a single communication channel (currently you need RPC & ZMQ for most use cases which would require VPN or a fancy multi port stunnel connection to broadcast the notification over the internet)
How does it work
- The listener calls the
pollnotification
RPC command. - If no notifications are available, the RPC thread will idle for a given timeout (30s by default)
- If a notification was fired during the 30 seconds, the longpoll call will be responded with the new notification(s)
- The client/listener can immediately reconnect and wait again
- If notifications are already in the queue, the
pollnotification
command will immediately response. - Notifications can’t get lost (possible to lose them during http transfer and if one exceed the queue limit)
Downsides
- JSON encoding overhead
New RPC calls
setregisterednotifications [<notificationtype>]
(possible types are hashtx
and hashblock
)
getregisterednotifications
pollnotifications
Missing
- More tests
- Documentation
I’d like to use a such interface to work on a remote GUI (use case: GUI on your local desktop, node on a VPS).