there is something that I don't understand very well and I hope you could help me. Just imagine there are 2 nodes (node A and node B), each maintains a list of unverified transactions
* Node A has tx1, tx2 and tx3
* Node B has tx1, tx3 and tx4
Then they both decide to include them all in a new block and start mining. Node A finds the hash first so, it includes its block in the blockchain and publishes it. That is what I understood however I don't know how Node B should behave because it has 2 transactions in common with A.
Exactly the same way as it should if it has 0 transactions in common with A (or all of its transactions in common with A). The number of transactions in common doesn't matter.
Yes. Always. As soon as you receive a completed block, you should stop mining the block you were working on, and should begin mining a new block.
- How do nodes decide how many transactions to include in a block?
It is up to the solo miner (or mining pool) to choose which transactions they want to include. Most polls (and solo miners) run software that makes those decisions based on some pre-set conditions configured in the software.
Thank you, @DannyHamilton.