Looking at the initial chain from the development process of blockchain
This article mainly introduces the relevant knowledge of blockchain in 200 lines of code. It is very good and has reference value. Friends who need it can refer to it
Recently, the topic of blockchain has been speculated It’s very hot. People who understand technology pay attention to the chain, while those who don’t understand technology care about the currency price. In short, blockchain is a new decentralized economic organization model implemented by a series of technologies. In fact, blockchain technology appeared as early as 2007. With years of improvement and perfection, we have the btc, eth, eos, and true we see now. In short, blockchain is a new decentralized economic organization model implemented by a series of technologies. This article aims to conduct some research from the perspective of consensus algorithms of blockchains in different periods.
1 POW represented by btc: Proof of Work, proof of work.
Bitcoin uses the POW mechanism in the Block generation process. A Block Hash that meets the requirements consists of N leading zeros. The number of zeros depends on the difficulty value of the network. To obtain a reasonable Block Hash requires a lot of trial and error calculations, and the calculation time depends on the hashing speed of the machine. When a node provides a reasonable Block Hash value, it means that the node has indeed undergone a large number of attempted calculations. Of course, the absolute value of the number of calculations cannot be obtained, because finding a reasonable hash is a probabilistic event. When a node has n% of the computing power of the entire network, the node has a probability of n/100 to find the Block Hash.
Advantages: safe, resistant to forks, the POW consensus currency represented by Bitcoin has been in existence for 9 years, and its security has been tested by time.
Disadvantages: Waste of electricity, not energy-saving, a large amount of electricity and computing power are used to compete for Bitcoin’s accounting rights, without making any contribution to the real society. According to incomplete statistics, the electricity required for Bitcoin mining now exceeds the average level of 180 countries. It is precisely because of this that POS appeared
2: POS: Proof of Stake, proof of equity.
POS: Also known as proof of equity, it is similar to property stored in a bank. This model will allocate corresponding interest to you based on the amount and time you hold digital currency.
Operating mechanism: The nodes in the network put the digital currency in the node into the POS mechanism, and the identity is changed into a verifier. The POS mechanism randomly selects one of these verifiers as the generator of the block. Of course, this randomness and input The number of digital currencies is related. The probability of being selected is higher if you invest more coins than if you invest less, which is basically proportional to the quantity ratio. Of course, within a certain period of time, if the generator selected by POS does not generate a block, then the next validator will be selected again. As for the effective chain, this follows the longest chain principle of the blockchain. Since in the POS consensus mechanism, there are tokens as collateral, when the system finds that the node is suspected of committing evil, the mortgaged tokens can be destroyed. Therefore, in the POS consensus mechanism, the security of the system is not provided by the competition of hardware computing power outside the system, but by the hardware computing power competition outside the system. Is based on collateralized tokens as a guarantee of honest nodes.
3 PBFT: Practical Byzantine Fault Tolerance, practical Byzantine fault tolerance algorithm. See the previous introduction to the Byzantine Fault Tolerance algorithm.
PBFT is a state machine replica replication algorithm, that is, the service is modeled as a state machine, and the state machine replicates replicas on different nodes in the distributed system. Each copy of the state machine saves the state of the service and also implements the service's operations. The set of all replicas is represented by a capital letter R, and an integer from 0 to |R|-1 is used to represent each replica. For the convenience of description, assume |R|=3f 1, where f is the maximum number of replicas that may fail. Although more than 3f1 replicas can exist, the additional replicas do not improve reliability other than reducing performance.
Chulian is the world’s earliest hybrid consensus public chain, which is characterized by combining pbft and pow consensus. Use the former to ensure performance and the latter to ensure decentralization. To put it simply, it is based on POW, and then the PBFT backbone node is elected on this node. Personally, I feel that integrating two different consensus algorithms is a very innovative idea. First select the main node based on POW to avoid excessive centralization, similar to the EOS super node, and then operate it under several main nodes later. Although it seems to be contrary to decentralization, this is also the efficiency at this stage. , a better solution that takes into account both performance and decentralization.
Recently, the topic of blockchain has been very hot. Those who understand the technology will follow the chain, and those who do not understand the technology will follow the chain. Pay attention to currency prices. In short, blockchain is a new decentralized economic organization model implemented by a series of technologies. In fact, blockchain technology appeared as early as 2007. With years of improvement and perfection, we have the btc, eth, eos, and true we see now. In short, blockchain is a new decentralized economic organization model implemented by a series of technologies. This article aims to conduct some research from the perspective of consensus algorithms of blockchains in different periods.
1 POW represented by btc: Proof of Work, proof of work.
Bitcoin uses the POW mechanism in the Block generation process. A Block Hash that meets the requirements consists of N leading zeros. The number of zeros depends on the difficulty value of the network. To obtain a reasonable Block Hash requires a lot of trial and error calculations, and the calculation time depends on the hashing speed of the machine. When a node provides a reasonable Block Hash value, it means that the node has indeed undergone a large number of attempted calculations. Of course, the absolute value of the number of calculations cannot be obtained, because finding a reasonable hash is a probabilistic event. When a node has n% of the computing power of the entire network, the node has a probability of n/100 to find the Block Hash.
Advantages: safe, resistant to forks, the POW consensus currency represented by Bitcoin has been in existence for 9 years, and its security has been tested by time.
Disadvantages: Waste of electricity, not energy-saving, a large amount of electricity and computing power are used to compete for Bitcoin’s accounting rights, without making any contribution to the real society. According to incomplete statistics, the electricity required for Bitcoin mining now exceeds the average level of 180 countries. It is precisely because of this that POS appeared
2: POS: Proof of Stake, proof of equity.
POS: Also known as proof of equity, it is similar to property stored in a bank. This model will allocate corresponding interest to you based on the amount and time you hold digital currency.
Operating mechanism: The nodes in the network put the digital currency in the node into the POS mechanism, and the identity is changed into a verifier. The POS mechanism randomly selects one of these verifiers as the generator of the block. Of course, this randomness and input The number of digital currencies is related. The probability of being selected is higher if you invest more coins than if you invest less, which is basically proportional to the quantity ratio. Of course, within a certain period of time, if the generator selected by POS does not generate a block, then the next validator will be selected again. As for the effective chain, this follows the longest chain principle of the blockchain. Since in the POS consensus mechanism, there are tokens as collateral, when the system finds that the node is suspected of committing evil, the mortgaged tokens can be destroyed. Therefore, in the POS consensus mechanism, the security of the system is not provided by the competition of hardware computing power outside the system, but by the hardware computing power competition outside the system. Is based on collateralized tokens as a guarantee of honest nodes.
3 PBFT: Practical Byzantine Fault Tolerance, practical Byzantine fault tolerance algorithm. See the previous introduction to the Byzantine Fault Tolerance algorithm.
PBFT is a state machine replica replication algorithm, that is, the service is modeled as a state machine, and the state machine replicates replicas on different nodes in the distributed system. Each copy of the state machine saves the state of the service and also implements the service's operations. The set of all replicas is represented by a capital letter R, and an integer from 0 to |R|-1 is used to represent each replica. For the convenience of description, assume |R|=3f 1, where f is the maximum number of replicas that may fail. Although more than 3f1 replicas can exist, the additional replicas do not improve reliability other than reducing performance.
Chulian is the world’s earliest hybrid consensus public chain, which is characterized by combining pbft and pow consensus. Use the former to ensure performance and the latter to ensure decentralization. To put it simply, it is based on POW, and then the PBFT backbone node is elected on this node. Personally, I feel that integrating two different consensus algorithms is a very innovative idea. First select the main node based on POW to avoid excessive centralization, similar to the EOS super node, and then operate it under several main nodes later. Although it seems to be contrary to decentralization, this is also the efficiency at this stage. , a better solution that takes into account both performance and decentralization.
Related recommendations:
200 lines of code to implement blockchain Detailed explanation of blockchain examples
Bitcoin’s blockchain api friends who are familiar with it will give advice one time
The above is the detailed content of Looking at the initial chain from the development process of blockchain. For more information, please follow other related articles on the PHP Chinese website!

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.