How Does Blockchain Work
A blockchain is a technique for storing and modifying data, using no central nodes. What is so special about it, and why is it necessary to invent some kind of a new mechanism when you can store everything on the server?
The central node issue
A blockchain was first described and applied to ensure digital currency transactions. Let us consider the usual way to transfer money. Presume there are 3 blokes (A, B, and C), who possess 10 bucks on their accounts. Their accounts are registered in a bank (in a regular table). When bloke “A” wants to transfer 5 bucks to bloke “B”, he will send the request to that bank. The bank will verify his balance and send money to the recipient if a sufficient amount is available on the account.
There are several troubles with this mechanism:
- In case a bank does not work, customers are unable to use their accounts or conduct transactions.
- The database is in one way or another accessible to some bank employees, who may make changes to it (by mistake or intentionally).
To eliminate these possible troubles, it is necessary to solve the following issues:
- The transaction lists should not be stored in a single place but in multiple places simultaneously. So, a single person alone possessing master access will not be able to affect the data.
- The transaction lists have to be public, and anyone has to be able to access it, meaning: anyone who wants will be able to verify the validity of any transaction.
Exactly these principles are the basis of the blockchain database technology.
Let us imagine that our guys are going to keep a table of their accounts – each at their computers. In this case, to transfer money from “A” to “B”, it will only be necessary to inform the entire network about the event, indicating that “A” transfers $5 to “B”.
Each node will have the opportunity to make sure that “A” has enough money on the account to conduct the transfer, and each node will be able to update the corresponding data in their own table. So, even when node “A” would want to transfer more money than there is on their account, the other two nodes will not accept this transaction. Transparency and possibility to verify any transaction will make this system invulnerable to deception.
Transaction chain of blocks
To provide a possibility of verifying any transaction at any time, the ledger contains a list of transactions, not a list of accounts:
A -> B: $5
B -> B: $2
B -> A: $1
B -> B: $1
# The system money data is stored as a list of transactions
For convenient manipulation, transactions are grouped into blocks which are sent throughout the network after being assembled:
Block 1 : A -> B: $5
: B -> B: $2
: B -> A: $1
Block 2 : B -> B: $1
# Block 2 will be filled and sent to all customers
Each node receives such a block and adds it to the already stored blocks. So, a chain of blocks or blockchain is created (Blockchain – chain of blocks). Yet, one question still remains: how to make sure the nod has received a block with true data, and it is not faked by other participants?
Actually, when one user sends money to another, his transaction is flagged as unconfirmed. Within a short period of time, it remains like this until special nodes verify it.
These nodes are called miners. To confirm a transaction, they use complex calculations (accessible to all participants). The one who does it first is the winner. Practically, the winner is the one who has more computing power. The node victorious receives a little reward, and a new block is added to the chain of the entire system in a chronological order.
After that, all the other nodes are able to easily verify the new block validity using a special hash ( ) function. This way data are synchronized among all nodes of the system.
The most important
A blockchain database provides (truly) distributed data storage. Besides, the network transparency allows changing data (e.g. transferring currency) using no central nodes, thus protecting the data from fraud and hacking.
Read more on Blockchain: