How does Bitcoin work? #2

Hello everyone! Welcome to "Prime Numbers". Today I want to briefly talk about how Bitcoin works. Let's take Alice to transfer coins to Bob, and Bob also wants to transfer some coins to Charlie as an example. let's see. Here are some nodes to represent the Bitcoin network. Real networks can be much larger than this. Can consist of hundreds of thousands to millions of nodes. Here is a simplification to explain the problem. Not every node is connected to all nodes. It will only interconnect with a few adjacent nodes. For example, node #1 is connected to #2 and #3. Node #2 is connected to #4, #5. Node #3 is connected to #5 and #6. #4 is connected to #6. At this time, there is a person named Alice. She has a mobile phone with a bitcoin wallet installed and she wants to transfer some bitcoins to Bob. She can send this transaction signed with her private key to any node in the Bitcoin network. Here she sent it to node #1. Whenever a node receives a transaction request, it will use the Gossip protocol to spread the transaction to all Bitcoin nodes like a flood, starting with the neighbors of this node.

Node #1 will first send this transaction to nodes #2 and #3. After node #2 receives it, it will propagate it to #4 and #5. After that, node #4 will propagate it to #6. In order to prevent endless propagation, if a node has already propagated, then it refuses to receive and also Refuse to forward. Because each transaction has a unique hash value, it is easy to know whether the transaction is already in the pending transaction pool by comparing the hash value. Through this, all nodes of the Bitcoin network have this transaction. This does not mean that the transaction has been placed in the blockchain. This is just a request for this transaction. Let's add something Bob wants to transfer some bitcoins to Charlie through his computer and his transaction is sent to another node #5. Node 5 receives this transaction and it propagates to nodes #2 and #3 . Node #2 will propagate to Node #1 and Node #4. Node #3 will propagate to Node #6 Not all nodes have the same pool of waiting transactions they can be completely out of sync.

For example: Node #1 can have a transaction that others do not: C transfers to D. Node #4 can have another transaction: D transfers coins to E. None of this matters. Because different nodes of Bitcoin are distributed in different geographical locations. At the same time, all nodes are selecting some transaction packaging blocks because each block has a capacity limit and each block can only contain a part of the transaction. Say node #1 wants to pack these two transactions into a block. Node #4 wants to pack these two transactions into a block To generate a new block, Bitcoin has a mechanism called "Proof of Work".

You have to guess a number, put this number in the block and then calculate the hash value for the entire block. The first many digits of the hash value must be 0. How many 0s there are can be adjusted according to the difficulty. Assume that node #1 successfully guessed the number at this time, and after generating a block, it will use the same Gossip protocol to spread it out "I have a new block here, everyone quickly add it to your own block" block chain" It will first add this block to the end of its block chain and then notify node #2 and node #3. Node #2 will do the same thing: it will first verify this block, verify the For the transaction, verify whether the guessed number is calculated with this number and the hash value meets the requirements . If everything is normal, this node will also add this block to its own block. After this, all nodes will put this The block added to the end of the blockchain is the "consensus mechanism".

The consensus mechanism is that even if each node has different waiting transactions and will generate its own block, in the end everyone will reach a consensus which block is added to the blockchain, and there may be two nodes generating blocks at the same time. Blocks are legal and correct. But the Bitcoin consensus mechanism only recognizes the longest blockchain. So even if there is a soft fork, it will be determined by the position added in the next block to determine which is the legal blockchain.

Based on the fact that all nodes only recognize the longest one. We have already talked about several important Bitcoin concepts such as: block, transaction, consensus mechanism, P2P network but only briefly mentioned. I'll cover these concepts in depth in a follow-up video Thanks for watching! Leave a message and tell me what you want to see. If you like it, welcome to subscribe to my channel! Thank you 🙏!.

As found on YouTube

You May Also Like