Into the open source code (1)

Into the open source code


table of Contents

Into the open source code

Preface

Where to start?

to sum up


Preface

       Today is a special and young festival-Double Eleven (Chop Hand Festival), which is also a memorable beginning! I took the system architect exam last week, and the paper was not finished. Although I will definitely not be able to pass this time, it can be considered as an experience. The paper must be practiced in advance, otherwise I want to write 3000 words within 2 hours— —Equivalent to writing a word in 2 seconds, which is still very nervous.

      As an old programmer, I have coded a lot of code, but there is no good quality, that is, I am more proficient. Look at the code a little faster. Now open source code has become a treasure trove for people who love technology, love to share, and are diligent in exploring. Therefore, I want to squeeze some time to learn the code of some open source projects and record the learning experience for reference and exchanges with friends who also love code.

      In recent years, blockchain technology has received more and more attention from various countries. In 2017, by chance, I learned about the concept of blockchain, and then I borrowed a few books about blockchain from the library to learn more about it. After reading it, I was shocked. I vaguely felt that the decentralization of blockchain, the digitization of assets, and the transfer of value will revolutionize the financial field. It can also be combined with other technologies such as the Internet of Things, 5G, and artificial intelligence. , And ultimately have a huge impact on other industries and fields. As the representative of Blockchain 2.0, Ethereum was developed using Go language, so I started to learn Go language by myself and joined a blockchain company.

      Although I later left the company for some reasons, I have always been concerned about the development of blockchain technology, and I firmly believe that the future of blockchain technology is unlimited. So the decision is to start with Bitcoin, the pioneer of blockchain technology!


 

Where to start?

Open source code is usually relatively large, and the source code of Bitcoin is no exception! I won’t go into details about the introduction of blockchain and Bitcoin. There are also many introductions to the source code of Bitcoin on the Internet.

First, I reviewed the paper "Bitcoin: A Peer-to-Peer Electronic Money System", and then referred to this article . Bitcoin's architecture is not like the current popular microservices and C/S, B/S three-tier architecture. This is because the blockchain is based on a P2P (Peer-to-Peer) network. The overall Bitcoin architecture The above is divided into two parts, one is the front end, including wallet or graphical interface; the other is the background program running on each node, including functions such as mining, blockchain management, script engine, and network management.


to sum up

As the saying goes, "The sparrow is small, but it has all five internal organs." As Blockchain 1.0, it really solves the problems mentioned in the paper:

1. How to prevent double payment in the absence of a trusted third party? ——All transactions must be publicly released, and a system that allows all participants to agree on a single history of the order in which transactions are received is required.

2. How to maintain a unified "ledger" in a distributed system and ensure that the "ledger" is not tampered with? ——Each node only recognizes the longest chain consisting of the hash value containing the timestamp information.

3. How to ensure the "liveness" of nodes in the blockchain? ——Reward the nodes that calculate the fast hash value of the new block, that is, reward the "miner". The process of calculating the hash value of the new block by the "miner" is called "mining".

Bitcoin is the well-deserved boss. Solving the above three problems is an important reason why it has been ups and downs over the past 10 years.

Guess you like

Origin blog.csdn.net/huanggang982/article/details/109632663