Commit Graph

283 Commits

Author SHA1 Message Date
tomFlowee f49b5c03f5 Update to use list for walletTxIndex
Since a core feature of NotificationListener is to combine many
notification objects into one, we now changed the app-private
wallet-transaction-id to be a list instead of a singular item.
This allows the combined set of notifications to not have lost
the actual reference to the underlying individual transactions.
2025-05-07 12:43:50 +02:00
tomFlowee 409908178b Avoid a gap. 2025-05-06 15:42:52 +02:00
tomFlowee f1a975f53c Forget Id when the group is multiple items. 2025-05-06 11:58:50 +02:00
tomFlowee 32f58119a2 Add detection of being made too fat. 2025-05-06 11:58:13 +02:00
tomFlowee 42eff37213 Remove unused count and replace it with txindex 2025-04-19 15:33:56 +02:00
tomFlowee f70adc558d Initialize it here 2025-03-10 23:33:22 +01:00
tomFlowee 5f6db1de18 Add feature: p2pnet power save mode.
Setting the "LowPower" mode on the main DownloadManager class will
cause it to halt all network activity and jobs will die.
You can revive it by changing it to NormalPower and optionally calling
the start() method to restart all jobs.
2025-03-07 14:31:02 +01:00
tomFlowee 119988723f Ensure that we don't hold onto the sharedptr too long
This allows a peer we remove / ban to get deleted properly again.
2025-02-24 21:18:07 +01:00
tomFlowee 16bf019d6b Minor. Cleanup and debug outputs.
Cleans up the comments a bit, adds some logging details and as most
functional change it tweaks the numbers a little.
2025-02-24 15:53:52 +01:00
tomFlowee f2d12fd1fe Alter spv download to be parallel.
We always need two random peers to download a certain merkle block, to
avoid the withholding attack.
It occurred to me that there is no need to do them one after the other,
they can both run in parallel without issues. Saving time.
2025-02-19 19:26:56 +01:00
tomFlowee 5cae07500c Port away from deprecated ASIO methods
This makes thehub compile with BOOST_ASIO_NO_DEPRECATED defined.
2025-02-11 16:46:21 +01:00
tomFlowee 0fb5795305 Add API docs and minor fixes
Also use the more appropriate lock_guard for mutex usage.
And I noticed that in the NotificationCenter we assumed a callback would
be able to unregister itself, which requires a recursive mutex. As such
the mutex has now been elevated to be such.
2025-02-10 17:00:41 +01:00
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 82e698ad57 Avoid negative punishment leading to negative banscore
Negative ban scores are a bit annoying since when a user bans the node
it gives a 1000 point punishment, assuming that this will make the ban
score be above the 1000 point limit which implies banned.
2025-02-03 17:00:26 +01:00
tomFlowee 09821e7dda Optimize download on testnet
Allow testnet downloads to be less secure, which makes it faster
and more reliable since there are a lot less nodes running there.
2025-01-06 23:31:19 +01:00
tomFlowee 450384e6eb Update includes. 2024-12-04 16:04:34 +01:00
tomFlowee 8c17156dbe Trust peers longer on being on the same chain.
Instead of asking every time, we now remember and keep valid the p2p
answer for a week for a single peer.
2024-11-30 16:52:20 +01:00
tomFlowee 83be152768 Add updateBackupBlockHeight() callback
This is called whenever we have the backup peer give us a merkleblock.
2024-11-30 15:42:43 +01:00
tomFlowee 4fd2e4b3d6 Add log sections file. 2024-11-30 15:39:40 +01:00
tomFlowee b6fc84696a Wrap PrivacySegment in a shared pointer.
This is an abstract class that the application using this library needs
to subclass. Ownership and lifetime don't change, it still lies with the
app using the library and they still need to add and remove it from the
connectionManager, but this makes it much more stable for multi-
threading environments and avoids issues on misuse.
2024-11-29 15:12:13 +01:00
tomFlowee 88f3e65fa5 Add a callback indicating the certainty of the height
As the systems gets more peers to confirm the same current blockheight,
our certainty increases. This is now made available via a listener
callback.
2024-11-29 14:02:36 +01:00
tomFlowee e9915cbcad When removing a segment, disconnect its peers
The removal of a privacySegment now makes sure that all the Peers
that reported to it are disconnected and then deleted.
2024-10-11 19:44:54 +02:00
tomFlowee 4b6ca81490 Remove dead code. 2024-10-11 19:40:26 +02: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 9008b4a312 Update checkpoints
The checkpoints were formerly copied from the full node, so based
on possible fork-events.
That seems less useful nowadays and since we want to be able to
allow starting a blockchain instance from any checkpoint it makes
sense to spread them out more evenly.
Based on the concept that the BCH chain generates around 50K blocks
a year, we simply use that interval.

