Commit Graph

11 Commits

Author SHA1 Message Date
TomZ 02258d9dcd Make pruner use the new tags
This allows the pruner to be used on the 'tip' DB file, at which point it
will set the filesize to be the default 2GB one.
Previously pruning the tip would confuse the Hub with a smaller file
size.
2020-03-05 23:29:52 +01:00
TomZ d9604e3f33 Design a better detection for need of UTXO-GC
Doing a garbage collect of the Sha256 based databases means we remove
all the records that have been deleted from our file.
We also sort the file to have all the jump-tables at the end, making it
much cheaper on memory-locality to find (or not) items in the DB.

The downsides are that this prune step takes time, writes dozens of MBs
and that we lose checkpoints. The latter means we no longer can rollback
to a safe position, simply because we flushed those records.

So we want to do this often enough to avoid fragmentation but not too
often because it creates a greater risk on data consistency.

This algoritm checks the actual data and calculates the fragmentation of
the jump-tables to decide if we want to start a GC.

When we do GC, we try to do as many files as makes sense, to make sure we
can wait quite a long time before we need to do a new GC.
2020-03-05 23:29:52 +01:00
TomZ f0e93708e1 Minor cleanups 2020-02-28 00:33:11 +01:00
TomZ e7a7ada953 Cleanup dependencies a bit more.
This means that for apps like 'pos' no longer link against libSSL

The streams no longer zero-after-free, there are no secrets transported
in datastreams so this is useless and avoids linking in one OpenSSL
call.

The insecure_rand() method depended on the openssl code to seed it with
randomness. Now replaced with a proven current-time-milliseconds.
This is enough in those cases because it was always meant to be an
insecure random.
2019-08-24 22:25:10 +02:00
TomZ 49b6f802a5 Make loglines less confusing
Now multiple different targets use this database, the messages
were confusing. Next to that "pruning" is not really correct
and it lead to confusing. More correct is the term GC.
2019-06-22 10:59:37 +02:00
TomZ 110d7e8a39 Fix pruning of rather large files 2019-06-19 16:55:59 +02:00
TomZ cfe690320d Move various standalone simple classes into utils
The 'server' library has always been a catch-all and
ideally only the hub links it in (far future goal).
In line with this I move a list of files out of server
into the utils lib.
I choose 'utils' because all these are plain old data
objects that many crypto apps will find useful.

now in utils/primitives/
* CScript
* CPubKey
* CTransaction
* CBlock
* FastTransaction
* FastBlock
* CScript

streams.h is now in utils/streaming/
hash.h is now in utils/
2019-03-11 15:40:42 +01:00
TomZ 9fc1ef6705 Fix clang warnings 2018-09-25 00:07:00 +02:00
TomZ a28ffd18bb Write less txid's to the DB file and write shorter ones.
When pruning we sort leafs by txid / output and refrain from
writing the txid repeatedly for outputs of the same tx.
Additionally, use the fact that we only ever get to a leaf via
a bucket and since the first 64 bits of a txid is there, skip
repeating them when writing to disk.
Last, make pruning have different strategies.

This should shrink the utxo by about 40%
2018-09-24 21:24:28 +02:00
TomZ e7e4a43084 Make UTXO auto-prune 2018-09-20 22:03:44 +02:00
TomZ 02a7c1d2f6 Refactor pruner to lib from DBA tools 2018-09-20 22:03:44 +02:00