Prefer a const reference instead of shared_ptr if the shared_ptr
is not used and argument type is not changed in the method.
This allows to prevent useless shared_ptr allocations.
In getRealPrefix, use OpState to track state instead of using many
different shared_ptr.
Fixes a bug where some callbacks wouldn't be called when a dummy request was
inserted to cancel some operation while not using the
net::Request::State::COMPLETED flag as per 19c47ec.
When learning about nodes in an answer,
we used to drop nodes with loopback address.
Address is now replaced by the packet sender
address and the port is preserved.
The op token is renewed regularly (around every 30 minutes),
so SHA256 provides enough security for this non-sensitive token.
SHA256 takes 32 bytes instead of 64 bytes for SHA512,
and the token is included in every listen requests,
renewed every 30 seconds, and every answer to get.
In the context of limited bandwith usage, using SHA256 seems more appropriate.
This change is backward and forward compatible.
After a connectivity change, the DHT would enter the "connecting" state in order
to try to resolve good nodes. However, the previous algorithm would
probabilistically increase time for completion each time a node would fail to
resolve. We now avoid this by prioritizing non-expired nodes in the process.
Also, a subtle error would sensibly stop the process for 30 minutes due to using
the Node::NODE_EXPIRE_TIME constant instead of Node::MAX_RESPONSE_TIME.
Since the initial implementation of listen operation, multiple listen requests
from a single node on a same hash was not possible without singular
inconsistencies. The flaw was coming from the fact that nodes receiving listen
request could not differentiate between listen refresh request and a new
independent listen request.
This patch introduces the new net::Socket structure which in time will enable
remote nodes to send update for a storage while differentiating between
concurrent listen requests. A socket has a unique identifier which consists of a
transaction id as defined in the OpenDHT protocol.