193 Commits

Author SHA1 Message Date
TomZ db9eb1adfb Install some more files 2019-05-30 13:36:57 +02:00
TomZ e6a23d5f4f Merge branch '2019.05' 2019-05-27 09:28:25 +02:00
TomZ 702addadbb Remove race-conditions in connecting 2019-05-27 09:27:26 +02:00
TomZ 8ed6d6a3e2 NWM: Fix reconnecting a dead connection
A disconnect would cause the socket to close which caused a
callback which triggered a timer to reconnect after half a minute...

This makes sure that after we manually disconnect we honor that.
2019-05-27 09:23:05 +02:00
TomZ a20118c5fb Add LiveService unit test
The bugreport claimed that sending an existing coinbase would give
inconsistent results. This test can't find any unexpected behaviour.
2019-05-27 09:23:05 +02:00
TomZ 18035c2e66 Start new testing setup for API testing
This is a blackbox type testing for specific API calls.
2019-05-25 17:06:23 +02:00
TomZ 38b4e8b189 Allow hubs -apibind to use 'localhost' string
The command really only accepts IP addresses, but we use 'localhost' as
an exception to bind to loopback for ipv4 and ipv6 at the same time.

Also improve logging of errors and avoid failing to start the API
service if a bind address wasn't an IP.
2019-05-24 23:14:15 +02:00
TomZ a54107c168 Make NetworkService thread-safe
This makes the access to the per-peer datastructure lock-free and
thread-safe.
2019-05-18 16:03:22 +02:00
TomZ ba2216d582 Add to CLI clients verbose/quiet options
All client apps (=connecting to a server only) now gained the  verbose
and quiet command line arguments to select a different level of
verbosity.

Servers don't need this as they use a config file.

This also makes the --debug option only for debug builds as the logging
system already doesn't compile in debug statements otherwise, it makes
little sense to try to print them.
2019-05-13 18:27:09 +02:00
TomZ 7fbb6772de NWM: Promote some debug level to warn/info 2019-05-13 12:20:57 +02:00
TomZ aa2c1a6f60 Vastly simplify the NWM callback after sent 2019-04-11 16:20:05 +02:00
TomZ 6cc433c589 Make usage of NetworkConnection::accept() clear
I added some docs to bind() that handlers there should call
accept().
Also made sure that when nobody accepts a connection it actually
gets disconnected instead of just being ignored.
2019-04-10 14:28:33 +02:00
TomZ ccd66a49b2 Document and refactor NetworkService
The main goal of this is to make sure that network services
implementations don't reuse one bufferpool for all their remotes as that
can cause threading issues.
One bufferpool per remote is now made easy.
2019-04-09 17:24:38 +02:00
TomZ 0c97e3261f Cleanup close/disconnect in NWM
Specifically avoid clearing the messages queue when the other side
disconnects.
2019-04-06 12:28:41 +02:00
TomZ cec1950650 Make connection wait on destructor
Make sure that a NetworkConnection object (which owns the callbacks)
doesn't return from its destructor until the already scheduled callbacks
in another thread have been completed.

This avoids shutdown scenarios where we execute in a deleted
object.
2019-04-06 11:59:49 +02:00
TomZ 9846b467e3 Move code and avoid work.
Move the creation of the ping message to the constructor (from the
connection-established method) so we are certain it gets done exactly
once.

Also avoid putting default (invalid) values in the hashmap.
2019-04-04 22:46:39 +02:00
TomZ 519cd1b6fc Work on stability of the NetworkManager
In extreme cases we might end up going over the bounds of the internal
buffers, as such myConnection.send() may now throw.

I also cleaned up the ping design and made it a bit more strict.
Last I increased the amount of incoming data I can receive in one go,
this will make throughput higher.
2019-04-01 10:57:42 +02:00
TomZ b8d329ef9f Further moves; NetworkEnums and netbase.{cpp|h}
NetworkEnums.h moves from utils to interfaces.
netbase moves from server to utils/
2019-03-29 21:39:08 +01:00
TomZ 5939de8ef0 Move API protocol definition to interfaces dir.
It makes no sense to include the API "library" just to use
the header file.
2019-03-29 21:07:28 +01:00
TomZ 57542dda91 Fix regression in NWM (after RingBuffers intro) 2019-03-28 10:23:32 +01:00
TomZ 6475d6060a Fix connecting to named hosts (as opposed to IPs) 2019-03-28 10:23:28 +01:00
TomZ cd31c199ee Add some more asserts to NWM 2019-03-27 20:25:07 +01:00
TomZ c8108f387c Drop API login requirement and api-cookie argument 2019-03-27 18:55:13 +01:00
TomZ 5d0fb95fda Fixlet; move assert
The boost APIs may callback outside of the strand in case of an error.
2019-03-25 12:50:27 +01:00
TomZ a8dd567006 Add unit test for the ring buffer class. 2019-03-24 11:43:43 +01:00
TomZ b8cf859fa6 Upgrade NWM to use ringbuffers
for internal purposes the network manager used std::list instances
for things that essentially were FIFO queues.
With high volume of packages being sent this causes a large overhead
and even a crash or two.
So I replaced them with ringbuffers which means that the normal
sending
of data will remove a large selection of mem allocations.
2019-03-24 10:23:52 +01:00
TomZ 8713914c47 Refactor to create a new baseclass for services
A NetworkSubscriptionService baseclass that creates
some metadata for each connection that uses the service.
2019-03-17 22:49:46 +01:00
TomZ 0e7dcf5b73 Enable hostname (DNS) based connections. 2019-03-04 20:16:40 +01:00
TomZ 36b7f7adb9 Use more c++ constructs 2018-06-12 19:46:40 +02:00
TomZ fab80a99ff Make network manager connect faster 2018-03-26 17:26:06 +02:00
TomZ dd742b6ab9 Add support for headerInt
Sending a message with a 'requestId' will transparantly make the reply
have that same requestId.
For easy matching of what the reply is for.
2018-03-21 17:56:56 +01:00
TomZ 21a08ec316 Fix sometimes not sending a message. 2018-03-16 23:33:16 +01:00
TomZ 066f9586d8 on registering an address at AddressMonitorService, search mempool.
So the service only noticed new stuff happening, like a transaction
coming in or block being mined.
With this change we get a little smarter and look in the current mempool
as well to try and match a transaction.

This should be very useful for clients that lose network connection
briefly.
2018-02-19 00:02:24 +01:00
TomZ cc5d3bd5ce Make compile with boost 1.66 2018-02-18 01:04:41 +01:00
TomZ 0d3d9f0efb Add NetworkManager::setAutoApiLogin() method.
Make sure that clients can do login to the API by doing nothing more
than pointing to the filename of the api-cookie.
2018-02-17 23:33:23 +01:00
TomZ 72593ea6a5 Merge branch 'master' into pos 2018-02-17 19:02:18 +01:00
TomZ 5769517646 Make MessageParser use ConstBuffer more. 2018-02-17 14:47:51 +01:00
TomZ e16353a7cc fix innocent copy/paste bug 2018-02-17 14:45:09 +01:00
TomZ 95325d5cdb Be consistent; lowercase the networkmanager dir. 2018-02-16 12:36:51 +01:00
TomZ 8cfacf219b Add NetworkService class 2018-02-16 12:32:08 +01:00
TomZ 954948246f Make clear this content is under the same license 2018-02-14 14:26:28 +01:00
TomZ 4ac68439d1 Introduce CMake building 2018-02-14 13:49:54 +01:00
TomZ 7e737c8ea8 Start library/networkmanger 2018-02-14 13:49:53 +01:00