Closed bonustrack closed 5 years ago
Agreed that it would be convenient to have but unfortunately due to the way streams are designed in node.js the data
event has only one argument. We could emit {block: .., id: 123}
but that would be an API breaking change.
However you can get the block number from the block_id
property. Like so:
const blockNum = Number.parseInt(block.block_id.slice(0, 8), 16)
Wow that's a great tip, i will definitely use that one. Thank you!
I'm trying to get the block number when streaming the chain so in case the server stop i can restart the streaming at the proper block number.
I'm using something like this to stream the chain:
The thing is that the
block
object may not include the block number, the block number is only visible in transactions array, which may be empty and not included in block object, example: https://api.steemjs.com/getBlock?blockNum=1000000Could we have the block number directly on the stream callback? Something like this: