It is a common knowledge that Blockchain technology is going to make a huge impact in almost all industries in the future, and for convincing reasons, financial institutions are endeavoring to put this technology under test as well as invest in it. Therefore, it is important to understand the structure of blockchain and how it works.
Blockchain data structure
The blockchain data structure is an ordered, back-linked list of blocks of transactions. The blockchain can be stored as a flat file, or in a simple database. The Bitcoin Core client stores the blockchain metadata using Google’s LevelDB database. Blocks are linked “back,” each referring to the previous block in the chain. The blockchain is often visualized as a vertical stack, with blocks layered on top of each other and the first block serving as the foundation of the stack.
See also: What is Blockchain Platform ?
Each block in blockchain is recognized by a hash, generated by the cryptographic hash algorithm SHA256 on the block header. Each block also references the previous block, called the main block. In other words, each block has a parent hash. A series of hashes connects each block to its parent, building into a string that, if traced back to the first block, is called the genesis block.
The identity of the children blocks will change once the identity of the parent block does. When the parent is modified in any way, the parent’s hash changes. The parent’s changed hash necessitates a change in the “previous block hash” pointer of the child. This in turn causes the child’s hash to change, which requires a change in the pointer of the grandchild, which in turn changes the grandchild, and so on. This cascade effect ensures that once a block has many generations following it, it cannot be changed without forcing a recalculation of all subsequent blocks. Because such a recalculation would require enormous computation, the existence of a long chain of blocks makes the blockchain’s deep history immutable, which is a key feature of bitcoin’s security..
One way to think about the blockchain is like layers in a geological formation, or glacier core sample. The surface layers might change with the seasons, or even be blown away before they have time to settle. But once you go a few inches deep, geological layers become more and more stable. By the time you look a few hundred feet down, you are looking at a snapshot of the past that has remained undisturbed for millions of years. In the blockchain, the most recent few blocks might be revised if there is a chain recalculation due to a fork. But once you go more deeply into the blockchain, blocks are less and less likely to change.
In simple words, blockchain data structure makes it hard or even impossible to remove or modify a block. When someone wants to change it, participants in the network who have a copy of the existing blockchain can evaluate and verify the proposed transaction. Therefore, transparency and accuracy in transactions are committed.
How does Blockchain work?
A unit of data stored within a block can be represented by any value depending on the blockchain type. It might be an asset, a part of a company, a digital certificate of ownership, a vote in an election, or any other values.
Data is encrypted and stored in the block. An electronic encoding block also contains the encoded identifiers of the sender and receiver. For example, a block of e-commerce transactions will contain the identifiers of the retailers and the consumers.
As noted in the previous section of blockchain data structure, each block has a hash, whose role is to define the block and its content. Any changes inside a block will cause changes in hash. Thus, a hash also indicates changes to a block. In addition, the previous block hash is also included in a block. Say that there are three blocks in a blockchain, block 3 will contain the hash of block 2, and block 2 will contain the hash of block 1. Any changes in a single block can lead to the changes in hash of that block, making the whole chain invalid.
Hash is a great tool to determine data changes in blocks. However, the hash algorithm alone cannot ensure the safety of a blockchain. In order to optimize the security and safety of a blockchain, it is a must to mention Proof-of-work.
Proof-of-work (PoW), which is a piece of data which is difficult to produce but easy for others to verify, is used to prevent fraud. In the context of a blockchain, PoW is used to solve mathematical puzzles. For each puzzle successfully resolved, a new block will be added to the chain. On average, the expected block time is 10 minutes.
Together, the hash and PoW algorithm contribute to the security and safety of the whole blockchain.
See also: Blockchain Programing