Skip to content

Commit

Permalink
Extend Bloom Filter support to InstantSend related messages (#2184)
Browse files Browse the repository at this point in the history
* use bloom filters for IX lock votes

* code style fixes
  • Loading branch information
gladcow authored and UdjinM6 committed Jul 20, 2018
1 parent b476173 commit ace9808
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/instantx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,11 @@ bool CTxLockVote::Sign()
void CTxLockVote::Relay(CConnman& connman) const
{
CInv inv(MSG_TXLOCK_VOTE, GetHash());
connman.RelayInv(inv);
CTxLockRequest request;
if(instantsend.GetTxLockRequest(txHash, request))
connman.RelayInvFiltered(inv, *request.tx);
else
connman.RelayInv(inv);
}

bool CTxLockVote::IsExpired(int nHeight) const
Expand Down
15 changes: 15 additions & 0 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2640,6 +2640,21 @@ void CConnman::RelayInv(CInv &inv, const int minProtoVersion) {
pnode->PushInventory(inv);
}

void CConnman::RelayInvFiltered(CInv &inv, const CTransaction& relatedTx, const int minProtoVersion)
{
LOCK(cs_vNodes);
for (const auto& pnode : vNodes) {
if(pnode->nVersion < minProtoVersion)
continue;
{
LOCK(pnode->cs_filter);
if(pnode->pfilter && !pnode->pfilter->IsRelevantAndUpdate(relatedTx))
continue;
}
pnode->PushInventory(inv);
}
}

void CConnman::RecordBytesRecv(uint64_t bytes)
{
LOCK(cs_totalBytesRecv);
Expand Down
1 change: 1 addition & 0 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ class CConnman
void RelayTransaction(const CTransaction& tx);
void RelayTransaction(const CTransaction& tx, const CDataStream& ss);
void RelayInv(CInv &inv, const int minProtoVersion = MIN_PEER_PROTO_VERSION);
void RelayInvFiltered(CInv &inv, const CTransaction &relatedTx, const int minProtoVersion = MIN_PEER_PROTO_VERSION);

// Addrman functions
size_t GetAddressCount() const;
Expand Down

0 comments on commit ace9808

Please sign in to comment.