p2p privacy
This commit is contained in:
28
src/net.cpp
28
src/net.cpp
@@ -31,6 +31,7 @@
|
|||||||
#include "ui_interface.h"
|
#include "ui_interface.h"
|
||||||
#include "crypto/common.h"
|
#include "crypto/common.h"
|
||||||
#include "hush/utiltls.h"
|
#include "hush/utiltls.h"
|
||||||
|
#include <random.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#else
|
#else
|
||||||
@@ -1981,16 +1982,30 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss)
|
|||||||
vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv));
|
vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv));
|
||||||
}
|
}
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
|
||||||
|
auto vRelayNodes = vNodes;
|
||||||
|
|
||||||
|
// We always round down, except when we have only 1 connection
|
||||||
|
auto newSize = (vNodes.size() / 2) == 0 ? 1 : (vNodes.size() / 2);
|
||||||
|
|
||||||
|
random_shuffle( vRelayNodes.begin(), vRelayNodes.end(), GetRandInt );
|
||||||
|
|
||||||
|
vRelayNodes.resize(newSize);
|
||||||
|
fprintf(stderr, "%s: Relaying to %lu peers\n", __func__, newSize);
|
||||||
|
|
||||||
|
// Only relay to randomly chosen 50% of peers
|
||||||
|
BOOST_FOREACH(CNode* pnode, vRelayNodes)
|
||||||
{
|
{
|
||||||
if(!pnode->fRelayTxes)
|
if(!pnode->fRelayTxes)
|
||||||
continue;
|
continue;
|
||||||
LOCK(pnode->cs_filter);
|
LOCK(pnode->cs_filter);
|
||||||
if (pnode->pfilter)
|
if (pnode->pfilter) {
|
||||||
{
|
if (pnode->pfilter->IsRelevantAndUpdate(tx)) {
|
||||||
if (pnode->pfilter->IsRelevantAndUpdate(tx))
|
|
||||||
pnode->PushInventory(inv);
|
pnode->PushInventory(inv);
|
||||||
} else pnode->PushInventory(inv);
|
}
|
||||||
|
} else {
|
||||||
|
pnode->PushInventory(inv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2053,10 +2068,7 @@ void CNode::Fuzz(int nChance)
|
|||||||
Fuzz(2);
|
Fuzz(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// CAddrDB
|
// CAddrDB
|
||||||
//
|
|
||||||
|
|
||||||
CAddrDB::CAddrDB()
|
CAddrDB::CAddrDB()
|
||||||
{
|
{
|
||||||
pathAddr = GetDataDir() / "peers.dat";
|
pathAddr = GetDataDir() / "peers.dat";
|
||||||
|
|||||||
Reference in New Issue
Block a user