Consensus in Blockchain
This article is part of Blockchain tutorials where you will understand about consensus in Blockchain.
Consensus in blockchain is a way to ensure the nodes on the network verify the transactions and agree with their order and existence on the ledger. In the case of applications like a cryptocurrency, this process is critical to prevent double spending or other invalid data being written to the underlying ledger, which is a database of all the transactions.
So let's understand the consensus in blockchain concept in detail.
Let's take one example. I want transfer some money from my account to someone else account. Suppose I want to transfer 10 dollars from my account to my friend's account.
Since there is no central authority here in case of blockchain then who will make sure that I am having ten dollar in my account so that I will be able to send a ten dollar to someone else account?
Because in case of central authority they will make sure that I have sufficient balance in my account like in case of bank they will make sure that I have sufficient balance in my account and then only I will be able to transfer the amount from my account to someone else account. In case I don’t have sufficient amount then my transaction will not be processed as bank is a central authority that has visibility and has control over my account detail.
But in blockchain how that will happen how we will make sure that the sender has sufficient balance in their account before they send the money or transfer that money to someone else.
There is one another problem which is known as double spending which means you may be trying to send ten dollars at the same time to two different people.
So these are some open questions which are managed by central authority in case of central system and make sure that only valid transactions are processed.
Answer to these questions in blockchain is consensus so let’s understand that, how consensus in blockchain will help here.
Whenever transaction is initialed in blockchain network, transaction is sent to all peers irrespective of number of peers in network like in case of Ethereum we have more than 60,000 peers so transaction is sent to all 60,000 peers in network and all that peers need to validate the transaction and confirm if that transaction is valid or not. If that transaction is valid then transaction will get saved to blockchain network, otherwise it will get rejected.
This does not mean that all 60,000 peers to validate and confirm, at very high level, mainly 51% peers (majority) need to confirm the transaction to progress it further. In case only 50% verify and validate the transaction then that transaction will not be processed further.
In case there is very big network then transaction validation may take time so you will notice that transaction processing time is always high in case of Blockchain if you compare that with central system.