Commit Graph

15 Commits

Author SHA1 Message Date
TomZ 37e1f2fcd3 Fix bad usage of create_directories() 2020-11-14 23:59:01 +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 6d9881f413 Play with punishment
Based on the idea that randomly selecting a peer from our database will
prioritize based on the peers punishment score, this sets the punishment
for never connected-to peers at 10 (out of 1000) just to give a minor
benefit to speeding up the meshing.
2020-05-20 20:31:19 +02:00
TomZ 52f40acb93 Speed up loading 2020-05-19 08:27:53 +02:00
TomZ 7ba11b9880 Unify usage of random number generator. 2020-05-18 19:53:11 +02:00
TomZ f6bf22e9ad Remember 'reset' time.
This allows the seeder to re-investigate a peer that has high
punishment, but has not been tried for a long time.
2020-05-17 22:31:30 +02: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 00453d52c4 NWM: Reuse connection objects
Avoid deleting and creating connections, which is really a rather rare
event anyway, and simply remember the connection object and reuse it
when a new one is requested.
2020-05-10 16:01:08 +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