Introduction to the
At the bottom of bitcoin is blockchain technology, which is also known for bitcoin. What are the characteristics of bitcoin’s blockchain compared to other blockchain technologies? As the originator of blockchain, what are its distinctive features? Come and see it with us.
The bitcoin network
Bitcoin uses peer-to-peer networks, which are peer-to-peer rather than person-to-person lending.
P2P means that each computer in the same network is peer to peer, and each node provides network services together, without any “special” node. Each network node is connected in a flat topology. There are no servers, centralized services, or hierarchies in P2P networks.
The traditional network structure is the client-server mode, all clients interact with the server to obtain information, once the server fails, the client is useless.
However, in P2P network, there is no concept of server, each node can act as a server. By contrast, P2P networks are much more stable than C-S architectures.
Network discovery and synchronization
P2P network, so the question is, how is this P2P network set up? How is it found between nodes?
Those of you who have done P2P downloading have probably heard of the concept of a seed, which contains the addresses of other active nodes. You can connect the corresponding node by downloading the seed.
Each node in turn stores the most recently connected or active nodes, thus forming a large P2P network.
The same is true of bitcoin’s P2P network.
How does the new node discover its peers in the network? While there are no special nodes in the Bitcoin network, the client maintains a list of nodes that are stable over time. Such nodes are called “seed nodes.”
A node must constantly do two things: discover a new node when an existing connection is lost, and help other nodes when they start up.
The SPV node
As we noted earlier, there are neither accounts nor balances in the world of Bitcoin, only UTXO (Unspent Transaction Outputs) dispersed into the blockchain.
So if you want to verify the transaction, you need to find all the transactions related to the transaction from the historical transaction, so as to carry out a complete and comprehensive verification.
The problem with this is that downloading all the history requires hundreds of gigabytes of hard disk space, which is unimaginable for mobile phones or other lightweight clients.
So the SPV came along. SPV stands for Simplified Payment Verification and is called simple Authentication Payment.
Instead of storing the entire blockchain, the SPV stores the headers of the blockchain, and since each header is only 80 bytes long, even if all the headers were downloaded and stored, it wouldn’t be very large.
Block chain head
The block header consists of three groups of block metadata. The first is a set of data that references the hash value of the parent block. This set of metadata is used to connect the block to the previous block in the blockchain.
The second set of metadata, namely difficulty, timestamp, and Nonce, is related to mining competition.
The third set of metadata is the Merkle root, a data structure used to effectively summarize all transactions in a block.
The Nonce, difficulty target, and timestamp are used in the mining process, and the Merkle root is used to index and organize all transactions in the block.
Above is a chain of blockchain heads.
Merkle Tree
Merkle Tree is a kind of Tree (called Tree in data structure), which is mostly called Merkle Hash Tree on the Internet, because all nodes of the Merkle Tree constructed by it are Hash values. Merkle Tree has the following characteristics:
-
It is a kind of tree, can be binary tree, can also be multi-fork tree, no matter how many fork tree, it has all the characteristics of tree structure;
-
For example, Merkle Hash Tree uses the Hash value of the data as the value of the leaf node.
-
The value of a non-leaf node is calculated according to the value of all the leaf nodes below it and then calculated according to a certain algorithm. For example, the value of the non-leaf node of the Merkle Hash Tree can be calculated by combining all the child nodes of the node and then calculating the Hash value of the combination result.
With Merkle Tree, we only need to know the information in other Merkle trees related to the transaction to be verified to calculate the value of the entire Merkle Tree, which can be verified directly using the header information. That’s how the SPV works.
The blockchain in Bitcoin
A blockchain is a data structure made up of blocks containing transaction information that are sequentially linked from back to front. It can be stored as a flat file (a file containing unrelated records) or in a simple database.
The bitcoin core client uses Google’s LevelDB database to store blockchain metadata.
It consists of a block header containing metadata followed by a long list of transactions that make up the block body. The block header is 80 bytes, while the average transaction is at least 250 bytes, and the average block contains at least over 500 transactions.
Block identifier
So how do you represent a block? We use block identifiers.
The block primary identifier is its cryptographic hash, a digital fingerprint derived from a secondary hash of the block header using the SHA256 algorithm. The resulting 32-byte hash is called a block hash, but is more accurately called a block header hash because only the block header is used for calculation.
The second way to identify a block is by its position in the blockchain, known as block height. The first block, whose block height is 0, differs from the block hash in that the block height is not a unique identifier. While a single block will always have a clear, fixed block height, the reverse is not true, and a block height does not always identify a single block. Two or more blocks may have the same block height, competing for the same position in the blockchain.
The foundation block
The first block in the blockchain was created in 2009 and is called the Genesis Block. It is the common ancestor of all blocks in the blockchain, which means that you can trace back from any block to genesis.
Since Trands blocks are incorporated into the Bitcoin client software, each node starts with a blockchain that contains at least one block, which ensures that trands blocks will not be altered. Each node “knows” the hash value of the genesis block, its structure, when it was created, and a transaction in it. Therefore, each node treats that block as the first block of the blockchain, thus building the root of a secure and trusted blockchain.
Blocks in the foundation of the hash value is: 0000000000 19 d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
The Genesis block contains a hidden message. The Coinbase entry included The phrase “The Times 03/Jan/2009 Chancellor on The brink of second Bailout Forbanks.” This was The headline of a front-page article in The Times that day, quoting, It is not only a description of the time when the block was created, but also a tongue-in-cheek reminder of the importance of an independent monetary system. It also tells people that with the development of Bitcoin, an unprecedented global monetary revolution will take place. The message was embedded in the Trands block by Bitcoin founder Satoshi Nakamoto.
Coinbase values are: 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e6420 6261696c6f757420666f722062616e6b73
The decoding method is as follows:
In python shell:
“04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e642 06261696c6f757420666f722062616e6b73”.decode(‘hex’)
Output:
‘\x04\xff\xff\x00\x1d\x01\x04EThe Times 03/Jan/2009 Chancellor on brink of second bailout for banks’
conclusion
This article introduces the bitcoin network and blockchain in Bitcoin related concepts, I hope you can enjoy.
Author: Flydean program stuff
Link to this article: www.flydean.com/bitcoin-blo…
Source: Flydean’s blog
Welcome to pay attention to my public number: procedures those things, more wonderful waiting for you!