15Dkatz / cryptochain

Build a blockchain-based cryptocurrency on the full stack course
https://www.udemy.com/build-blockchain-full-stack
256 stars 221 forks source link

Orphan blocks and stale blocks #2

Open tejush1998 opened 4 years ago

tejush1998 commented 4 years ago

Hi, I subscribed through your course. I was wondering what happens when a transaction is stored in a stale block. Your code is assuming if once blockchain is broadcasted, it will automatically be part of the longest blockchain. What happens when that blockchain is not accepted and the block becomes a stale block ? The transactions will be lost Thanks

spayse commented 3 years ago

Actually, if you are connected to other peers, then you allready broadcasted the transaction. so, it should be included in the winning block.