Skip to content

Commit 440f1d3

Browse files
theunisipa
authored andcommitted
net: remove now-unused ssSend and Fuzz
1 parent 5c2169c commit 440f1d3

File tree

2 files changed

+1
-41
lines changed

2 files changed

+1
-41
lines changed

src/net.cpp

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ void CConnman::ThreadSocketHandler()
10631063
BOOST_FOREACH(CNode* pnode, vNodesCopy)
10641064
{
10651065
if (pnode->fDisconnect ||
1066-
(pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->nSendSize == 0 && pnode->ssSend.empty()))
1066+
(pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->nSendSize == 0))
10671067
{
10681068
// remove from vNodes
10691069
vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end());
@@ -2482,46 +2482,10 @@ int CConnman::GetBestHeight() const
24822482
return nBestHeight.load(std::memory_order_acquire);
24832483
}
24842484

2485-
void CNode::Fuzz(int nChance)
2486-
{
2487-
if (!fSuccessfullyConnected) return; // Don't fuzz initial handshake
2488-
if (GetRand(nChance) != 0) return; // Fuzz 1 of every nChance messages
2489-
2490-
switch (GetRand(3))
2491-
{
2492-
case 0:
2493-
// xor a random byte with a random value:
2494-
if (!ssSend.empty()) {
2495-
CDataStream::size_type pos = GetRand(ssSend.size());
2496-
ssSend[pos] ^= (unsigned char)(GetRand(256));
2497-
}
2498-
break;
2499-
case 1:
2500-
// delete a random byte:
2501-
if (!ssSend.empty()) {
2502-
CDataStream::size_type pos = GetRand(ssSend.size());
2503-
ssSend.erase(ssSend.begin()+pos);
2504-
}
2505-
break;
2506-
case 2:
2507-
// insert a random byte at a random position
2508-
{
2509-
CDataStream::size_type pos = GetRand(ssSend.size());
2510-
char ch = (char)GetRand(256);
2511-
ssSend.insert(ssSend.begin()+pos, ch);
2512-
}
2513-
break;
2514-
}
2515-
// Chance of more than one change half the time:
2516-
// (more changes exponentially less likely):
2517-
Fuzz(2);
2518-
}
2519-
25202485
unsigned int CConnman::GetReceiveFloodSize() const { return nReceiveFloodSize; }
25212486
unsigned int CConnman::GetSendBufferSize() const{ return nSendBufferMaxSize; }
25222487

25232488
CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn, SOCKET hSocketIn, const CAddress& addrIn, uint64_t nKeyedNetGroupIn, uint64_t nLocalHostNonceIn, const std::string& addrNameIn, bool fInboundIn) :
2524-
ssSend(SER_NETWORK, INIT_PROTO_VERSION),
25252489
addr(addrIn),
25262490
fInbound(fInboundIn),
25272491
id(idIn),

src/net.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,6 @@ class CNode
593593
ServiceFlags nServices;
594594
ServiceFlags nServicesExpected;
595595
SOCKET hSocket;
596-
CDataStream ssSend;
597596
size_t nSendSize; // total size of all vSendMsg entries
598597
size_t nSendOffset; // offset inside the first vSendMsg already sent
599598
uint64_t nSendBytes;
@@ -645,9 +644,6 @@ class CNode
645644
mapMsgCmdSize mapSendBytesPerMsgCmd;
646645
mapMsgCmdSize mapRecvBytesPerMsgCmd;
647646

648-
// Basic fuzz-testing
649-
void Fuzz(int nChance); // modifies ssSend
650-
651647
public:
652648
uint256 hashContinue;
653649
int nStartingHeight;

0 commit comments

Comments
 (0)