Читать книгу Cryptocurrency Mining For Dummies - Peter Kent - Страница 22

Hashing: “Fingerprinting” blocks

Оглавление

Having the blockchain duplicated across many different computers is powerful, making it much harder to hack or manipulate. But there’s something else that’s also powerful: hashing. A hash is a long number that is a kind of fingerprint for data. The blockchain uses it as follows:

1 A computer running a node gathers and validates Bitcoin transactions (records of Bitcoin sent between addresses within the blockchain) that are going to be added to the blockchain.

2 When the computer has collected enough transactions, it creates a block of data and hashes the data — that is, it passes the data to a special hashing algorithm, which passes back the hash.Here’s an example of a real-life hash, from a block in the Bitcoin blockchain:000000000000000000297f87446dc8b8855ae4ee2b35260dc4af61e1f5eec579ThA hash is a fingerprint for the data, and thanks to the magic of complex mathematics, it can’t possibly match any other set of data. If the hashed data is changed even slightly — a 0 changes to a 5, or an A is changed to a B — the hash fingerprint will no longer match the original data.

3 The hash is added to the block of transactions.

4 The block is added to the blockchain.

5 More transactions are collected for the next block.

6 After a full block of transactions is ready, the hash of the previous block is added to the current block.

7 The block — the transactions and previous-block’s hash — are hashed again.

8 The process repeats, creating a timestamped chain of blocks.

So, every block contains two hashes: the previous block’s hash and the current block’s hash, which is created by hashing the combination of all the Bitcoin transactions and the previous block’s hash.

That’s how blocks are chained together into the blockchain (see Figure 1-1). Each block contains the previous block’s hash — in effect, a copy of the previous block’s unique fingerprint. Each block is also, in effect, identifying its position in the blockchain; the hash from the previous block identifies the order in which the current block sits.


FIGURE 1-1: Each block’s hash is stored in the next block of data. The hashes chain the blocks together in an orderly fashion.

Cryptocurrency Mining For Dummies

Подняться наверх