Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions builds/cmake/install-cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@
# Default: ON
# -Dwith-valgrind=<ON/OFF> Use valgrind memcheck client requests.
# Default: OFF
# -Dwith-verbose=<ON/OFF> Compile verbose logging.
# Default: OFF
#
# All unrecognized options provided shall be passed as configuration
# options for all dependencies.
Expand Down Expand Up @@ -1105,8 +1103,6 @@ help()
msg " Default: ON"
msg "-Dwith-valgrind=<ON/OFF> Use valgrind memcheck client requests."
msg " Default: OFF"
msg "-Dwith-verbose=<ON/OFF> Compile verbose logging."
msg " Default: OFF"
msg ""
msg "All unrecognized options provided shall be passed as configuration"
msg "options for all dependencies."
Expand Down
4 changes: 0 additions & 4 deletions builds/cmake/install-presets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@
# Default: ON
# -Dwith-valgrind=<ON/OFF> Use valgrind memcheck client requests.
# Default: OFF
# -Dwith-verbose=<ON/OFF> Compile verbose logging.
# Default: OFF
#
# All unrecognized options provided shall be passed as configuration
# options for all dependencies.
Expand Down Expand Up @@ -1160,8 +1158,6 @@ help()
msg " Default: ON"
msg "-Dwith-valgrind=<ON/OFF> Use valgrind memcheck client requests."
msg " Default: OFF"
msg "-Dwith-verbose=<ON/OFF> Compile verbose logging."
msg " Default: OFF"
msg ""
msg "All unrecognized options provided shall be passed as configuration"
msg "options for all dependencies."
Expand Down
3 changes: 3 additions & 0 deletions builds/gnu/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ src_libbitcoin_node_la_SOURCES = \
${srcdir}/../../src/error.cpp \
${srcdir}/../../src/estimator.cpp \
${srcdir}/../../src/full_node.cpp \
${srcdir}/../../src/rolling_bloom_filter.cpp \
${srcdir}/../../src/settings.cpp \
${srcdir}/../../src/channels/channel_peer.cpp \
${srcdir}/../../src/chasers/chaser.cpp \
Expand Down Expand Up @@ -141,6 +142,7 @@ include_bitcoin_node_HEADERS = \
${srcdir}/../../include/bitcoin/node/events.hpp \
${srcdir}/../../include/bitcoin/node/full_node.hpp \
${srcdir}/../../include/bitcoin/node/preprocessor.hpp \
${srcdir}/../../include/bitcoin/node/rolling_bloom_filter.hpp \
${srcdir}/../../include/bitcoin/node/settings.hpp \
include/bitcoin/node/version.hpp

Expand Down Expand Up @@ -244,6 +246,7 @@ test_libbitcoin_node_test_SOURCES = \
${srcdir}/../../test/estimator.cpp \
${srcdir}/../../test/full_node.cpp \
${srcdir}/../../test/main.cpp \
${srcdir}/../../test/rolling_bloom_filter.cpp \
${srcdir}/../../test/settings.cpp \
${srcdir}/../../test/test.cpp \
${srcdir}/../../test/chasers/chaser.cpp \
Expand Down
4 changes: 0 additions & 4 deletions builds/gnu/install-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@
# Default: --with-secp256k1
# --<with/without>-valgrind Use valgrind memcheck client requests.
# Default: --without-valgrind
# --<with/without>-verbose Compile verbose logging.
# Default: --without-verbose
#
# All unrecognized options provided shall be passed as configuration
# options for all dependencies.
Expand Down Expand Up @@ -1179,8 +1177,6 @@ help()
msg " Default: --with-secp256k1"
msg "--<with/without>-valgrind Use valgrind memcheck client requests."
msg " Default: --without-valgrind"
msg "--<with/without>-verbose Compile verbose logging."
msg " Default: --without-verbose"
msg ""
msg "All unrecognized options provided shall be passed as configuration"
msg "options for all dependencies."
Expand Down
13 changes: 0 additions & 13 deletions builds/msvc/vs2026/libbitcoin-network.import.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,13 @@
<PropertyPageSchema Include="$(MSBuildThisFileDirectory)libbitcoin-network.import.xml" />
</ItemGroup>

<!-- Options -->

<PropertyGroup>
<Option-verbose Condition="'$(Option-verbose)' == ''">false</Option-verbose>
</PropertyGroup>

<!-- Messages -->

<Target Name="NetworkOptionInfo" BeforeTargets="PrepareForBuild">
<Message Text="Option-verbose : $(Option-verbose)" Importance="high"/>
</Target>

<!-- Linkage -->

