简体   繁体   English

如何保存我的Nodejs BLockchain

[英]How to save my Nodejs BLockchain

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 . 您可以在这里找到我的代码: https : //github.com/Snixells/js-blockchain
I already implemented that the Blockchain + Transactions are created through nodeJs arrays and JSON. 我已经实现了通过nodeJs数组和JSON创建Blockchain + Transactions 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. 我想在(也许)快递服务器上运行整个区块链,并通过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. 我也已经有了一些主意,但似乎没有一个好主意。

  1. I could save the whole chain as a JSON file and always when needed open that and afterwards save it. 我可以将整个链保存为JSON文件,并始终在需要时打开它,然后将其保存。 But that won't scale at all later 但这根本不会扩展
  2. I thought about saving each block as a single JSON file, but I think that wouldn't work that great either. 我曾考虑过将每个块保存为一个JSON文件,但是我认为那也不行。
  3. I could use any kind of database, like RethinkDB or MongoDB but that conflicts with the whole idea of Blockchain being the database itself. 我可以使用任何类型的数据库,例如RethinkDB或MongoDB,但这与将Blockchain作为数据库本身的整个思想相冲突。

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 :) 谢谢你的帮助 :)

Update: 更新:
I tried out rethinkDB and it seems to be a great choice because you can just simply store json objects in that database. 我尝试了rethinkDB,它似乎是一个不错的选择,因为您可以将json对象仅存储在该数据库中。 It's perfect for what I need! 完美满足我的需求!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM