Client WebSocket events for blocks and balances in ADAMANT Node #65
massivedev0
started this conversation in
ADM Nodes, Delegates & Pools
Replies: 1 comment
-
|
Well done! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
We implemented two related client WebSocket capabilities for ADAMANT Node:
newBlockevents for successfully applied and saved blocks;balances/changeevents for confirmedbalanceandunconfirmedBalanceupdates.The implementation is available in Adamant-im/adamant#264, with synchronized documentation in Adamant-im/docs#35 and an OpenAPI 3.2 companion contract in Adamant-im/adamant-schema#48.
This work addresses Node issue #256 and Node issue #217.
Client subscription contract
The client API uses Socket.IO rather than a bare WebSocket connection. Subscriptions are scoped to one socket and must be restored after reconnecting.
New block events
Clients explicitly enable block notifications:
newBlockcontains a compact public header: block ID, height, timestamp, generator public key, transaction count, total amount, total fee, and reward. It intentionally omits the transaction list, signatures, and payload hash; clients can request the full block through REST when needed.The node emits this event only after the complete block application pipeline succeeds and the block is saved. Historical replay and memory-table rebuilds do not produce live-looking block events.
Balance change events
Balance delivery requires both an address subscription and an explicit field subscription:
Example payload:
{ "address": "U1234567890123456", "balance": "100000000", "unconfirmedBalance": "99900000" }The payload includes only subscribed fields that changed. Values are decimal strings in 1/10^8 ADM units and currently use the same numeric account representation as the REST API.
balancerepresents confirmed blockchain state.unconfirmedBalancealso reflects the node's current unconfirmed pool and may change when transactions are accepted, confirmed, expired, rolled back, or revalidated.Delivery and performance design
The main implementation goal was to add useful events without turning every account mutation into a scan of every connected socket or an unnecessary database read.
The changes do not modify consensus rules, block or transaction serialization, signatures, IDs, database schemas, rewards, fees, or peer protocol behavior.
Best-effort event semantics
These events are low-latency notifications, not a durable event log:
We did not introduce an arbitrary silent per-socket subscription ceiling in this change. The current API has no acknowledgement mechanism for partial rejection, so a resource limit should be a separate configurable and documented contract with explicit client feedback.
Validation
Validation included:
The longest unrelated test suites were intentionally skipped because this feature does not change consensus validation, serialization, SQL, peer transport, or REST endpoints.
References
newBlockissue: Adamant-im/adamant#256modules/clientWs.jsapi/websocket.mdx-client-websocketBeta Was this translation helpful? Give feedback.
All reactions