In the last few weeks, I tried to code my own Blockchain, just to understand the whole concept better.
You can find my code here: https://github.com/Snixells/js-blockchain .
I already implemented that the Blockchain + Transactions are created through nodeJs arrays and JSON.
The problem I am working on right now is that the data does not get saved. I want to run the whole blockchain on a (maybe) express server and access it by a RESTful API. Because of that, I need a way to store the Blockchain somewhere. I also have already some ideas but none of them seems like a good one.
- I could save the whole chain as a JSON file and always when needed open that and afterwards save it. But that won't scale at all later
- I thought about saving each block as a single JSON file, but I think that wouldn't work that great either.
- I could use any kind of database, like RethinkDB or MongoDB but that conflicts with the whole idea of Blockchain being the database itself.
I would love to hear some answers, for example, what frameworks and so on I could use. Or maybe any ideas on how to store the database at all. Thanks for your help :)