A blockchain is a shared database secured by cryptography. It is used by cryptocurrencies like Bitcoin or Ethereum as an independently auditable storage of all its transactions (recorded in blocks) in a decentralized network. This is why it is also often referred to as a decentralized ledger - it is saved on many computers all over the world that are called nodes.
In most cryptocurrencies (eg., in Bitcoin) blockchain is a public ledger, it means anyone can check the balances or transactions of any used address in history. Some cryptocurrencies (eg., in Monero) have their blockchain obfuscated.
Blocks and mining
The blockchain is also characterized by adding new transactions in separate blocks in a process called mining. Every new block contains a hash of the previous block and it must meet certain criteria. New block always comes after the previous block chronologically because the previous block's hash would otherwise not be known. It is also impractical to modify it once it has been in the chain for some time because every block after it would also have to be regenerated. These properties are what make transactions in cryptocurrencies like bitcoin irreversible.
During the creation of new blocks, forks can occur. One-block forks are created from time to time when two blocks are created just a few seconds apart by two different miners. Nodes build onto whichever one of the blocks they received first. This situation lasts until next block is found on one or other chain. If new block is found on one of these chains, it is broadcasted and the nodes with the second chain have to accept new chain because the longer chain prevails. In some rare situations new block can be found in both of these chains. This fork is than solved in next block in the same way. That's why the transactions are confirmed absolutely only after 6 confirmation - it is almost impossible that the fork of new blocks lasts for 6 or more blocks. More serious forks have occurred after fixing bugs that required backward-incompatible changes.
There are also permanent divergences in the blockchain, which occurs when non-upgraded nodes can’t validate blocks created by upgraded nodes that follow newer consensus rules, they mostly occur when there is a change in protocol and are called hard forks.
- Andreas Antonopoulos - Mastering Bitcoin