This removes various very old ones meaning that the total count is
roughly equal.
2024-06-29 20:26:35 +02:00
tomFlowee 0838a4cc93 Add more support for checkpoint based chains.
This improves the docs, adds a getter and last it makes the
blockHeightAtTime() more secure by not returning a value below the
checkpoint. As this would throw if used directly in the block() method.
2024-06-29 11:52:29 +02:00
tomFlowee 4acc8ee883 Fix check for chain integrity. 2024-06-26 21:57:07 +02:00
tomFlowee c2ae326620 More sanity checks for creating partial chain. 2024-06-25 23:01:59 +02:00
tomFlowee 3b91e503ff Fix binary search on smaller chain
When a chain starts from a checkpoint instead of '1', we should limit
our search to that in order to avoid codepaths that throw.
2024-06-25 23:00:51 +02:00
tomFlowee dc3545857d [p2pnet] Add Blockchain::replaceStatichain()
This public method allows an application to replace the static-
header files in a life-situation. Without needing to restart the app.

The idea is that a static chain starts at a checkpoint, and we extend
it into the past to start at an earlier checkpoint. This suddenly
makes available a larger amount of history without changing anything
of the data that was already there.
2024-06-02 21:22:37 +02:00
tomFlowee 5ada583bd1 Fixlets in code and comments. 2024-06-02 11:58:05 +02:00
tomFlowee dcaddcca7c Remove unused include 2024-06-01 19:22:27 +02:00
tomFlowee 7ecd46ba1c Make checkpoints available via method call.
This also adds docs.
And this moves away from the map which isn't worth the code complexity
with the low number of entries.
2024-05-31 13:05:38 +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 1165da7336 Make bloom filter cheaper 2024-04-05 12:38:21 +02:00
tomFlowee 6ade318b2e Introduce interleaving during download
The download from a peer is now limited to just 4000 blocks, at which
point the download proceeds from another peer.
Naturally it can go back to the first afterwards too.

The idea is that we download a month worth of blocks at a time and then
fetch the same blocks from a backup peer in order to be certain we
actually see the real state.
The problem we've seen is that after the first downloads we end up
starting the second and if the initial sync or a similar large download
happens, many people won't leave it running until the backup actually
completes since the UI looks like its finished.

This is also a good starting point for rating peers at download speed by
having predictable chunks and that means we could time and aim to use
the faster peers.
This is becoming relevant as we can see a huge difference where peers
give you 10x performance compared to some of the slower ones.
2024-02-23 22:08:28 +01:00
tomFlowee a53d03c5a3 Avoid too harsh a reaction on slowness
Afterall, the slowness can very well be temporary.
2024-02-23 22:01:48 +01:00
tomFlowee 58ec8fb8f8 Fix typo in enum name. 2024-02-23 17:28:40 +01:00
tomFlowee 6b88f6ad7b Ensure addressDB is updated upon connection.
Even if the user disqualifies the connection, we should still register
that there was a successful handshake.
2024-02-14 16:20:02 +01:00
tomFlowee b93a993eaf Fix rare case of not downloading 1 block.
If between the first peer finishing downloading and the second
finishing downloading a block was mined, we need to pick a different
peer for the block the first one didn't download.
2024-02-10 19:50:44 +01:00
tomFlowee 3877df4e2f Improve comment grammar 2024-02-10 19:49:15 +01:00
tomFlowee 04fd3bbf1d Treat DNS based addresses as more reliant 2024-02-10 19:49:00 +01:00
tomFlowee 99c63db936 Try new peers more agressively
Every cycle (1500ms) we try to connect to a new peer if we're low on
peers.
This avoid waiting for a connection to time-out.
2024-02-09 21:12:45 +01:00
tomFlowee 1125e5d329 Add new field 'tried'.
For addresses that we tried to connect to, even though it may
have failed to actually reach the handshake phase.
2024-02-09 18:52:04 +01:00
tomFlowee feb3b29a08 Tweak numbers 2024-02-07 16:30:20 +01:00
tomFlowee c6548c82e6 add more seeds 2024-01-30 20:50:53 +01:00
tomFlowee 2612db6fb4 Add IP to log message 2024-01-30 20:48:36 +01:00
tomFlowee 4cb4100cec Check peers more agressively
With the expansion of the database more agressive, checking a
larger set of peers for one that works becomes more important, as
such open more connections ever cycle if we can't find good ones
after half a minute.
2024-01-29 13:03:25 +01:00
tomFlowee 13d494efef Check more datapoints
With the expansion of the database more agressive, checking a
larger set of items for the best one becomes more important, as
such do a 10x for finding the best sccoring item.

The observed effect is finding previously useful peers within seconds
instead of a minute.
2024-01-29 11:54:40 +01:00
tomFlowee 35be013a19 Detect low number of usable addresses
When our addresses database is filled with old or wrong addresses, we
end up trying to connect to a large number of IPs before we find actual
peers.
When we see that is the case, let's try to find more IP addresses from
our peers.
2024-01-28 21:31:28 +01:00