Part of list:
Bitcoin's Insight: A Working Decentralized Ledger
- What is a consensus protocol?
- So, how does bitcoin solve the double-spending problem?
At a high level, bitcoin describes what's known as a consensus protocol that allows for the successful implementation of a decentralized ledger.
It's a set of rules that you and everyone around you follow so that everyone can agree on which transactions are legitimate, and which aren't. American democracy, for example, can be thought of as a very complicated and very slow consensus protocol. The rules described in the constitution and all the other legislative documents dictate what laws are created, and ultimately lead to a population-wide "consensus" on what constitutes proper behavior and what doesn't. The bitcoin protocol is effectively a very, very clever constitution for transactions that allows us to implement a decentralized ledger.
Let's go back to our small town example, where we had everyone keeping a personal notebook containing their view of everyone else's balances. The problem we faced there was that we couldn't update everyone's notebooks fast enough to prevent someone evil from double-spending with two separate people.
How does bitcoin solve this problem?
It does something tricky — it elects someone to act as a transaction validator at set intervals in time. In the small town example, imagine that at the beginning of each hour, someone in the town is randomly selected to act as the validator for all transactions for that particular hour (We'll see later in this guide how this is not completely accurate — but for now, assume that this is what happens.) Anyone who wants to send/receive money would then have to go to this validator guy at some point during that hour and tell him about their transaction.
Then, at the end of that hour, the validator would gather all the transactions he got, leave out any invalid double-spendy ones, and announce them to everyone else in the town so they could update their notebooks. So if you wanted to send money to someone, you'd have to figure out who the validator was for that hour, tell them about your transaction, and then the person you were sending money to would have to wait until the end of the hour for the validator to "approve" your transaction.
If you tried to double-spend, the validator would catch it, and reject one of your fraudulent transactions. Every hour, a new validator is chosen completely at random in order to prevent centralization (you don't want your validator guy getting drunk with power).
In exchange for his effort, the validator gets to bump his balance a bit, say by $1 every time he's chosen. Note that this whole scheme is a little annoying because you have to wait until the end of an hour in order to see if your transaction got approved, but in practice when you run this protocol on machines, you can make the intervals really short (say every few minutes).