<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\libbitcoin-network\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\libbitcoin-network\build\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Linkage-libbitcoin-network)' == 'static' Or '$(Linkage-libbitcoin-network)' == 'ltcg'">BCT_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions Condition="'$(Option-verbose)' == 'true'">WITH_LOGV;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies Condition="'$(Linkage-libbitcoin-network)' != ''">libbitcoin-network.lib;%(AdditionalDependencies)</AdditionalDependencies>
Expand Down
12 changes: 0 additions & 12 deletions builds/msvc/vs2026/libbitcoin-network.import.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,4 @@
<EnumValue Name="ltcg" DisplayName="Static using link time compile generation (LTCG)" />
</EnumProperty>
</Rule>
<Rule Name="libbitcoin-network-options-uiextension" PageTemplate="tool" DisplayName="Bitcoin Network Options" SwitchPrefix="/" Order="1">
<Rule.Categories>
<Category Name="verbose" DisplayName="verbose" />
</Rule.Categories>
<Rule.DataSource>
<DataSource Persistence="ProjectFile" ItemType="" />
</Rule.DataSource>
<EnumProperty Name="Option-verbose" DisplayName="Compile Verbose Logging" Description="Compile verbose logging." Category="verbose">
<EnumValue Name="false" DisplayName="No" />
<EnumValue Name="true" DisplayName="Yes" />
</EnumProperty>
</Rule>
</ProjectSchemaDefinitions>
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
<ClCompile Include="..\..\..\..\test\functional\p2p_witness.cpp" />
<ClCompile Include="..\..\..\..\test\main.cpp" />
<ClCompile Include="..\..\..\..\test\protocols\protocol.cpp" />
<ClCompile Include="..\..\..\..\test\rolling_bloom_filter.cpp" />
<ClCompile Include="..\..\..\..\test\sessions\session.cpp" />
<ClCompile Include="..\..\..\..\test\settings.cpp" />
<ClCompile Include="..\..\..\..\test\test.cpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
<ClCompile Include="..\..\..\..\test\protocols\protocol.cpp">
<Filter>src\protocols</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\rolling_bloom_filter.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\test\sessions\session.cpp">
<Filter>src\sessions</Filter>
</ClCompile>
Expand Down
2 changes: 2 additions & 0 deletions builds/msvc/vs2026/libbitcoin-node/libbitcoin-node.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
<ClCompile Include="..\..\..\..\src\protocols\protocol_transaction_out_70001.cpp" />
<ClCompile Include="..\..\..\..\src\protocols\protocol_transaction_out_70013.cpp" />
<ClCompile Include="..\..\..\..\src\protocols\protocol_transaction_out_70016.cpp" />
<ClCompile Include="..\..\..\..\src\rolling_bloom_filter.cpp" />
<ClCompile Include="..\..\..\..\src\sessions\session.cpp" />
<ClCompile Include="..\..\..\..\src\sessions\session_inbound.cpp" />
<ClCompile Include="..\..\..\..\src\sessions\session_manual.cpp" />
Expand Down Expand Up @@ -217,6 +218,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_transaction_out_70013.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocol_transaction_out_70016.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocols.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\rolling_bloom_filter.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\sessions\session.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\sessions\session_inbound.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\sessions\session_manual.hpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@
<ClCompile Include="..\..\..\..\src\protocols\protocol_transaction_out_70016.cpp">
<Filter>src\protocols</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\rolling_bloom_filter.cpp">
<Filter>src</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\sessions\session.cpp">
<Filter>src\sessions</Filter>
</ClCompile>
Expand Down Expand Up @@ -359,6 +362,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\protocols\protocols.hpp">
<Filter>include\bitcoin\node\protocols</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\rolling_bloom_filter.hpp">
<Filter>include\bitcoin\node</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\sessions\session.hpp">
<Filter>include\bitcoin\node\sessions</Filter>
</ClInclude>
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <bitcoin/node/events.hpp>
#include <bitcoin/node/full_node.hpp>
#include <bitcoin/node/preprocessor.hpp>
#include <bitcoin/node/rolling_bloom_filter.hpp>
#include <bitcoin/node/settings.hpp>
#include <bitcoin/node/version.hpp>
#include <bitcoin/node/channels/channel.hpp>
Expand Down
13 changes: 7 additions & 6 deletions include/bitcoin/node/channels/channel_peer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#ifndef LIBBITCOIN_NODE_CHANNELS_CHANNEL_PEER_HPP
#define LIBBITCOIN_NODE_CHANNELS_CHANNEL_PEER_HPP

#include <deque>
#include <bitcoin/node/channels/channel.hpp>
#include <bitcoin/node/configuration.hpp>
#include <bitcoin/node/define.hpp>
#include <bitcoin/node/rolling_bloom_filter.hpp>

