Streaming Subscriptions
Watchtower will continue to augment his suite of Streamed data. Please find below a list of the available subscriptions Watchtower exposes.
HCS Topic Subscription
/com.hedera.mirror.api.proto.ConsensusService/subscribeTopic
- Allows for real time streaming for topics from the mirror node
HCS Get Nodes
/com.hedera.mirror.api.proto.NetworkService/getNodes
- Allows for real time streaming for available nodes
HCS Account Balance Subscription
/proto.CryptoService/cryptoGetBalance
- Allows for real time streaming of account balance with zero syncing lag.
More coming soon!
To subscribe any stream, from client side we will emit subscribe
with payload and callback. Payload will contain the path to the service to subscribe and the body of the request. Callback will be called with the response of the subscription.
const payload = { // path to which service to subscribe subscribe: '/com.example.service/subscribeTopic', body:{ // body static references available in the docs }}socket.emit('subscribe', payload, (callback: any) => { // callback will be called with the response of the subscription // Example callback response //{ // "uid": "97f196b1-dc2c-4525-a314-be5e58a09f6a", // "listeners": { // "data": "data-97f196b1-dc2c-4525-a314-be5e58a09f6a", // "error": "error-97f196b1-dc2c-4525-a314-be5e58a09f6a", // "end": "end-97f196b1-dc2c-4525-a314-be5e58a09f6a", // "status": "status-97f196b1-dc2c-4525-a314-be5e58a09f6a" // }, // "meta": { // "subscribe": "/com.example.service/subscribeTopic", // "body": { // // body sent in payload for subscription // } // } // } // callback.listeners.data will contain the path to the data stream socket.on(callback.listeners.data, (data: any) => { // data stream }); // callback.listeners.error will contain the path to the error stream socket.on(callback.listeners.error, (error: any) => { // error stream });})