Cryptocurrency Mining For Dummies. Peter Kent
Чтение книги онлайн.
Читать онлайн книгу Cryptocurrency Mining For Dummies - Peter Kent страница 11
The blockchain is a database; it stores information in a structured form. You can use blockchains for many different purposes: for example, for property rights registries (who owns this piece of land, and how did they come to own it?), or supply chain tracking (where did your wine or fish come from, and how did it get to you?). Blockchains can store any kind of data. In the case of cryptocurrencies, though, blockchains store transaction data: who owns what amount of cryptocurrency, who gave it to them, and who have they given it to (how have they spent it)?
Of course, blockchains have several special characteristics. Firstly, they are networked. There is a Bitcoin network, a Litecoin network, an Ethereum network, just like there’s an email network or a World Wide Web network.
Bitcoin, for example, is a network of thousands of nodes or servers, spread across the entire planet.
These nodes each contain a copy of the Bitcoin blockchain, and they communicate with each other and stay in sync. They use a system of consensus to come to an agreement regarding what the current, valid blockchain database looks like. That is, they all contain a matching copy of the blockchain.
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.
Blockchain is “immutable”
You may have heard that the blockchain is virtually immutable, which simply means that it can’t easily be changed. If the Bitcoin blockchain says you own x Bitcoin, then you do own x Bitcoin, and there can be no disagreement … and nobody can go into the blockchain and hack it or somehow change or mutate it.
Imagine what would happen if someone went into a block (we’ll call it Block A) and changed a little bit of data — for example, they go in and show that instead of sending someone 1 Bitcoin you sent 9 Bitcoin.
Well, the hash in Block A would no longer match its data. Remember, a hash is a fingerprint that identifies the data, so if you change the data, the hash no longer matches.
Okay, so the hacker could rehash Block A’s data and then save the “corrected” hash. But wait, now the next block (Block B) would not match because Block B is carrying Block A’s hash. So now say the hacker changes the Block A hash stored in Block B.
But now Block B’s hash doesn’t match Block B’s data, because that hash was created from a combination of Block B’s transaction data and Block A’s hash!
So, Block B would have to be re-hashed, and the hash updated. But wait! That means Block B’s hash stored in Block C now doesn’t match!
See where we’re going? This would ripple through the entire blockchain. The entire blockchain is now broken, by just modifying one single character in a block lower down. In order to fix the problem, the entire blockchain has to be recalculated. From the hacked block onwards, it must be “re-mined.” What may look like a simple hack and database edit now turns into a major computational headache that cannot be easily completed.
So, this hashing function, combined with the fact that thousands of other nodes must be in sync with identical copies of the blockchain, makes the blockchain virtually immutable; it simply can’t be easily hacked.
Nobody can change it or destroy it. Hackers can’t get into the peer-to-peer node network and create transactions in order to steal crypto, governments can’t close it down (China, for example, could attempt to shut down Bitcoin within its borders, but the blockchain would continue to exist in many other countries), a terrorist group can’t destroy it, one nation can’t attack another and destroy its blockchain, and so on. Because there are so many copies of the blockchain, and as long as enough people want to continue working with the blockchain, it’s practically immutable and indestructible.
Where’s the Money?
You may be wondering, “So where is the cryptocurrency? Where’s the money?” Or perhaps you’ve heard of cryptocurrency wallets and think that’s where the money is stored. Wrong. There’s no money in a cryptocurrency wallet. In fact, there is no cryptocurrency.
Cryptocurrency blockchains are often described as ledgers. A ledger is described by Google Dictionary as “a book or other collection of financial accounts of a particular type.” Ledgers have been around for hundreds of years, used to record transactions for individuals, businesses, government departments, and so on. The statement you get from your bank account or credit card is a form of ledger, showing you your individual transactions; money you pay to others, and money you receive from others.
FINDING THE BALANCE IN THE BLOCKCHAIN
Well, okay, the blockchain