Commit Graph

20 Commits

Author SHA1 Message Date
tomFlowee 678eccfa70 Be smarter at asking for 'headers' from peers 2024-01-04 21:53:16 +01:00
tomFlowee 8cf80a8634 Cleanup GetHeaders p2p call
Move the builder into the place its used (leftover from earlier ownership change)
Make the message we build be more compatible.
2023-11-03 22:07:57 +01: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 10034d9f0e Add chain-work to checkpoints.
Also rename the member 'checkpoints' to include the m_ prefix to be
internally consistent.
2023-10-09 11:35:20 +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 06b3d3d491 Save the downloaded block headers into multiple files
This change makes it so that we rely less on the downloaded
blockheader data being only in memory and us saving it when
the client shuts down.
Instead, we save more regularly and we save smaller files
instead of always overwriting the complete downloaded headers.

Having less to save at shutdown is then a happy side-effect.
2022-11-12 23:42:59 +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 460d4be807 Add new method Blockchain::blockHeightAtTime() 2021-05-28 14:52:27 +02:00
tomFlowee d17b8f0c40 Add API docs for new static-headers method. 2021-05-28 12:42:30 +02:00
tomFlowee c45e7d9c3e [P2P] Do not save blockchain data when not changed 2021-05-27 19:08:46 +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
tomFlowee 1f2f7c36d2 Port the boost container to the std one.
The unordered_map is now available in stl, and said to be better,
so lets slowly switch over
2021-02-03 16:31:46 +01:00
tomFlowee adfe4081cb Update copyright notice and email address 2021-02-02 13:08:07 +01:00
tomFlowee 2f26329eb9 Add some API docs 2021-01-05 21:29:14 +01:00
TomZ 3f5fe41534 P2PNet: Support multiple chains.
This adds support for the testnet4 chain.
2020-10-29 21:47:53 +01:00
TomZ 7bfe5e0e2c Provide a getter for blockHeight on Blockchain 2020-05-11 18:07:10 +02:00
TomZ 43d7626d46 P2PNet make the blockchain class save its state. 2020-05-11 15:16:59 +02:00
TomZ d49b1ae5e2 Make NetworkManager connections leaner
The NetworkManager usage was mostly for low connection counts and this
made defaults selection easy.
With more usages it is important to allow the NWM-connection to be more
configurable about memory usage and leaner in general.

This changes the headers-buffers (used to create envelopes) to not be per
connection anymore but per thread using the tread_local keyword.

This changes the ring-buffers to become configurable using
NetworkConnections::setMessageQueueSizes().

Also removing some include statements where they were not really needed
in the P2PNet lib.
2020-05-09 20:23:05 +02:00
TomZ 25ffc84f80 Introduce new lib p2p
We reuse the NetworkManager lower level code in order to connect
to the Bitcoin P2P network.
This implements the basics for anyone wanting to be a player on
this network.
2020-04-20 21:49:03 +02:00