Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Which database would you choose for a blockchain?
2 points by tcsenpai on June 1, 2024 | hide | past | favorite | 11 comments
OK, OK, I said the cursed "B" word. Feel free to mock me for being in the crypto space.

That said, I am in the process of building a blockchain (funded and all, not a hobby project) and I am exploring the various database options.

The only requirements (just lol) are: - Must be completely local - Must be very performant especially in concurrent reads and writes

I am using sqlite3 as a dummy but of course it is not suitable and not scalable enough.

I was wondering if PostgreSQL might be an idea but I am very basic in my knowledge of databases.

In your opinion, given the high throughput and concurrency, where should I start looking?

Bonus points if it is open source of course



The method of storage isn't a factor in something becoming a blockchain, only the fact that new records contain a hash of previous records, which themselves contain a hash of previous records, and so on. This is the "chain." How you store or retrieve it is up you. Any data storage method you like can be equally "blockchain-y."


copypasted from below just because is the very same answer:

My blockchain uses the database to store also registries containing pending requests, mempool statuses and GLS which is a global status layer that is frequently accessed and wrote.


Use sqlite3 until you actually cannot. It sounds like you're assuming it's bad, but it sounds ideal for your use-case since it is designed to be a fully-local database.


I actually cannot, I have severe performance degradation when I scale the blockchain over two nodes and I traced that back to sqlite 3 unfortunately


If each node has its own local database, then:

* you shouldn’t need a database that can handle concurrent writes

* and increasing the number of nodes shouldn’t increase the database load


One option is LMDB [1], which is used succesfully in several blockchains.

[1] https://en.wikipedia.org/wiki/Lightning_Memory-Mapped_Data


Great, reading and learning about it. Thanks a lot!


It is amusing that you got funded while being clueless about what to do. The B word works, after all.

Why are you using a SQL-based database? Blockchain data is so simple you could use Redis.


Yeah the B word works very well, the AI term improves that by a lot too

Looking into Redis, thanks a lot :)


What blockchain attributes are you looking for? ... your local requirement has removed decentralization, distributed-ledger, and transparency.

What's left? immutability?


My blockchain uses the database to store also registries containing pending requests, mempool statuses and GLS which is a global status layer that is frequently accessed and wrote.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: