1. Blockchain development and current situation
Video Address: https://www.imooc.com/video/17452
Attention:
The biggest difference between Bitcoin and Ethereum is:
Ethereum has introduced support for Turing's perfect smart contract, where one can write any business logic to the blockchain in the form of a contract, and before Ethereum, to issue its own digital currency, a separate blockchain network is needed.
Relatively stable, the blockchain system that was taken to study:
"1". Super Ledger
itself is not a complete blockchain system, but to facilitate enterprises to build their own blockchain framework. Each component, such as data storage, consensus algorithms, can be flexibly replaced and assembled. It also has good support for smart contracts.
Therefore, it is often used by large industries such as banks/financial institutions to build the alliance chain.
"2". Aether Square
Operating Environment:
1. Put the go language environment in place
2. Install the IDE or your favorite text editor: such as Sublime
3. My environment: Mac + Goland
2. What is the classification of blockchain "1" Blockchain:
(1). Public chain
Anyone can read, anyone can initiate a trade, the deal can be effectively confirmed, and anyone can participate in the blockchain of its consensus process.
such as Bitcoin, Ethereum, EOS.
(2). Private chain
Generally used within a company or organization.
such as in the blockchain application, their own on the local building of the development node and in the company intranet test node.
(3). Alliance Chain
There are situations where competition and cooperation are needed. The Technical Alliance chain refers to the blockchain that the consensus process is controlled by the preselected nodes. Only the Access Alliance node can participate.
such as Fabric R3 Alliance/EEA (Ethereum Enterprise Alliance)/Sunshine chain (crowdfunding platform Tsing Lung chip)
"2" Blockchain problem solving: value transfer
"3" What is a blockchain:
Blockchain is a special kind of distributed database
First: The blockchain function is to store information (any data that needs to be saved can be written to the blockchain or read from it.) So it's--database)
Second: Anyone can set up a server to join a blockchain network and become a node. So it has--distributed system features
In the blockchain world, there is no central node, and each node is equal. All save the entire database and can write & read data to any node. Because all of the nodes will be synchronized. Ensure that the blockchain is consistent.
The above: The nodes are distributed in various parts of the country, and the nodes are connected with each other. You send a request to any node, and the request data is quickly synchronized to all nodes on the network.
Description
"1". No center, no admin
There is no center or administrator for such a large network, and it is self-managed through the blockchain protocol.
"2". National Journal
Note: Bookkeeping rather than data (because blockchain is used primarily for value transfer, and for value transmission, it is important to trust the ledger. Used to record all the transaction data. The so-called National Journal is the ledger that has one copy on each node of the blockchain. Each node can write transaction data to the ledger on the basis of the blockchain protocol.
"3". Can only be added to the search, cannot be deleted
Note: The data manipulation on the blockchain refers to the operation of the transaction data on the blockchain, not the final state.
When we make a transfer operation, the balance changes,
"3" Blockchain features:
(1). Cannot be grasped: Blockchain only supports additions and queries, cannot be modified and deleted (no 404 on Blockchain)
(2). Traceable:
(3). De-centering: the assurance that data cannot be grasped and changed cannot depend on a center.
3. Blockchain architecture model
Description
Data Layer-"network layer-" consensus Layer-"incentive layer-" The contract layer (a total of 5 layers) together constitute the core system of the blockchain infrastructure.
Application layer: Represents a variety of applications built on blockchain technology. Deployed separately from the Blockchain 5 core systems, and through the remote procedure call RPC, interacting with the blockchain core system.
"1" Data layer & Network layer & consensus layer (necessary elements for building blockchain)
A. Data layer
The data layer encapsulates the chain structure of the underlying data, as well as the corresponding asymmetric public private key encryption technology and timestamp technology. (The lowest data structure in the entire blockchain technology)
B. Network layer
The network layer includes the mechanism of peer network, data dissemination mechanism and data verification mechanism.
C. Consensus layer
The consensus layer encapsulates the various consensus mechanism algorithms of network nodes. The consensus mechanism algorithm is the core technology of the blockchain, which determines who is going to do the calculation. The method of calculation will affect the security and reliability of the whole system.
POW/EOS/DPOS/PBFP and other consensus algorithms.
"2". Excitation layer (main application public chain)
Mainly used in the public chain. You must motivate the nodes that follow the rules to participate in the calculation. Punish nodes that do not obey the rules. (The private Chain & Alliance chain does not have to be motivated, because the nodes that participate in the calculation often complete the game outside the chain)
"3". Contract Layer
Used to encapsulate various scripts, algorithms and smart contracts. Is the basis of the blockchain programmability. Can be easily understood as a custom electronic contract. And this contract can be executed automatically after a certain trigger condition is reached, no manual intervention is required. It can also be automatically terminated if the condition is not met.
"4". Application Layer
The application layer encapsulates the blockchain scenarios and cases. such as the building of Ethereum?
4. Blockchain-linked structure
Chain-Type structure:
Chain structure the most basic form of single-----block (composed of block size and chunk)
Block Body: Store transaction data
Chunk header: Parent Chunk Hash
Question: Why should each chunk header store the hash value of the chunk? (The result of a hash calculation of the same value is consistent.) )
Understanding the--hash function
4. Summary of chain structure
Note: The value of chunk 1 is changed a bit, and the hash value will change. Block 2 will refer to an incorrect address. The hash value of chunk 1 referenced by blockchain 2 is invalid.
Changes in block 1 values can cause changes in block 2hash values .... In turn ... (To change all chunks.) )
5. Build Your own Blockchain
Part:
(i). Implement a chain-type structure
(b). Implement a simple HTTP server, externally exposed read-write interface
Steps:
Step1: Creating a block (development environment: Goland)
A. Create a project Demochain
Demichain/block.go
B. Create a block file
C. Creating block structures and functions
Structure:
Calculate hash value
Generate new Blocks
Founding blocks
Step2: Create Blockchain
Video Address: https://www.imooc.com/video/17447
A. Create a Blockchain file (blockchain.go)
B. Creating blockchain structures and related methods
Define the blockchain structure:
Define related methods (add chunks to blockchain)
Validation (not all chunks can be added to the blockchain)
Step3: Create Httpserver
Video Address: https://www.imooc.com/video/17448
You can also provide API interface access not only on-premises.
Package: RPC/File Server.go
(iii). Effect Display (3 Blockchain, new blockchain can be added via address bar)
Video Address: https://www.imooc.com/video/17445
001/go language building block chain (MOOC)