diff --git a/builds/cmake/install-cmake.sh b/builds/cmake/install-cmake.sh index 156b8b43..52aa3d9d 100755 --- a/builds/cmake/install-cmake.sh +++ b/builds/cmake/install-cmake.sh @@ -456,6 +456,7 @@ main() secp256k1_OPTIONS=( "-DSECP256K1_BUILD_TESTS=OFF" "-DSECP256K1_EXPERIMENTAL=ON" + "-DSECP256K1_ENABLE_MODULE_ELLSWIFT=ON" "-DSECP256K1_ENABLE_MODULE_RECOVERY=ON" "-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON") diff --git a/builds/cmake/install-presets.sh b/builds/cmake/install-presets.sh index 10efe303..d37e3dbf 100755 --- a/builds/cmake/install-presets.sh +++ b/builds/cmake/install-presets.sh @@ -472,6 +472,7 @@ main() secp256k1_OPTIONS=( "-DSECP256K1_BUILD_TESTS=OFF" "-DSECP256K1_EXPERIMENTAL=ON" + "-DSECP256K1_ENABLE_MODULE_ELLSWIFT=ON" "-DSECP256K1_ENABLE_MODULE_RECOVERY=ON" "-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON") diff --git a/builds/gnu/install-gnu.sh b/builds/gnu/install-gnu.sh index bd6775cd..63d22fa8 100755 --- a/builds/gnu/install-gnu.sh +++ b/builds/gnu/install-gnu.sh @@ -484,6 +484,7 @@ main() secp256k1_OPTIONS=( "--disable-tests" "--enable-experimental" + "--enable-module-ellswift" "--enable-module-recovery" "--enable-module-schnorrsig") diff --git a/data/bn.cfg b/data/bn.cfg deleted file mode 100644 index b3206e23..00000000 --- a/data/bn.cfg +++ /dev/null @@ -1,321 +0,0 @@ -# Libbitcoin Node configuration file - -[bitcoin] -# The activation time for bip16 in unix time, defaults to 1333238400. -bip16_activation_time = -# The number of blocks considered for bip34 style soft fork activation, defaults to 1000. -bip34_activation_sample = -# The number of new version blocks required for bip34 style soft fork activation, defaults to 750. -bip34_activation_threshold = -# The number of new version blocks required for bip34 style soft fork enforcement, defaults to 950. -bip34_enforcement_threshold = -# The block height to freeze the bip34 softfork for bip90, defaults to 227931. -bip34_freeze = -# The block height to freeze the bip65 softfork for bip90, defaults to 388381. -bip65_freeze = -# The block height to freeze the bip66 softfork for bip90, defaults to 363725. -bip66_freeze = -# The hash:height checkpoint for bip9 bit0 activation, defaults to 000000000000000004a1b34462cb8aeebd5799177f7a29cf28f2d1961716b5b5:419328. -bip9_bit0_active_checkpoint = -# The target block period, defaults to 600. -block_spacing_seconds = -# The blockchain checkpoints, defaults to the consensus set. -checkpoint = -# The genesis block, defaults to mainnet. -genesis_block = -# The initial block subsidy, defaults to 50. -initial_block_subsidy_bitcoin = -# A block presumed to be valid but not required to be present, defaults to 000000000000000000010538edbfd2d5b809a33dd83f284aeea41c6d0d96968a:900000. -milestone = -# The minimum work for any branch to be considered valid, defaults to 000000000000000000000000000000000000000052b2559353df4117b7348b64. -minimum_work = -# The proof of work limit, defaults to 486604799. -proof_of_work_limit = -# The difficulty retargeting factor, defaults to 4. -retargeting_factor = -# The difficulty retargeting period, defaults to 1209600. -retargeting_interval_seconds = -# The subsidy halving period, defaults to 210000. -subsidy_interval = -# The future timestamp allowance, defaults to 7200. -timestamp_limit_seconds = - -[database] -# The number of buckets in the address table head, defaults to '1' (0|1 disables). -address_buckets = -# The percentage expansion of the address table body, defaults to '5'. -address_rate = -# The minimum allocation of the address table body, defaults to '1'. -address_size = -# The percentage expansion of the candidate table body, defaults to '5'. -candidate_rate = -# The minimum allocation of the candidate table body, defaults to '2575500'. -candidate_size = -# The percentage expansion of the candidate table body, defaults to '5'. -confirmed_rate = -# The minimum allocation of the candidate table body, defaults to '2575500'. -confirmed_size = -# The minimum number of buckets in the duplicate table head, defaults to '1024'. -duplicate_buckets = -# The percentage expansion of the duplicate table, defaults to '5'. -duplicate_rate = -# The minimum allocation of the duplicate table body, defaults to '44'. -duplicate_size = -# The number of buckets in the filter_bk table head, defaults to '0' (0 disables). -filter_bk_buckets = -# The percentage expansion of the filter_bk table body, defaults to '5'. -filter_bk_rate = -# The minimum allocation of the filter_bk table body, defaults to '1'. -filter_bk_size = -# The number of buckets in the filter_tx table head, defaults to '0' (0 disables). -filter_tx_buckets = -# The percentage expansion of the filter_tx table body, defaults to '5'. -filter_tx_rate = -# The minimum allocation of the filter_tx table body, defaults to '1'. -filter_tx_size = -# The number of buckets in the header table head, defaults to '386364'. -header_buckets = -# The percentage expansion of the header table body, defaults to '5'. -header_rate = -# The minimum allocation of the header table body, defaults to '21000000'. -header_size = -# The percentage expansion of the input table body, defaults to '5'. -input_rate = -# The minimum allocation of the input table body, defaults to '92500000000'. -input_size = -# The percentage expansion of the ins table body, defaults to '5'. -ins_rate = -# The minimum allocation of the point table body, defaults to '8550000000'. -ins_size = -# The percentage expansion of the output table body, defaults to '5'. -output_rate = -# The minimum allocation of the output table body, defaults to '25300000000'. -output_size = -# The percentage expansion of the puts table body, defaults to '5'. -outs_rate = -# The minimum allocation of the puts table body, defaults to '3700000000'. -outs_size = -# The blockchain database directory, defaults to 'blockchain'. -path = -# The number of buckets in the spend table head, defaults to '1365977136'. -point_buckets = -# The percentage expansion of the point table body, defaults to '5'. -point_rate = -# The minimum allocation of the point table body, defaults to '25700000000'. -point_size = -# The minimum number of buckets in the prevout table head, defaults to '0'. -prevout_buckets = -# The percentage expansion of the prevout table, defaults to '5'. -prevout_rate = -# The minimum allocation of the prevout table body, defaults to '1'. -prevout_size = -# The number of buckets in the strong_tx table head, defaults to '469222525'. -strong_tx_buckets = -# The percentage expansion of the strong_tx table body, defaults to '5'. -strong_tx_rate = -# The minimum allocation of the strong_tx table body, defaults to '2900000000'. -strong_tx_size = -# The number of buckets in the tx table head, defaults to '469222525'. -tx_buckets = -# The percentage expansion of the tx table body, defaults to '5'. -tx_rate = -# The minimum allocation of the tx table body, defaults to '17000000000'. -tx_size = -# The number of buckets in the txs table head, defaults to '900001'. -txs_buckets = -# The percentage expansion of the txs table body, defaults to '5'. -txs_rate = -# The minimum allocation of the txs table body, defaults to '1050000000'. -txs_size = -# The number of buckets in the validated_bk table head, defaults to '900001'. -validated_bk_buckets = -# The percentage expansion of the validated_bk table body, defaults to '5'. -validated_bk_rate = -# The minimum allocation of the validated_bk table body, defaults to '1700000'. -validated_bk_size = -# The number of buckets in the validated_tx table head, defaults to '1'. -validated_tx_buckets = -# The percentage expansion of the validated_tx table body, defaults to '5'. -validated_tx_rate = -# The minimum allocation of the validated_tx table body, defaults to '1'. -validated_tx_size = - -[forks] -# Add check-sequence-verify op code, defaults to true (soft fork). -bip112 = -# Use median time past for locktime, defaults to true (soft fork). -bip113 = -# Segregated witness consensus layer, defaults to true (soft fork). -bip141 = -# Witness version 0 (segwit), defaults to true (soft fork). -bip143 = -# Prevent dummy value malleability, defaults to true (soft fork). -bip147 = -# Add pay-to-script-hash processing, defaults to true (soft fork). -bip16 = -# Disallow collision of unspent transaction hashes, defaults to true (soft fork). -bip30 = -# Require coinbase input includes block height, defaults to true (soft fork). -bip34 = -# Witness version 1 (taproot), defaults to true (soft fork). -bip341 = -# Validation of taproot script, defaults to true (soft fork). -bip342 = -# Finite monetary supply, defaults to true (soft fork). -bip42 = -# Add check-locktime-verify op code, defaults to true (soft fork). -bip65 = -# Require strict signature encoding, defaults to true (soft fork). -bip66 = -# Add relative locktime enforcement, defaults to true (soft fork). -bip68 = -# Assume bip34, bip65, and bip66 activation if enabled, defaults to true (hard fork). -bip90 = -# Require difficult blocks, defaults to true (use false for testnet). -difficult = -# Retarget difficulty, defaults to true. -retarget = -# Fix target overflow for very low difficulty, defaults to false (hard fork). -retarget_overflow_patch = -# Use scrypt hashing for proof of work, defaults to false (hard fork). -scrypt_proof_of_work = -# Fix time warp bug, defaults to false (hard fork). -time_warp_patch = - -[log] -# Enable application logging, defaults to true. -application = -# Enable local fault logging, defaults to true. -fault = -# The maximum byte size of each pair of rotated log files, defaults to 1000000. -maximum_size = -# Enable news logging, defaults to true. -news = -# The log files directory, defaults to empty. -path = -# Enable protocol logging, defaults to false. -protocol = -# Enable proxy logging, defaults to false. -proxy = -# Enable quitting logging, defaults to false. -quitting = -# Enable remote fault logging, defaults to true. -remote = -# Enable session logging, defaults to true. -session = -# Path to windows debug build symbols file (.pdb). -symbols = -# Enable verbose logging, defaults to false. -verbose = - -[network] -# The lower bound for address selection divisor, defaults to 5. -address_lower = -# The upper bound for address selection divisor, defaults to 10. -address_upper = -# IP address to bind, multiple entries allowed, defaults to 0.0.0.0:8333. -bind = -# IP address to disallow as a peer, multiple entries allowed. -blacklist = -# The age limit for any connection, defaults to 1440. -channel_expiration_minutes = -# The time between ping messages, defaults to 5. -channel_heartbeat_minutes = -# The inactivity time limit for any connection, defaults to 10. -channel_inactivity_minutes = -# The number of concurrent attempts to establish one connection, defaults to 5. -connect_batch_size = -# The time limit for connection establishment, defaults to 5. -connect_timeout_seconds = -# Enable address messages, defaults to true. -enable_address = -# Enable address v2 messages, defaults to false. -enable_address_v2 = -# Enable alert messages, defaults to false. -enable_alert = -# Enable enable compact block messages, defaults to false. -enable_compact = -# Enable internet protocol version 6 (IPv6), defaults to false. -enable_ipv6 = -# Allow connections from the node to itself, defaults to false. -enable_loopback = -# Enable reject messages, defaults to false. -enable_reject = -# Enable transaction relay, defaults to true. -enable_relay = -# Enable witness transaction identifier relay, defaults to false. -enable_witness_tx = -# The time limit to complete the connection handshake, defaults to 30. -handshake_timeout_seconds = -# The maximum number of peer hosts in the pool, defaults to 10000. -host_pool_capacity = -# The magic number for message headers, defaults to 3652501241. -identifier = -# The target number of incoming network connections, defaults to 100. -inbound_connections = -# The advertised services that cause a peer to be dropped, defaults to 176. -invalid_services = -# The maximum allowable channel clock skew, defaults to 120. -maximum_skew_minutes = -# The minimum retained read buffer size, defaults to 4000000. -minimum_buffer = -# The target number of outgoing network connections, defaults to 100. -outbound_connections = -# The peer address cache file directory, defaults to empty. -path = -# A persistent peer node, multiple entries allowed. -peer = -# The maximum network protocol version, defaults to 70012. -protocol_maximum = -# The minimum network protocol version, defaults to 31800. -protocol_minimum = -# The per channel send rate limit in bytes per second, defaults to 0 (unlimited). -rate_limit = -# The time delay for failed connection retry, defaults to 1. -retry_timeout_seconds = -# A seed node for initializing the host pool, multiple entries allowed. -seed = -# The time limit for obtaining seed addresses, defaults to 30. -seeding_timeout_seconds = -# IP address to advertise, multiple entries allowed. -self = -# The maximum services exposed by network connections, defaults to 9 (full node, witness). -services_maximum = -# The minimum services exposed by network connections, defaults to 9 (full node, witness). -services_minimum = -# The minimum number of threads in the network threadpool, defaults to 16. -threads = -# The node user agent string, defaults to '/libbitcoin:4.0.0/'. -user_agent = -# Validate the checksum of network messages, defaults to false. -validate_checksum = -# IP address to allow as a peer, multiple entries allowed. -whitelist = - -[node] -# Block deserialization buffer multiple of wire size, defaults to 20 (0 disables). -allocation_multiple = -# Allowable underperformance standard deviation, defaults to 1.5 (0 disables). -allowed_deviation = -# Limit of per channel cached peer block and tx announcements, to avoid replaying (defaults to 42). -announcement_cache = -# Time from present that blocks are considered current, defaults to 60 (0 disables). -currency_window_minutes = -# Delay accepting inbound connections until node is current, defaults to true. -delay_inbound = -# Maximum number of blocks to download concurrently, defaults to '50000' (0 disables). -maximum_concurrency = -# Maximum block height to populate, defaults to 0 (unlimited). -maximum_height = -# Set the validation threadpool to high priority, defaults to true. -priority = -# Sampling period for drop of stalled channels, defaults to 10 (0 disables). -sample_period_seconds = -# The number of threads in the validation threadpool, defaults to 32. -threads = - -[server] -# IP address to bind, multiple entries allowed, defaults to 0.0.0.0:8080. -bind = -# The target number of incoming network connections, defaults to 0. -inbound_connections = \ No newline at end of file diff --git a/include/bitcoin/node/channels/channel_peer.hpp b/include/bitcoin/node/channels/channel_peer.hpp index fde66df6..5fca5050 100644 --- a/include/bitcoin/node/channels/channel_peer.hpp +++ b/include/bitcoin/node/channels/channel_peer.hpp @@ -41,6 +41,7 @@ class BCN_API channel_peer const node::configuration& config, const options_t& options) NOEXCEPT : node::channel(log, socket, identifier, config), network::channel_peer(log, socket, identifier, config.network, options), + witness_(config.node.require_witness), announced_(config.node.announcement_cache), network::tracker(log) { @@ -49,7 +50,20 @@ class BCN_API channel_peer void set_announced(const system::hash_digest& hash) NOEXCEPT; bool was_announced(const system::hash_digest& hash) const NOEXCEPT; +protected: + /// Stamp witness parse context on the frame. + inline network::messages::peer::frame_ptr create_frame() + const NOEXCEPT override + { + const auto in = network::channel_peer::create_frame(); + in->witness = witness_; + return in; + } + private: + // This is thread safe (const). + const bool witness_; + // This is protected by strand. // boost::circular_buffer is included by network. boost::circular_buffer announced_; diff --git a/include/bitcoin/node/impl/sessions/session_peer.ipp b/include/bitcoin/node/impl/sessions/session_peer.ipp index b26035f0..fde9fa10 100644 --- a/include/bitcoin/node/impl/sessions/session_peer.ipp +++ b/include/bitcoin/node/impl/sessions/session_peer.ipp @@ -25,6 +25,13 @@ namespace node { // this-> is required for dependent base access in CRTP. +TEMPLATE +inline uint64_t CLASS::services_provided() const NOEXCEPT +{ + return system::bit_or(NetworkSession::services_provided(), + this->node_settings().services_provided()); +} + TEMPLATE inline CLASS::channel_ptr CLASS::create_channel( const socket_ptr& socket) NOEXCEPT @@ -69,16 +76,8 @@ inline void CLASS::attach_protocols(const channel_ptr& channel) NOEXCEPT const auto relay = this->network_settings().enable_relay; const auto delay = this->node_settings().delay_inbound; const auto headers = this->node_settings().headers_first; - const auto node_network = to_bool(bit_and - ( - this->network_settings().services_maximum, - service::node_network - )); - const auto node_client_filters = to_bool(bit_and - ( - this->network_settings().services_maximum, - service::node_client_filters - )); + const auto node_network = this->node_settings().provide_blocks; + const auto node_client_filters = this->node_settings().provide_filters; // Attach appropriate alert, reject, ping, and/or address protocols. NetworkSession::attach_protocols(channel); diff --git a/include/bitcoin/node/protocols/protocol_block_in_106.hpp b/include/bitcoin/node/protocols/protocol_block_in_106.hpp index 80eb39c1..2656e525 100644 --- a/include/bitcoin/node/protocols/protocol_block_in_106.hpp +++ b/include/bitcoin/node/protocols/protocol_block_in_106.hpp @@ -36,7 +36,7 @@ class BCN_API protocol_block_in_106 protocol_block_in_106(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol_peer(session, channel), - block_type_(session->network_settings().witness_node() ? + block_type_(session->node_settings().require_witness ? type_id::witness_block : type_id::block), network::tracker(session->log) { diff --git a/include/bitcoin/node/protocols/protocol_block_in_31800.hpp b/include/bitcoin/node/protocols/protocol_block_in_31800.hpp index e8e05e18..4f1358be 100644 --- a/include/bitcoin/node/protocols/protocol_block_in_31800.hpp +++ b/include/bitcoin/node/protocols/protocol_block_in_31800.hpp @@ -39,9 +39,9 @@ class BCN_API protocol_block_in_31800 : protocol_performer(session, channel, performance_enabled), top_checkpoint_height_( session->system_settings().top_checkpoint().height()), - block_type_(session->network_settings().witness_node() ? + block_type_(session->node_settings().require_witness ? type_id::witness_block : type_id::block), - node_pruned_(session->network_settings().pruned_node()), + node_pruned_(session->node_settings().limited_blocks), map_(chaser_check::empty_map()), network::tracker(session->log) { diff --git a/include/bitcoin/node/protocols/protocol_block_out_106.hpp b/include/bitcoin/node/protocols/protocol_block_out_106.hpp index 10d50eed..7c254ce7 100644 --- a/include/bitcoin/node/protocols/protocol_block_out_106.hpp +++ b/include/bitcoin/node/protocols/protocol_block_out_106.hpp @@ -38,8 +38,8 @@ class BCN_API protocol_block_out_106 : node::protocol_peer(session, channel), top_checkpoint_height_( session->system_settings().top_checkpoint().height()), - node_pruned_(session->network_settings().pruned_node()), - node_witness_(session->network_settings().witness_node()), + node_pruned_(session->node_settings().limited_blocks), + node_witness_(session->node_settings().provide_witness), allow_overlapped_(session->node_settings().allow_overlapped), network::tracker(session->log) { diff --git a/include/bitcoin/node/protocols/protocol_observer.hpp b/include/bitcoin/node/protocols/protocol_observer.hpp index 95b5874a..90a57798 100644 --- a/include/bitcoin/node/protocols/protocol_observer.hpp +++ b/include/bitcoin/node/protocols/protocol_observer.hpp @@ -45,7 +45,7 @@ class BCN_API protocol_observer is_negotiated(network::messages::peer::level::bip37) && !session->network_settings().enable_relay ), - node_witness_(session->network_settings().witness_node()), + node_witness_(session->node_settings().require_witness), network::tracker(session->log) { } diff --git a/include/bitcoin/node/protocols/protocol_transaction_in_106.hpp b/include/bitcoin/node/protocols/protocol_transaction_in_106.hpp index 404f896a..2ca8724f 100644 --- a/include/bitcoin/node/protocols/protocol_transaction_in_106.hpp +++ b/include/bitcoin/node/protocols/protocol_transaction_in_106.hpp @@ -35,7 +35,7 @@ class BCN_API protocol_transaction_in_106 protocol_transaction_in_106(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol_peer(session, channel), - ////tx_type_(session->network_settings().witness_node() ? + ////tx_type_(session->node_settings().require_witness ? //// type_id::witness_tx : type_id::transaction), network::tracker(session->log) { diff --git a/include/bitcoin/node/protocols/protocol_transaction_out_106.hpp b/include/bitcoin/node/protocols/protocol_transaction_out_106.hpp index ee254a30..23aa4c44 100644 --- a/include/bitcoin/node/protocols/protocol_transaction_out_106.hpp +++ b/include/bitcoin/node/protocols/protocol_transaction_out_106.hpp @@ -35,7 +35,7 @@ class BCN_API protocol_transaction_out_106 protocol_transaction_out_106(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol_peer(session, channel), - node_witness_(session->network_settings().witness_node()), + node_witness_(session->node_settings().provide_witness), network::tracker(session->log) { } diff --git a/include/bitcoin/node/sessions/session_manual.hpp b/include/bitcoin/node/sessions/session_manual.hpp index 2c8a0289..b755e00a 100644 --- a/include/bitcoin/node/sessions/session_manual.hpp +++ b/include/bitcoin/node/sessions/session_manual.hpp @@ -32,6 +32,14 @@ class BCN_API session_manual typedef std::shared_ptr ptr; using base = session_peer; using base::base; + +protected: + /// Manual connections require the configured node services. + uint64_t services_required() const NOEXCEPT override + { + return system::bit_or(base::services_required(), + node_settings().services_required()); + } }; } // namespace node diff --git a/include/bitcoin/node/sessions/session_outbound.hpp b/include/bitcoin/node/sessions/session_outbound.hpp index 8048c9a6..796dc601 100644 --- a/include/bitcoin/node/sessions/session_outbound.hpp +++ b/include/bitcoin/node/sessions/session_outbound.hpp @@ -32,6 +32,14 @@ class BCN_API session_outbound typedef std::shared_ptr ptr; using base = session_peer; using base::base; + +protected: + /// Outbound connections require the configured node services. + uint64_t services_required() const NOEXCEPT override + { + return system::bit_or(base::services_required(), + node_settings().services_required()); + } }; } // namespace node diff --git a/include/bitcoin/node/sessions/session_peer.hpp b/include/bitcoin/node/sessions/session_peer.hpp index 8000a3e2..79e667e3 100644 --- a/include/bitcoin/node/sessions/session_peer.hpp +++ b/include/bitcoin/node/sessions/session_peer.hpp @@ -54,6 +54,7 @@ class session_peer using socket_ptr = network::socket::ptr; using channel_ptr = network::channel::ptr; + inline uint64_t services_provided() const NOEXCEPT override; inline channel_ptr create_channel( const socket_ptr& socket) NOEXCEPT override; inline void attach_handshake(const channel_ptr& channel, diff --git a/include/bitcoin/node/settings.hpp b/include/bitcoin/node/settings.hpp index f651967a..5da26060 100644 --- a/include/bitcoin/node/settings.hpp +++ b/include/bitcoin/node/settings.hpp @@ -40,6 +40,12 @@ class BCN_API settings bool thread_priority; bool memory_priority; bool allow_overlapped; + bool provide_blocks; + bool require_blocks; + bool provide_witness; + bool require_witness; + bool provide_filters; + bool limited_blocks; float allowed_deviation; float minimum_fee_rate; float minimum_bump_rate; @@ -62,6 +68,8 @@ class BCN_API settings virtual size_t maximum_height_() const NOEXCEPT; virtual size_t maximum_concurrency_() const NOEXCEPT; virtual size_t fee_estimate_horizon_() const NOEXCEPT; + virtual uint64_t services_provided() const NOEXCEPT; + virtual uint64_t services_required() const NOEXCEPT; virtual bool fee_estimate_enabled() const NOEXCEPT; virtual bool batch_signatures_enabled() const NOEXCEPT; virtual network::steady_clock::duration sample_period() const NOEXCEPT; diff --git a/src/chasers/chaser_block.cpp b/src/chasers/chaser_block.cpp index 0ad9386a..2e27a249 100644 --- a/src/chasers/chaser_block.cpp +++ b/src/chasers/chaser_block.cpp @@ -31,7 +31,7 @@ using namespace system::chain; chaser_block::chaser_block(full_node& node) NOEXCEPT : chaser_organize(node), - node_witness_(node.network_settings().witness_node()) + node_witness_(node.node_settings().require_witness) { } diff --git a/src/chasers/chaser_validate.cpp b/src/chasers/chaser_validate.cpp index 5d15c72c..2fdfcf3e 100644 --- a/src/chasers/chaser_validate.cpp +++ b/src/chasers/chaser_validate.cpp @@ -46,7 +46,7 @@ chaser_validate::chaser_validate(full_node& node) NOEXCEPT maximum_height_(node.node_settings().maximum_height_()), batch_target_(node.node_settings().batch_signatures), batch_enabled_(node.node_settings().batch_signatures_enabled()), - node_witness_(node.network_settings().witness_node()), + node_witness_(node.node_settings().require_witness), filter_(node.archive().filter_enabled()) { } diff --git a/src/full_node.cpp b/src/full_node.cpp index 7fb69ce1..872c10b3 100644 --- a/src/full_node.cpp +++ b/src/full_node.cpp @@ -37,7 +37,7 @@ BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) // net::strand() is safe to call from constructor (non-virtual). full_node::full_node(query& query, const configuration& configuration, const logger& log) NOEXCEPT - : net(configuration.network, log), + : net(configuration.network, log, configuration.node.services_required()), config_(configuration), start_time_(zulu_time()), query_(query), diff --git a/src/settings.cpp b/src/settings.cpp index b04557d5..93fa2fc0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -36,6 +36,12 @@ settings::settings() NOEXCEPT memory_priority{ true }, thread_priority{ true }, allow_overlapped{ true }, + provide_blocks{ true }, + require_blocks{ true }, + provide_witness{ true }, + require_witness{ true }, + provide_filters{ false }, + limited_blocks{ false }, batch_signatures{ 0 }, minimum_fee_rate{ 0.0 }, minimum_bump_rate{ 0.0 }, @@ -81,6 +87,38 @@ size_t settings::fee_estimate_horizon_() const NOEXCEPT return std::min(fee_estimate_horizon, estimator::maximum_horizon); } +uint64_t settings::services_provided() const NOEXCEPT +{ + using namespace network::messages::peer; + uint64_t services{ service::node_none }; + + if (provide_blocks) + services = bit_or(services, limited_blocks ? + service::node_network_limited : service::node_network); + + if (provide_witness) + services = bit_or(services, service::node_witness); + + if (provide_filters) + services = bit_or(services, service::node_client_filters); + + return services; +} + +uint64_t settings::services_required() const NOEXCEPT +{ + using namespace network::messages::peer; + uint64_t services{ service::node_none }; + + if (require_blocks) + services = bit_or(services, service::node_network); + + if (require_witness) + services = bit_or(services, service::node_witness); + + return services; +} + bool settings::fee_estimate_enabled() const NOEXCEPT { return to_bool(fee_estimate_horizon_()); diff --git a/test/settings.cpp b/test/settings.cpp index d678e7c8..af296bc1 100644 --- a/test/settings.cpp +++ b/test/settings.cpp @@ -36,6 +36,12 @@ BOOST_AUTO_TEST_CASE(settings__node__default_context__expected) BOOST_REQUIRE_EQUAL(node.memory_priority, true); BOOST_REQUIRE_EQUAL(node.thread_priority, true); BOOST_REQUIRE_EQUAL(node.allow_overlapped, true); + BOOST_REQUIRE_EQUAL(node.provide_blocks, true); + BOOST_REQUIRE_EQUAL(node.require_blocks, true); + BOOST_REQUIRE_EQUAL(node.provide_witness, true); + BOOST_REQUIRE_EQUAL(node.require_witness, true); + BOOST_REQUIRE_EQUAL(node.provide_filters, false); + BOOST_REQUIRE_EQUAL(node.limited_blocks, false); BOOST_REQUIRE_EQUAL(node.minimum_fee_rate, 0.0); BOOST_REQUIRE_EQUAL(node.minimum_bump_rate, 0.0); BOOST_REQUIRE_EQUAL(node.allowed_deviation, 1.5);