Improve transaction relaying logic:

The existing logic involves every server sending every transaction
that it receives to all its peers (except the one that it received
a transaction from).

This commit instead uses a randomized algorithm, where a node will
randomly select peers to relay a given transaction to, caching the
list of transaction hashes that are not relayed and forwading them
to peers once every second. Peers can then determine whether there
are transactions that they have not seen and can request them from
the node which has them.

It is expected that this feature will further reduce the bandwidth
needed to operate a server.
This commit is contained in:
Gregory Tsipenyuk
2020-09-08 18:05:08 -04:00
committed by Nik Bougalis
parent 0d17dd8228
commit ea145d12c7
35 changed files with 1349 additions and 71 deletions

View File

@@ -217,6 +217,21 @@ public:
// Set log level to debug so that the feature function can be
// analyzed.
bool VP_REDUCE_RELAY_SQUELCH = false;
// Transaction reduce-relay feature
bool TX_REDUCE_RELAY_ENABLE = false;
// If tx reduce-relay feature is disabled
// and this flag is enabled then some
// tx-related metrics is collected. It
// is ignored if tx reduce-relay feature is
// enabled. It is used in debugging to compare
// metrics with the feature disabled/enabled.
bool TX_REDUCE_RELAY_METRICS = false;
// Minimum peers a server should have before
// selecting random peers
std::size_t TX_REDUCE_RELAY_MIN_PEERS = 20;
// Percentage of peers with the tx reduce-relay feature enabled
// to relay to out of total active peers
std::size_t TX_RELAY_PERCENTAGE = 25;
// These override the command line client settings
std::optional<beast::IP::Endpoint> rpc_ip;