[mkdocs] docs: add listen new blocks tutorial#910
Conversation
| For each message, the snippet prints two of its fields: | ||
|
|
||
| * `height`: The height of the new block. | ||
| * `signer`: The public key of the <harvester account:> that produced the block. |
There was a problem hiding this comment.
Unlike Symbol, NEM doesn't return the block hash in the response, so I'm printing the harvester public key instead.
| A NEM block does not include its own hash in this payload, so this tutorial identifies each block by its `height` | ||
| and also prints the harvester's `signer`. | ||
|
|
||
| !!! warning "New blocks are not yet final" |
There was a problem hiding this comment.
Unlike Symbol, I'm not showing how to determine whether a block is irreversible, since NEM has no dedicated channel for it. Instead, I'm linking to the polling tutorial, where it's already explained in enough detail.
| print(f'Using node {NODE_URL}') | ||
|
|
||
|
|
||
| # SockJS has no Python client library. |
There was a problem hiding this comment.
There's no sockjs-client library for Python, so I had to write some helper functions to achieve the same functionality as in JavaScript.
| import { Client } from '@stomp/stompjs'; | ||
| import SockJS from 'sockjs-client'; | ||
|
|
||
| const NODE_URL = process.env.NODE_URL || 'http://ntn1.dusanjp.com:7778'; |
There was a problem hiding this comment.
I'm using this other node because libertalia does not have websockets enabled at 7778. I'm asking in discord if there's a way to enable them for consistency.
Adapt listen new blocks tutorial to NEM.