Commit Graph

32 Commits

Author SHA1 Message Date
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 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 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 991eadb311 Add some more debugging output 2023-08-17 21:32:09 +02:00
tomFlowee 9435c318f2 Clarify usage of punish() method
We removed the default value in order to avoid misusage of the method
and mistaking the amount with the connection-id.

From Peer we now se the faster overload of punish(), avoiding looping
through the peer list.

Also check return-code when needed.
2023-05-08 11:34:47 +02:00
tomFlowee 3e2ab7ced7 Don't send notifications of new blocks until we synched 2023-04-17 11:56:50 +02:00
tomFlowee 2c0e0bad75 Update SyncChainAction to present day concepts
When the SyncChainAction was written, various interactions we do
today in the ConnectionManager did not happen yet. Features in
Peer didn't exist yet.

This updates the SyncChainAction to take those items into account
and be more responsive and conclue we are 'up to date' faster,
while also leaving behind a better state.
2023-03-27 15:20:50 +02:00
tomFlowee aa6f0676a3 Docs improvements. Mostly API docs 2023-03-27 15:19:05 +02:00
tomFlowee 004f957540 Revisit listener interfaces.
Now we have 3 more logically divided interfaces for the listener
pattern (callbacks).

A P2PNetInterface for peers maintainance.
A DataListenerInterface for the sections getting new data.
And last the new  HeaderSyncInterface about the state of the
header-chain (application wide).
2023-01-31 20:29:51 +01:00
tomFlowee 4b358543c5 Add unit test for partial blockchain saving. 2022-11-13 15:53:51 +01:00
tomFlowee 64d382b7c4 Add saveData() function to p2p net 2022-11-11 19:25:19 +01:00
tomFlowee 7376c28a3c Move pool thread-local getter to utils.
This nicely cleans up the calling usage a static on the connection
manager instance.
2022-01-24 12:06:37 +01:00
tomFlowee 1b5ae89d31 [Refactor] rename FastTransaction.{h|cpp} -> Tx.* 2021-11-02 11:05:14 +01:00
tomFlowee d18e13b93b Add new callback on DataListenerInterface when we synched headers 2021-05-28 14:53:19 +02:00
tomFlowee d3f1d7f454 Whitepace and minor fixes. 2021-02-05 17:32:36 +01:00
tomFlowee f026e626a1 Add notifications for the p2pnet lib. 2021-02-05 17:22:52 +01:00
tomFlowee 70f363cabb Also allow downloading of dsproofs. 2021-02-04 18:09:38 +01:00
tomFlowee 447a2e12e6 Add new action
When a peer never sends headers we now ban it after a timeout based on
the idea that we don't even know if this peer is on the same chain as we
are.
2021-02-03 14:41:51 +01:00
tomFlowee adfe4081cb Update copyright notice and email address 2021-02-02 13:08:07 +01:00
tomFlowee c5fca38956 Check basedir or throw
This makes the download manager fail fast, with appropriate logging, on
misconfiguration.
2021-01-13 12:00:15 +01:00
TomZ 301a4ca3ee Fix properly following the chain-tip
This is done in several steps:

1. Separate my height from the remote peer heights.
Instead of assuming we have one height, recognize that a peer may
not be at the tip at the same time we are. We monitor headers/invs
to update the 'peerHeight' variable.

2. Ask for merkle blocks from a peer to the maximum height of that
peer (but not later than what we validated to be true).
This avoids us asking past the remotes tip which they didn't like.

3. Redo the SyncSPVAction to use all this and make it much more
reliable in finding peers to download from and getting all the
changes as fast as possible.
2020-11-13 21:03:56 +01:00
TomZ 376fe9dc86 On startup, start downloading headers
In most cases headers would be automatically downloaded if we didn't
connect to that peer for a while, but that is not a guarentee so lets
make sure we actually start downloading headers from any peer we can :)
2020-10-29 22:18:10 +01:00
TomZ 3f5fe41534 P2PNet: Support multiple chains.
This adds support for the testnet4 chain.
2020-10-29 21:47:53 +01:00
TomZ 2e29bc4f6e When saving to non-existing dir, handle the error. 2020-05-23 14:03:29 +02:00
TomZ cafa0ede08 For wallets, start a sync at startup.
This helps when SPV wallets are still behind on merkle-blocks while the
wallet shut down.
We start instantly again, instead of waiting for the first block to be
mined.
2020-05-16 10:27:00 +02: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 93f9758ca5 Add load/save to PeerAddressDB 2020-05-11 13:24:06 +02:00
TomZ 46e1f966e2 Re-enable actions. 2020-05-06 17:59:36 +02:00
TomZ fb6f91bf79 Simplify p2pnet ownership
Make the Peer object be owned by a shared pointer.
2020-05-05 22:53:25 +02:00
TomZ 3f60c0a48f remember 'good headers' flag for a peerAddress 2020-05-05 17:02:10 +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