Commit Graph

12069 Commits

Author SHA1 Message Date
TomZ 7bfe5e0e2c Provide a getter for blockHeight on Blockchain 2020-05-11 18:07:10 +02:00
TomZ d0bc12ea2d API docs and minor fixes 2020-05-11 17:42:44 +02:00
TomZ 43d7626d46 P2PNet make the blockchain class save its state. 2020-05-11 15:16:59 +02:00
TomZ c68bb14583 Merge remote-tracking branch 'gitlab/master' 2020-05-11 13:28:35 +02:00
TomZ 93f9758ca5 Add load/save to PeerAddressDB 2020-05-11 13:24:06 +02:00
TomZ bd2a06a9ff Add a save to match the load Addr. 2020-05-11 13:24:06 +02:00
TomZ 79a92cf2ce NWM: work better with large concurrency
The asio stuff is quite broken when it comes to, ironically,
concurrency.
Connecting to peers lead to lots of 'canceled' (sic) errors being
generated internally in asio and other such issues.
Even though they were called on separate objects.

Adding a mutex around the async_connect calls made the amount of
failures go down dramatically.

This patch also includes upgrading boost::mutex to the std-lib
versions.
2020-05-11 13:19:10 +02:00
TomZ ed5b100ca5 Delete ununsed connections on shutdown. 2020-05-10 22:03:22 +02:00
Tom Zander dbb204d8e6 Merge branch 'master' into 'master'
Added MySQL support to AddressIndexer

See merge request FloweeTheHub/thehub!13
2020-05-10 16:47:40 +00:00
justBCHit 833b256469 Added MySQL support to AddressIndexer 2020-05-10 16:11:32 +00:00
TomZ 010df674e4 P2PNet: Use exceptions and avoid deadlock.
This avoids still having the blockchain lock while calling into the
connectionmanager which may do the reverse, causing deadlock.
2020-05-10 16:02:14 +02:00
TomZ 0b3dc7a8f5 NWM: fix reconnects/reuse of connection 2020-05-10 16:02:14 +02:00
TomZ ebbbdcd3a2 P2PNet: log improvement.
Also fix cron disconnecting peers before they connect.
2020-05-10 16:02:14 +02:00
TomZ 36cd1d4f56 Just disconnect a slow peer, don't ban. 2020-05-10 16:02:14 +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 5bb095f8a2 Minor fixes in usage of shared pointers. 2020-05-07 18:26:41 +02:00
TomZ 9b9be73a5d Detect already deleted peer. 2020-05-07 17:01:03 +02:00
TomZ 9a78e770ac P2PNet: handle errors better
This changes handling to also remove peers that fail with:
  "Cannot assign requested address"
An error seen in a Docker container on a system supporting IPv6.

Additionally we now always assign a error level so an unknown error will
still cause the node to be banned after 5 attempts.
2020-05-07 16:07:12 +02:00
TomZ dc9a92c57e Also install the new header. 2020-05-07 15:38:32 +02:00
TomZ 488e9b4322 Add missing dependency 2020-05-07 14:04:57 +02:00
TomZ 6a5ccf30cf Move 'sendheaders' msg to after version handshake 2020-05-06 23:59:02 +02:00
TomZ 39fb4723ef Lost this in the refactor. 2020-05-06 18:38:37 +02:00
TomZ 46e1f966e2 Re-enable actions. 2020-05-06 17:59:36 +02:00
TomZ 7ad2592d40 P2PNet: API cleanups and review + docs. 2020-05-06 10:42:58 +02:00
TomZ 991da54d3c List our own seeder too 2020-05-06 10:39:47 +02:00
TomZ 0dd33072f7 Explain briefly how the config file works. 2020-05-06 10:39:23 +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 16168bc541 slight fixes in logging 2020-05-05 10:56:57 +02:00
TomZ bf76c5ab36 Write all bytes after command to zero.
Instead of just a single trailing zero, write all bytes of the
command-section. This is required by the protocol.
2020-05-05 10:54:26 +02:00
TomZ c2dd23d89b Merge branch '2020.03' 2020-05-03 21:02:50 +02:00
TomZ 3f16f6224a Fix the threading model in the P2PNet
This allows deletion of peers also from other threads than their own
assigned ones.
2020-05-03 21:02:45 +02:00
TomZ b51d15e3c5 Add some more comments and sanity checks 2020-05-03 19:52:44 +02:00
TomZ 2298df4935 Make peer shutdown safer.
This avoids a race condition on remove/delete of peer where
the connection manager decides to delete a peer while in its own thread
the peer is processing a package.
This moves deletion of the peer to its own strand.
2020-04-27 15:47:15 +02:00
TomZ 43ea10d9ef Prioritize the actually maintained seed 2020-04-27 11:39:57 +02:00
TomZ 164b2b4f18 Also disconnect peers that failed the version msg
When during parsing of the version message an error was found,
we should still disconnect it after 30 seconds when it doesn't
recover.
2020-04-27 11:38:53 +02:00
TomZ 6e10b8d435 P2PNet: Fixes and some new methods 2020-04-26 16:20:45 +02:00
TomZ 488fc14ece Merge branch '2020.03' 2020-04-24 10:52:39 +02:00
TomZ 2f7f7cec4c Nicely initialize the variable every loop 2020.03.2 2020-04-24 10:41:55 +02:00
TomZ d71cc4b84b [CMake] rename 'find' files to the package name
Resolve inconsistencies
2020-04-22 17:58:42 +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
TomZ 37d8209d64 use constexpr 2020-04-17 17:32:16 +02:00
TomZ 2870f42ad3 Split PartialMerkleTree out into its own header.
Additionally:
- add loading to it from a P2PParser
- move code from header to cpp file
2020-04-17 17:31:46 +02:00
TomZ e5ee37fd87 Fix larger messages in LegacyP2P mode.
Splitting up the bigger message in chunks is not supported on the legacy
p2p network, so don't attempt.
2020-04-16 17:12:57 +02:00
TomZ 4506e3d639 Start new streaming classes for the p2p protocol
And implemnt saving in the bloom filter for test
2020-04-16 17:12:57 +02:00
TomZ daabb551eb master is not a release 2020-04-13 18:36:02 +02:00
TomZ dc95dae34a new version 2020.03.1 2020-04-13 18:35:32 +02:00
TomZ 01bc6a4d71 fix url to online help 2020-04-13 18:15:54 +02:00
TomZ 63021917ed Fixlet in secp256k1/CMakeLists.txt 2020-04-13 15:57:42 +02:00