Peter Kent

Cryptocurrency Mining For Dummies


Скачать книгу

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.

Illustration depicting how blocks are chained together into the blockchain; each block’s hash is stored in the next block of data and the hashes chain the blocks together in an orderly fashion.

      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.

      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.

      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 doesn’t actually store a balance for each address. Nowhere in the blockchain does it state how much of the cryptocurrency any particular owner owns or how much any particular address has associated with it. Rather, you can use a blockchain explorer to follow all your transactions, incoming and outgoing, and the blockchain explorer can figure out your balance based on those transactions.

      Think of it this way. Say that you’re a little compulsive and like to keep a record of the cash in your pocket. You carry a notepad, to record every time you put money into your pocket and every time you spend it, and you calculate the current balance. That notepad is a kind of transaction ledger, right?

      Cryptocurrency is very similar to this ledger of cash transactions … except there’s no pocket. The blockchain is the ledger; it stores a record of every transaction (when you first purchased or were sent the cryptocurrency, when you spent it or sold it, and the balance you own).

      But there’s no pocket and no cryptocurrency sitting in storage somewhere. The blockchain is simply a series of “mythical” (or virtual) transactions stored in the ledger. No currency is being physically transferred; we simply update the record to state that currency has been transferred.

      The ledger says you own cryptocurrency, so everyone can validate and accept that you own it. And remember, that ledger can’t be edited after being solidified into the chain — it can’t be hacked. (See the preceding section for more on this topic.) So if the ledger says you own, say, half a Bitcoin, then you absolutely