anders94 / blockchain-demo

A web-based demonstration of blockchain concepts.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Valid Balance and more...

zverbatim opened this issue · comments

First of all : Great project !

Question #1: Please details how transactions are validated (there are sufficient funds)
In video you mentioned if user A received in previous block $10 than in the next one can transfer $2.
What if user A besides receiving $10 also transfer those $10 in previous block?

Question #2: Please explain how peers synchronize their chains?

Question #3: Do you plan to add the functionality to add "Blocks"?

Thanks

Question #1: Peers follow the network's rules to validate. If a user has already spent their money, a new spend of additional funds that they wouldn't have would be considered invalid. Blocks containing transactions like these would be considered invalid and wouldn't be propagated to other peers on the network. Nobody else would hear about these blocks and nobody will consider them part of the valid blockchain.

Question #2: Peers synchronize their chains by communicating directly with a random set of other peers. When they first connect, they exchange information on the longest chain they know about. If another "has a longer chain", the peers that don't have the newer blocks ask for each block they don't have, validating it before adding it to their copy of the chain. Eventually everyone becomes synchronized.

When new blocks are created, the miner that created the new block tells the random set of peers it is connected to about it. As other peers hear about it, they independently validate the new block, adding it and telling other peers about it if it satisfies the network's rules. If it doesn't pass the rules, the peer doesn't tell other peers about it and that block languishes in obscurity.

Question #3: I don't currently plan to have adding blocks as part of the demo. I may decide to touch on it though if there is significant confusion about it.