Transactions are collected from the Mempool and stored at a specific block. This blog is trying to detect each block’s mempool, such that we will know what kind of transactions will be collected.
This part is going to detect new Bitcoin blocks. The mechanism is as follows: we detect whether there is a new block created every 2 seconds. If yes, the terminal prints a signal like “find a new block!!!”; Otherwise, the terminal prints a signal like “updating unconfirmed transactions”.
The key implementation used the command bitcoin-cli getblockcount
to get the height of blocks. The source code is named “new_blocks_detector.py”.
$ python new_blocks_detector.py
updating unconfirmed transactions
updating unconfirmed transactions
updating unconfirmed transactions
updating unconfirmed transa