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.
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.
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.
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.
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.
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.
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.
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.
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.
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.