13 Commits

Author SHA1 Message Date
tomFlowee bb7275466b Stop using deprecated asio io_service
This ports the io-service to the source compatible io-context
class, with the most work going to the WorkerThreads which owns
that one.
2025-02-08 19:05:26 +01:00
tomFlowee 85a6e20e1a Have better spread checkpoints and adjust the unit test
This updates the unit test to move the tiny chain it tests to match the
new checkpoint location.
2024-07-06 22:00:34 +02:00
tomFlowee 422822530b Add Blockchain::dataSources() getter
The blockchain object holds all block-headers, the backing store for
this class is now being exposed more to allow understanding what we have
or not have available. And also what the source of that info is.
2024-05-28 10:51:52 +02:00
tomFlowee 51e872152b Redo various pieces of logic to be more sane.
A review of the numbers because this easily becomes off-by-one fest
that can make you get lost for hours! :-)
2023-10-16 20:29:14 +02:00
tomFlowee cbeb6dbb0a Allow a static blocks file to start at a checkpoint
The blockchain class can effectively now be shallow,
we can have a list of blockheaders of, for instance, the last year
alone. It builds on top of a known checkpoint (hardcoded block data)
and as long as we do not access block info that is unavailable, things
just work like normal.

We throw at the request of a blockheader that is too old.
2023-10-09 18:08:10 +02:00
tomFlowee 35df33f3ab Do not allocate items for static block
This changed the vector to no longer have empty entries for the static
chain which were never inserted or read.
2023-10-09 11:35:20 +02:00
tomFlowee 6377a62baf Blockchain database fixes for compression of data. 2023-10-08 12:15:09 +02:00
tomFlowee 0ae791af1e Make the implementation fit the methodname.
The methodname:
  blockHeightAtTime()
makes the reader think about the actual height of the chain at that
time. Returning that value until the timestamp of the next block is
reached.
Now the method actally returns that number.

The code does not do any work to account for blocks going backwards in
time compared to the block before.
2023-06-14 16:51:23 +02:00
tomFlowee 4b358543c5 Add unit test for partial blockchain saving. 2022-11-13 15:53:51 +01:00
tomFlowee 9c4984dcf7 [P2Plib] Make initial startup 70% faster
What we did previously is load a static chain which was to avoid lots of
work by simply memory-mapping the data instead of inserting it in a
vector.

This improves upon that by also having a metadata file which holds the
block-hashes directly readable. This avoids us having to iterate over
the blockheaders and hashing them.

Additionally we now have a single chain-work field that is the total
amount added work for the headers. This saves us from doing 256-bit
divisions and work for each blockheader as well.

Result is that we make the statup mostly about memory moving and remove
all CPU intensive stuff. Going from 1450ms to 400ms on desktop.
I expect an even greater gain on mobile CPUs.
2022-01-12 19:45:51 +01:00
tomFlowee 919d6ffbc5 Make test less fragile.
This avoids depending on Qt CoW not hitting on returning it.
Also fix open() in release builds.
2021-08-09 21:26:07 +02:00
tomFlowee 460d4be807 Add new method Blockchain::blockHeightAtTime() 2021-05-28 14:52:27 +02:00
tomFlowee d1fa3fa4a9 [P2P] Allow static loading of blockheaders
This adds a unit test for the Blockchain class in the p2p lib and this
introduces the functionality to have a blockchain pre-shipped with an
app.
2021-05-27 19:08:46 +02:00