Page 48 of Common Lisp: A Gentle Introduction to Symbolic Computation answers oh oh oh so many questions!
Learning Luesday, Blockchain
Learning Luesday, wherein I set out to learn something new on a Tuesday, or thereabouts.
What the heck is blockchain…the blockchain…a blockchain!?
I first encountered the concept of a blockchain in 2013 or 14 when I started to fool around with Bitcoin and when I met a fellow involved with Common Accord on an airplane. I’ve since been well-aware of blockchain as a…design paradigm?…fad?…phenomenon?…tech-term? but haven’t ever really actually delved into what it is or how it works.
Here I go!
Firstly, blockchain ≠ bitcoin. Bitcoin uses a blockchain.
Blockchain “is to Bitcoin, what the internet is to email. A big electronic system, on top of which you can build applications.” A blockchain is “a distributed database that maintains a continuously growing list of ordered records.”
While there is no reason that I can find why a blockchain couldn’t be used as a general datastore, blockchains are most useful as transaction databases, or ledgers because they maintain a full copy of every transaction/update ever to take place on the chain.
A blockchain is comprised of many blocks, and a block is roughly equivalent to a record in a database. At a bare minimum, each block contains some data, a timestamp, a hash, and a previous hash.
The first block in the chain is sometimes called the genesis block. The genesis block is the only block in the chain that doesn’t directly reference any other blocks because it doesn’t contain a previous hash. There is a whole rabbit hole here about genesis blocks, but for the time being I’m going to stick with “they’re special” and move on.
So far I’ve groked more or less everything I’ve learned because it has mapped pretty well to my existing understanding of various datastores. Now, however, I’m wadding into territory unknown 👻
ʎɥdɐɹboʇdʎɹɔ and timestamps
Whereas one typically writes data to a database on an as needed basis, and each new entry takes up a new row, new data is written to a block on a blockchain in timed intervals, e.g. a block is created, and for 10 minutes all data posted to the blockchain is written to that block, after 10 minutes a new block is created, and the previous one “closed.”
In someone else’s words: “When a digital transaction is carried out, it is grouped together in a cryptographically protected block with other transactions that have occurred in the last 10 minutes and sent out to the entire network.”
Once a block is closed, members of the network are able to validate the transaction. The transaction is validated by solving (decrypting) what is ostensibly a difficult math problem. This is called proof of work. Only after it is validated is a block timestamped, assigned a hash, and added to the blockchain. The hash assigned to a validated block is then used to create the next block and the process starts over again.
Wait? But how is the next block created using the previous hash?
…I’m obviously no expert yet, but I feel like I have a (slightly) deeper understanding of what the heck the blockchain is.