From 18cce4836cc0ee69b867825ddbe2ddb004f05bdc Mon Sep 17 00:00:00 2001 From: gladcow Date: Thu, 12 Jul 2018 12:40:12 +0300 Subject: [PATCH 1/2] use bloom filters for IX lock votes --- src/instantx.cpp | 6 +++++- src/net.cpp | 17 +++++++++++++++++ src/net.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/instantx.cpp b/src/instantx.cpp index afe7f7e10f2d8..3f02f47941533 100644 --- a/src/instantx.cpp +++ b/src/instantx.cpp @@ -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 diff --git a/src/net.cpp b/src/net.cpp index 988230de8e73e..cfcb418bcfa6c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2640,6 +2640,23 @@ 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); // TODO: do we need it? + if(pnode->pfilter && + !pnode->pfilter->IsRelevantAndUpdate(relatedTx)) + continue; + } + pnode->PushInventory(inv); + } +} + void CConnman::RecordBytesRecv(uint64_t bytes) { LOCK(cs_totalBytesRecv); diff --git a/src/net.h b/src/net.h index cd135e5f230d5..bc58b4ebac232 100644 --- a/src/net.h +++ b/src/net.h @@ -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; From b7629001b02fc2b277d52d9dfb0fda6c71e53d9d Mon Sep 17 00:00:00 2001 From: gladcow Date: Tue, 17 Jul 2018 12:08:53 +0300 Subject: [PATCH 2/2] code style fixes --- src/net.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index cfcb418bcfa6c..630ab50b5b258 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2640,17 +2640,15 @@ void CConnman::RelayInv(CInv &inv, const int minProtoVersion) { pnode->PushInventory(inv); } -void CConnman::RelayInvFiltered(CInv &inv, - const CTransaction& relatedTx, - const int minProtoVersion) { +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); // TODO: do we need it? - if(pnode->pfilter && - !pnode->pfilter->IsRelevantAndUpdate(relatedTx)) + LOCK(pnode->cs_filter); + if(pnode->pfilter && !pnode->pfilter->IsRelevantAndUpdate(relatedTx)) continue; } pnode->PushInventory(inv);