r/howdidtheycodeit • u/stable_maple • Dec 10 '21
How does blockchain additions synchronize?
After writing this, I'm coming to the realization that what I've written doesn't make a whole lot of sense and doesn't convey what I'm trying to ask very well, but I'm still posting it in the hope that someone can understand what I'm trying to say, since I'm probably not going to get another chance to ask for awhile.
I want to implement a basic sort of blockchain with no proof of work penalty. I understand that, to add a new block, a hash of the previous block is used for conformation of the new block. In my implementation, I get how a single node can just append a new block to the ledger, but if Alice and Bob both download the ledger at the same time and append new blocks, how do we synchronize their additions? How does Alice get bob's block without waiting on Bob's addition?
View all comments
Show parent comment
1
u/StyMaar Dec 14 '21 edited Dec 14 '21
Well I think I've answered to your question in good faith in most of my post (at least I tried as best as I could). The last paragraph is here just because I don't want anyone reading this and be like “cryptocurrencies/web3 are so cool!”.
When it comes to protect data from manipulation, the Merkle Tree is probably the only feature of a blockchain you need (see
git). If you don't need linearizability, you can use a DAG (likegit) instead of a Linked List (like a blockchain) as a data structure and it's likely what you want (for instance, it solve your problem about Alice and Bob publishing at the same time, in case there's no conflict between what they publish, they can just do it and then Charlie will “merge” what they have both posted, so it removes a lot of synchronization overhead and dramatically improves your throughput).(Oh, and just in case you're interested, I do consulting on that kind of stuff for a living so if you're doing that for your job and your company need help with that I'm available for hire as a freelancer ;)