conradoqg / naivecoin

A cryptocurrency implementation in less than 1500 lines of code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Database Ideas?

cyberpunkbln opened this issue · comments

Hello,

at the moment i think about Possibilities to store the data without loose json. Traditionelly i use sql-dbs (but in the future i think about nosql-dbs) but i think use the filesystem-db was the easiest way wit the codebase to store the json-data.

I want to try split each block in an separate json-file and packing it into an binary-container. Knows anybody libs in node.js for that?

Or knows anybody an method for line-by-line-reading combined with the json-logic?

At simple as i think at the moment i must only write an new util.DB Class to deliver and recive the blockchain data, so long i respect the json-shemata?

thx

Hey,

I haven't thought about a database to replace the current JSON file storage. Ideally, if you replace the file-based storage for an SQL or NonSQL, you should also replace the way it searches for input/output transactions, replaces overthrown sequences and so on.

There is a way to improve speed when doing verification/search in the blockchain that usually cryptocurrencies use called Merkle Tree.

Best

Hi,

yes i have looked at the whole code and i have seen there are many places where the datas will be constructed. Some simple JSON-DBs that i have tested all are the same problem, there save and read the complete json, only gives some extra functions like search or selects and don't import and export the json-data pure from your code.

At the moment i completly use your code for understanding the complete crypto-process (blockchain and blocks are very simple at my current learning stage, the hardest to understand are the async transaction signings with pub- and privkey:)).

But now i think an extra-Database like an sql or nonsql are not the best way for an wallet-app, why the user must install (portable or not) an extra software.

Away from the code analysis i want to use your code as it is for save on an better "db", or i must completly rewrite the .fromJSON function, fuuh;).

At the moment i try to use only the db-class for writing a new db-concept.

My Idea at this point is an very very oldscool idea:

Writing only every Block or every 10th or 100th Block in an extra blockchain.js file. Before i think about the filesystem-restrictions on the whole fsystems i must found an possibility to get your index-logic into the db-class in and out.

When i have found a way to caps the read and write process from the fromJSON i can think about compress or capsule the blockchain files.

However i think the complete rewrite of your code with your code is an option,too;).

thx