Commit Graph

20 Commits

Author SHA1 Message Date
tomFlowee dcaddcca7c Remove unused include 2024-06-01 19:22:27 +02:00
tomFlowee 4fe9d69e7b Use more specific define-guards 2024-01-24 21:03:58 +01:00
tomFlowee fb927b9436 Continue shared_ptr convertion of Peer
Last year we started wrapping the Peer object in a shared pointer,
which is used now in the managers.
This continues the idea by making the PrivacySegment use smart
pointers too and the P2PNetInterface is changed to do the same
for downstream applications.
2024-01-04 17:06:32 +01: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 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 64d382b7c4 Add saveData() function to p2p net 2022-11-11 19:25:19 +01:00
tomFlowee d18e13b93b Add new callback on DataListenerInterface when we synched headers 2021-05-28 14:53:19 +02:00
tomFlowee f026e626a1 Add notifications for the p2pnet lib. 2021-02-05 17:22:52 +01:00
tomFlowee adfe4081cb Update copyright notice and email address 2021-02-02 13:08:07 +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 afd33b2ee0 API docs 2020-11-05 22:06:41 +01:00
TomZ 5e48d0dae7 Be smarter about when to ask for headers.
This avoids us asking a bunch of peers the headers while we are not yet
at the tip.
2020-11-05 21:54:33 +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 84ee1bc3fe Minor: comments and whitespace. 2020-09-17 20:53:56 +02:00
TomZ 652fc1e161 Introduce structure to broadcast transactions.
To send out transactions in the p2p net is quite a lot of work,
you need to find multiple peers to send the transaction to. First
you send an INV, then you respond to a getData to actually send
the transaction and last you wait for 'reject' messages that may
indicate that there is something wrong with the transaction.

This introduces the BroadcastTxData class that wraps a transaction
and gets callbacks for sending and for rejects, abstracting away
all the complexity for the user.
2020-06-08 21:35:10 +02:00
TomZ d0bc12ea2d API docs and minor fixes 2020-05-11 17:42:44 +02:00
TomZ 93f9758ca5 Add load/save to PeerAddressDB 2020-05-11 13:24:06 +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