Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db implementation #4

Open
gdassori opened this issue May 31, 2021 · 0 comments
Open

db implementation #4

gdassori opened this issue May 31, 2021 · 0 comments
Labels
utxo-torrent UTXO Torrent Proposal Draft

Comments

@gdassori
Copy link
Member

gdassori commented May 31, 2021

For the implementation, right now LevelDB is targeted and seems the best option Although Rocksdb has a quite better benchmark on some operations, LDB seems more stable and supported on the Python side.

LevelDB (and RocksDB, afaik) is a strict key: value storage, with no fancy structures as Redis would provide, like sets and lists. The following operations are available: READ, WRITE, DEL, ITER.

The business logic of the utxo DB, however, would need some sort of bucket in which data can go in and out, under the same key (to index multiple unspents under the same script key, to query "the unspents of the address X"), and LevelDB does not natively support a structure which can help to do this search.

However, the same result seems that can be achieved by organizing the DB keys in a way that the ITER operation would work as a cursor for a list of values.

The data storage would be the following:
outpoint -> script, block, amount

Regarding the indexes, something similar seems that can be iterated:
script.outpoint -> placeholder_byte (not null)
shard.outpoint -> placeholder_byte

This way the DB can be queried by outpoint to return an entry, and by script to return multiple entries (in case of address reusing, for example) or by shard, returning multiple entries as well (as keys).

It is not an efficient implementation on the disk usage side but seems that every access can be flat (with no adds to the LevelDB default complexity level).

@gdassori gdassori changed the title utxo-torrent / db implementation db implementation Jun 1, 2021
@gdassori gdassori added the utxo-torrent UTXO Torrent Proposal Draft label Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
utxo-torrent UTXO Torrent Proposal Draft
Projects
None yet
Development

No branches or pull requests

1 participant