A consensus algorithm is a mechanism that allows users or machines to coordinate in a distributed setting. It needs to ensure that all agents in the system can agree on a single source of truth, even if some agents fail. They ensure that all nodes in the network have the same copy of the ledger, which contains a record of all transactions. Consensus mechanisms are necessary for blockchains because there is no central authority to verify transactions and maintain the integrity of the network.
When tens of thousands of nodes keep a copy of the blockchain's data, some challenges can quickly arise, including data consistency and malicious nodes. To ensure the integrity of the blockchain, there are various consensus mechanisms that govern how network nodes reach an agreement. Let's now look into the major ones.
