Add notifications about produced block and change of last irreversible block
Notifications about produced block
It would allow to rewrite Node.wait_for_block_with_number
and Node.wait_number_of_blocks
based on threading.Event
set on notification about produced block. Current implementation polls (checks in loop) block number with database API get_dynamic_global_properties
method and wait 1s if it's still not requested block. With notification waiting can be a shorter, because with 1s delay, in the worst scenario you have to wait 1s after requested block was produced. It is different with notifications, because they are send immediately and immediately can interrupt waiting.
Above speed up is important in following case. When I run node speed up few times with libfaketime, current implementation caused problems, because was sleep too long. During 1s sleep too many blocks were produced. With notification will be received immediately, so even with speed up node, waiting should be precisely enough.
Notifications about last irreversible block
It would allow to wait until requested block became irreversible. I am not sure if this is needed, but surely below case is.
Common case in tests are waiting, until block containing last operation will become irreversible. Currently testers write something like below:
node.wait_number_of_blocks(21) # Waiting until above transactions become irreversible
It would be nice to be able to write something simple like:
node.wait_until_current_block_become_irreversible()