Two Notes block chain study: "block" what is?

Two Notes block chain study: "block" what is?

 

        Block is the basic structural unit block chain, or even "block chain" is also the name of the resulting, and its importance. Here we analyze the anatomy of the block, which in the end to see what are things?

 

       In block chain network, data are permanently recorded in the form of files, these files are called blocks . Block is the basic structural unit of the block chain constituted by header region containing metadata and the transaction data comprising block body . Currently Bitcoin block chain system approximately every 10 minutes will create a block.

      A block of some or all of the latest record set Bitcoin transactions, and not the other blocks previously recorded. The new block will be added to the last record, the write once, can no longer be changed or deleted.   

The main parameters of the block shown in the following table:

The "magic number" is the identification code when the bit Block data parsing the client credits, coins the number of bits magic formal networks are 0xD9B4BEF9. Magic number of different currencies is generally different, such as the number of magic litecoin is 0xDCB7C1FC. (Note: 0x prefix indicates hexadecimal)

The size of the header area of ​​80 bytes, including the version number of 4-byte, 32-byte (256) on a hash value of a block, 32-byte Merkle root node, a timestamp of 4 bytes, words 4 difficulty level value of the random number and the 4-byte section.

Region containing three sets of metadata header:

  • Connecting the hash value data of a previous block
  • Mining difficulty, workload proved timestamp
  • Merkle root data validation transaction data

Each block is formed by connecting a block on a chain structure, as shown below:

Above the "Block 1001" refers to the height of the block. Block height corresponding block numbers, but may be bifurcated, the height of the block is determined not only block, i.e., if there is a solitary block, this block is the block height isolated, and the other on the backbone block is the same height, the height of the block can not be simply used to identify one block.

Hash value and the height of the head blocks are not stored in the data block structure, but can be as fast in order to retrieve the metadata stored in the index database.

Hash value is a first digital fingerprint, a length of 32 byte header area twice SHA256 calculated. Uniquely and unambiguously identifies a block. A hash block header not included in this block, but includes a next block. In this manner form a chain structure.

       Bitcoin block design file block.h bit blocks implemented by currency CBLOCK class, the body field is CBLOCK CBlockHeader.

      "Block" CBlockHeader code structure is as follows :

      

Class CBlockHeader
{
    public:
    //header
    int32_t nVersion;  //版本号
    uint256 hashPrevBlock;  //上一个区块的哈希值
    uint256 hashMerkleRoot; //交易列表的Merkle树根节点哈希值。
    uint32_t nTime;  //当前时间戳
    uint32_t nBits;  //当前挖矿难度,nBits越小,难度越大
    uint32_t nNonce;  //随机数Nonce值
    CBlockHeader()
    {
    SetNUll();
    }
}

  See also: CBlockHeader English description

 The main parameters of the header area shown in the following table:

Wherein 256 bits are represented by the difficulty exponent target value calculation block miners must Hash value is smaller than the value of bits. Hash compression target expression values ​​for each block is stored in a hexadecimal (referred Bits). Bits e.g. value: 0x1b0404cb, corresponding hexadecimal target Hash value is of the form:

Timestamps generated from moment to block exists in the block. Corresponding to the certification each transaction record. Timestamp written directly block the chain, can not be tampered with. Before each stamp will Naruhaxi a timestamp value, are connected in sequence to form a complete chain.

Block comprises a selected transaction records within 10 minutes, the first transaction (transaction Coinbase) is a special bonus for trading currency miners bits, added to the block by the miners themselves.

The size of the current block is 1M, i.e. 1,048,576 bytes. Each transaction information space occupied by approximately 250 bytes. Then the total number of transactions a block can contain about 41.94 pen. Bitcoin network i.e. approximately 600 seconds out of every 10 minutes of one block, then the number of transactions per second, can handle a block of 4193/600, about 7. Thus, the efficiency of the Bitcoin network to process transactions is not high, sometimes a deal to wait a long time to be confirmed. 2018 11 double peak volume of 49.1 million transactions / second, is Bitcoin transaction efficiency of 7 times.

Since the difference is so poor, why should we use the block chain technology?

从前面我们对区块链运行原理的分析可知,区块链的目标就是打造一个去中心化的自运转体系,用以解决中心化机构存在的信任问题。在区块链中,要想改动一个区块数据,必须同时改动该区块后面的所有区块,而将一个区块放入主链中需要消耗非常多的资源,成本非常巨大,随着后面添加的区块越来越多,要想改动某个区块几乎是不可能的。从这个角度来看,区块链是在用效率换信任。在效率和信任不能两全的时候,信任所占的权重更大一些。


备注:学习笔记,日有所得。

           --不间端地思考,实时地批判你的工作!

发布了19 篇原创文章 · 获赞 6 · 访问量 1126

Guess you like

Origin blog.csdn.net/ydyuse/article/details/104689878