namespace libbitcoin {
namespace node {
Expand All @@ -42,12 +42,14 @@ class BCN_API channel_peer
: node::channel(log, socket, identifier, config),
network::channel_peer(log, socket, identifier, config.network, options),
network::tracker<channel_peer>(log),
witness_(config.node.require_witness),
announcement_cache_(config.node.announcement_cache)
witness_(config.node.require_witness)
{
}

/// Record a block or tx hash known to the peer.
void set_announced(const system::hash_digest& hash) NOEXCEPT;

/// The hash is (probably) known to the peer.
bool was_announced(const system::hash_digest& hash) const NOEXCEPT;

protected:
Expand All @@ -61,12 +63,11 @@ class BCN_API channel_peer
}

private:
// These are thread safe (const).
// This is thread safe (const).
const bool witness_;
const size_t announcement_cache_;

// This is protected by strand.
std::deque<system::hash_digest> announced_{};
rolling_bloom_filter announced_{};
};

} // namespace node
Expand Down
11 changes: 11 additions & 0 deletions include/bitcoin/node/protocols/protocol_transaction_out_106.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,22 @@ class BCN_API protocol_transaction_out_106
const network::messages::peer::get_data::cptr& message,
const gate_t::ptr& gate) NOEXCEPT;

/// Queue the tx for announcement, unless known to the peer.
virtual bool announce(const system::hash_digest& hash) NOEXCEPT;

/// Announce the queued txs unless an announcement is being written.
virtual void do_flush() NOEXCEPT;
virtual void handle_flush(const code& ec) NOEXCEPT;

private:
void send_queued() NOEXCEPT;

// These are thread safe.
const bool node_witness_;

// These are protected by strand.
inventory_items queued_{};
bool writing_{};
};

} // namespace node
Expand Down
67 changes: 67 additions & 0 deletions include/bitcoin/node/rolling_bloom_filter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* Copyright (c) 2011-2026 libbitcoin developers
*
* This file is part of libbitcoin.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBBITCOIN_NODE_ROLLING_BLOOM_FILTER_HPP
#define LIBBITCOIN_NODE_ROLLING_BLOOM_FILTER_HPP

#include <bitcoin/node/define.hpp>

namespace libbitcoin {
namespace node {

/// Not thread safe rolling bloom filter of hashes, by generation.
class BCN_API rolling_bloom_filter
{
public:
/// Insert the hash, replacing the oldest generation when current is full.
void insert(const system::hash_digest& hash) NOEXCEPT;

/// The hash is (probably) inserted.
bool contains(const system::hash_digest& hash) const NOEXCEPT;

private:
static uint64_t entropy(const system::hash_digest& hash) NOEXCEPT;

// Retains at least the most recent (generations - 1) * generation.
static constexpr auto generations = 3_size;
static constexpr auto generation = network::messages::peer::max_inventory;

// False positive rate of about 2^-probes per generation.
static constexpr auto probes = 20_size;

// Optimal bits per generation, generation * probes / ln(2).
static constexpr auto micro = 1'000'000_u64;
static constexpr auto ln2_micro = 693'147_u64;
static constexpr auto load = system::multiply<uint64_t>(generation, probes);
static constexpr auto scaled = system::multiply(load, micro);
static constexpr auto rounded = system::ceilinged_divide(scaled, ln2_micro);
static constexpr auto optimal = system::possible_narrow_cast<size_t>(rounded);

using filter = system::bloom_array<optimal, probes>;
using table = std::shared_ptr<filter::type>;

// These are not thread safe.
std::array<table, generations> known_{};
size_t current_{};
size_t count_{};
};

} // namespace node
} // namespace libbitcoin

#endif
1 change: 0 additions & 1 deletion include/bitcoin/node/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class BCN_API settings
uint64_t batch_verify;
uint64_t batch_silent;
uint16_t current_connections;
uint16_t announcement_cache;
uint16_t fee_estimate_horizon;
uint32_t maximum_height;
uint32_t maximum_concurrency;
Expand Down
11 changes: 2 additions & 9 deletions src/channels/channel_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,13 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT)
void channel_peer::set_announced(const hash_digest& hash) NOEXCEPT
{
BC_ASSERT(stranded());
if (is_zero(announcement_cache_))
return;

if (announced_.size() == announcement_cache_)
announced_.pop_front();

announced_.push_back(hash);
announced_.insert(hash);
}

bool channel_peer::was_announced(const hash_digest& hash) const NOEXCEPT
{
BC_ASSERT(stranded());
return std::find(announced_.begin(), announced_.end(), hash) !=
announced_.end();
return announced_.contains(hash);
}

BC_POP_WARNING()
Expand Down
Loading
Loading