I am trying to understand the blockchain and I have read a bunch of these explanations, but they all don't address some of the questions I am still wondering about. So first I'll explain what I know, and then list out some questions.
There is a ledger with everyone's transactions on it.
The ledger is duplicated on each node in the network.
Some nodes are
miners. Nodes just store them and have other things read and update it. Miners create blocks and send to all nodes.
So say Alice has only $10 and gives $10 to Joe and $10 to Bob.
Two entries are sent to the network which is
Now every node will have pending transactions of either
A consensus happens to decide which of the two should be added first. (is it to figure out which happens first and second or which to accept and which to reject like not add to chain at all?)
The miners will keep hashing the
Alice->$10->Bob depending on which one the miner has. They keep doing it until a miner has a hash that is considered valid.
For the first valid hash of a miner, that miner sends that transactions to every node as a valid block, and all nodes just add it to their chain if it looks valid (they check too). Lets say
Alice->$10->Bob got mined first, and added to all nodes.
Now the blockchain knows Alice has no money left.
Alice->$10->Joe gets mined, and sent to everyone, but they all reject it because Alice has no money left (this part I'm not sure about).
Or is it that both transactions get mined, but which ever the majority of miners are for a certain transaction after 10 minutes, that transaction is added and the other is rejected?
I'm still confused about how the consensus part works. How the majority part works and how things get mined. How does it work, if only 1 unique transaction goes in the network like
Alice->$10->Joe and not