For the full breakdown, see Understanding the pending block on Ethereum.
Now let's have a hands-on walkthrough in Python. Here's what we are going to do:
- Check the version of the node we are connected to.
- Fetch a pending block and its number.
- Feth the latest block with the same number.
- Compare transactions in the pending and latest blocks.