24 Commits

Author SHA1 Message Date
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 e508631885 The effects of resetAll was better than just pardons 2024-01-28 21:31:28 +01:00
tomFlowee ffe458a1f6 Remove unused member 2024-01-28 19:51:56 +01:00
tomFlowee 9d980fdcad Minor tweaks to IP selection.
When we didn't personally verify the services, don't judge the IP based
on them and connect anyway.

In addition to not trusting the services we receive from the net, be
more careful with the usage of the 'lastConnected' field.
Notice that we don't actually use the result of that variable in the end
if the everConnected is likewise incorrect.
2024-01-28 17:01:01 +01:00
tomFlowee dc9ef827b4 Fix various issues in the addressDB
this introduces a new version of the address-db, as stored in the db
file itself. Causing a one-time 'upgrade'.
Main issue solved is that the 'everSeen' bool was restored incorrectly
and from then on out saved wrong too.
This may have caused bad selection of peers to connect to as the DB
grew.

Together with the various bugs in the last months update we also reset
the punishment to not avoid connecting to possibly perfectly fine peers.
2024-01-26 13:32:39 +01:00
tomFlowee 4fe9d69e7b Use more specific define-guards 2024-01-24 21:03:58 +01:00
tomFlowee 18b14a97bc add method to pardon sinners 2024-01-14 17:07:38 +01:00
tomFlowee 8d5c1604f8 Add accessors for the ip version support
The AddressDB stores separately the ipv4 and ipv6 addresses, ensuring
that the caller only receives IP addresess compatible with what they
asked.
Until now the booleans to define this were simply private members of the
DB and ipv6 was off.

This exposes those boolean to the outside world.
2024-01-06 22:01:00 +01:00
tomFlowee 618585f22b Add feature; PeerAddressDB statistics generation. 2024-01-06 22:01:00 +01:00
tomFlowee f50ad44529 Tweaks in the punishment score
The PeerAddressDB keeps a score for each IP/port we have about how
useful that peer is.
This change re-visits the way we use the DB where we now are more fluid
in our approach to scores. We no longer simply forever-ban a peer after
it made a mistake once.

This rewrites the select-a-peer algo to take timing into account,
preferring a peer that we connected to recently while putting a higher
score on a peer that failed a long time ago so if we start running out
of good peers we start on the not-so-great-but-maybe-improved first.

Good behavior is likewise rewarded so a peer can become higher prio
again, but generally a new IP still gets preferred. Again, the balance
is to keep not-so-great options in the running.
2023-04-24 13:48:55 +02:00
tomFlowee c6d5bd6336 API Doc addition. 2023-02-25 11:04:19 +01:00
tomFlowee 64d382b7c4 Add saveData() function to p2p net 2022-11-11 19:25:19 +01:00
tomFlowee 0d8845386d API docs. 2021-07-30 10:01:06 +02:00
tomFlowee adfe4081cb Update copyright notice and email address 2021-02-02 13:08:07 +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 3f5fe41534 P2PNet: Support multiple chains.
This adds support for the testnet4 chain.
2020-10-29 21:47:53 +01:00
TomZ 10cc4443ab Add a mutex to the peer-address-db
As this is a multi-threaded enabled class, even though 99% of it is
reads, we still need to lock.
2020-05-16 11:01:27 +02:00
TomZ 148f9c0e93 Improve tracking of 'good' peers.
This avoids a peer once sending acceptable headers and never
being bothered again. Instead we now check regularly and keep
track of when the peer was known to follow the same chain as us.
2020-05-11 18:49:16 +02:00
TomZ 93f9758ca5 Add load/save to PeerAddressDB 2020-05-11 13:24:06 +02:00
TomZ ebbbdcd3a2 P2PNet: log improvement.
Also fix cron disconnecting peers before they connect.
2020-05-10 16:02:14 +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 3f60c0a48f remember 'good headers' flag for a peerAddress 2020-05-05 17:02:10 +02:00
TomZ 6e10b8d435 P2PNet: Fixes and some new methods 2020-04-26 16:20:45 +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