Skip to content

Commit 00d48e4

Browse files
committed
Merge pull request #97 from evoskuil/master
Derive settings from node, use const, change listener setting.
2 parents 794d224 + bfc7c0b commit 00d48e4

23 files changed

+197
-475
lines changed

Makefile.am

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ src_libbitcoin_server_la_SOURCES = \
4242
src/subscribe_manager.cpp \
4343
src/worker.cpp \
4444
src/config/config.cpp \
45-
src/config/endpoint.cpp \
4645
src/config/settings.cpp \
4746
src/service/blockchain.cpp \
4847
src/service/compat.cpp \
@@ -60,7 +59,6 @@ check_PROGRAMS = test/libbitcoin_server_test
6059
test_libbitcoin_server_test_CPPFLAGS = -I${srcdir}/include ${bitcoin_node_CPPFLAGS} ${sodium_CPPFLAGS} ${czmq___CPPFLAGS}
6160
test_libbitcoin_server_test_LDADD = src/libbitcoin-server.la ${boost_unit_test_framework_LIBS} ${bitcoin_node_LIBS} ${sodium_LIBS} ${czmq___LIBS}
6261
test_libbitcoin_server_test_SOURCES = \
63-
test/endpoint.cpp \
6462
test/main.cpp \
6563
test/server.cpp \
6664
test/stress.sh
@@ -99,7 +97,6 @@ include_bitcoin_server_HEADERS = \
9997
include_bitcoin_server_configdir = ${includedir}/bitcoin/server/config
10098
include_bitcoin_server_config_HEADERS = \
10199
include/bitcoin/server/config/config.hpp \
102-
include/bitcoin/server/config/endpoint.hpp \
103100
include/bitcoin/server/config/settings.hpp
104101

105102
include_bitcoin_server_servicedir = ${includedir}/bitcoin/server/service

builds/msvc/vs2013/libbitcoin-server-test/libbitcoin-server-test.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
</ProjectReference>
111111
</ItemGroup>
112112
<ItemGroup>
113-
<ClCompile Include="..\..\..\..\test\endpoint.cpp" />
114113
<ClCompile Include="..\..\..\..\test\main.cpp" />
115114
<ClCompile Include="..\..\..\..\test\server.cpp" />
116115
</ItemGroup>

builds/msvc/vs2013/libbitcoin-server-test/libbitcoin-server-test.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,5 @@
1515
<ClCompile Include="..\..\..\..\test\main.cpp">
1616
<Filter>src</Filter>
1717
</ClCompile>
18-
<ClCompile Include="..\..\..\..\test\endpoint.cpp">
19-
<Filter>src</Filter>
20-
</ClCompile>
2118
</ItemGroup>
2219
</Project>

builds/msvc/vs2013/libbitcoin-server/libbitcoin-server.vcxproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
</ItemGroup>
7373
<ItemGroup>
7474
<ClInclude Include="..\..\..\..\include\bitcoin\server\config\config.hpp" />
75-
<ClInclude Include="..\..\..\..\include\bitcoin\server\config\endpoint.hpp" />
7675
<ClInclude Include="..\..\..\..\include\bitcoin\server\config\settings.hpp" />
7776
<ClInclude Include="..\..\..\..\include\bitcoin\server\define.hpp" />
7877
<ClInclude Include="..\..\..\..\include\bitcoin\server\message.hpp" />
@@ -92,7 +91,6 @@
9291
</ItemGroup>
9392
<ItemGroup>
9493
<ClCompile Include="..\..\..\..\src\config\config.cpp" />
95-
<ClCompile Include="..\..\..\..\src\config\endpoint.cpp" />
9694
<ClCompile Include="..\..\..\..\src\config\settings.cpp" />
9795
<ClCompile Include="..\..\..\..\src\message.cpp" />
9896
<ClCompile Include="..\..\..\..\src\server_node.cpp" />

builds/msvc/vs2013/libbitcoin-server/libbitcoin-server.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@
7373
<ClInclude Include="..\..\..\..\include\bitcoin\server\server_node.hpp">
7474
<Filter>include\bitcoin\server</Filter>
7575
</ClInclude>
76-
<ClInclude Include="..\..\..\..\include\bitcoin\server\config\endpoint.hpp">
77-
<Filter>include\bitcoin\server\config</Filter>
78-
</ClInclude>
7976
<ClInclude Include="..\..\..\..\include\bitcoin\server\config\settings.hpp">
8077
<Filter>include\bitcoin\server\config</Filter>
8178
</ClInclude>
@@ -117,9 +114,6 @@
117114
<ClCompile Include="..\..\..\..\src\server_node.cpp">
118115
<Filter>src</Filter>
119116
</ClCompile>
120-
<ClCompile Include="..\..\..\..\src\config\endpoint.cpp">
121-
<Filter>src\config</Filter>
122-
</ClCompile>
123117
<ClCompile Include="..\..\..\..\src\config\settings.cpp">
124118
<Filter>src\config</Filter>
125119
</ClCompile>

data/bs.cfg

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,48 @@
11
# Libbitcoin Server configuration file.
22

3-
[general]
4-
# The blockchain directory, defaults to 'blockchain'.
5-
blockchain_path = blockchain
3+
[node]
4+
# The number of threads in the database threadpool, defaults to 6.
5+
database_threads = 6
6+
# The number of threads in the network threadpool, defaults to 4.
7+
network_threads = 4
8+
# The number of threads in the memory threadpool, defaults to 4.
9+
memory_threads = 4
10+
# The maximum number of peer hosts in the pool, defaults to 1000.
11+
host_pool_capacity = 1000
12+
# The maximum number of orphan blocks in the pool, defaults to 50.
13+
block_pool_capacity = 50
14+
# The maximum number of transactions in the pool, defaults to 2000.
15+
tx_pool_capacity = 2000
616
# The minimum height of the history database, defaults to 0.
717
history_height = 0
8-
# The peer cache file path, defaults to 'hosts'.
9-
hosts_file = hosts
10-
# Enable the listening for incoming connections, defaults to true.
11-
listener_enabled = true
18+
# The height of the checkpoint hash, defaults to 0.
19+
checkpoint_height = 0
20+
# The checkpoint hash, defaults to a null hash (no checkpoint).
21+
checkpoint_hash = 0000000000000000000000000000000000000000000000000000000000000000
22+
# The port for incoming connections, set to 0 to disable listener, defaults to 8333 (18333 for testnet).
23+
# listen_port = 0
1224
# The maximum number of outgoing P2P network connections, defaults to 8.
13-
out_connections = 8
14-
# Enable the publisher, defaults to false.
15-
publisher_enabled = false
16-
# The maximum number of transactions in the pool, defaults to 2000.
17-
tx_pool_capacity = 2000
18-
19-
[logging]
20-
# The debug log file path, defaults to 'debug.log'.
21-
debug_file = debug.log
22-
# The error log file path, defaults to 'error.log'.
23-
error_file = error.log
24-
# Write service requests to the log, impacts performance, defaults to false.
25-
log_requests = false
25+
outbound_connections = 8
26+
# The peer cache file path, defaults to 'peers'.
27+
hosts_file = peers
28+
# The blockchain directory, defaults to 'blockchain'.
29+
blockchain_path = blockchain
2630

27-
[endpoints]
31+
[server]
2832
# The query service endpoint, defaults to 'tcp://*:9091'.
29-
service = tcp://*:9091
30-
# The heartbeat endpoint, defaults to 'tcp://*:9092'.
31-
heartbeat = tcp://*:9092
33+
query_endpoint = tcp://*:9091
34+
# The heartbeat service endpoint, defaults to 'tcp://*:9092'.
35+
heartbeat_endpoint = tcp://*:9092
3236
# The block publishing service endpoint, defaults to 'tcp://*:9093'.
33-
block_publish = tcp://*:9093
37+
block_publish_endpoint = tcp://*:9093
3438
# The transaction publishing service endpoint, defaults to 'tcp://*:9094'.
35-
tx_publish = tcp://*:9094
39+
tx_publish_endpoint = tcp://*:9094
40+
# Enable the publisher, defaults to false.
41+
publisher_enabled = false
3642

3743
[identity]
44+
# The server name, must be unique if specified.
45+
# unique_name =
3846
# The path to the ZPL-encoded server private certificate file.
3947
# cert_file =
4048
# The directory for ZPL-encoded client public certificate files, allows anonymous clients if not set.
@@ -45,5 +53,11 @@ tx_publish = tcp://*:9094
4553
# Node to augment peer discovery, formatted as host:port, multiple entries allowed.
4654
# peer = obelisk.airbitz.co:8333
4755
# peer =
48-
# The server name, must be unique if specified.
49-
# unique_name =
56+
57+
[logging]
58+
# The debug log file path, defaults to 'debug.log'.
59+
debug_file = debug.log
60+
# The error log file path, defaults to 'error.log'.
61+
error_file = error.log
62+
# Write service requests to the log, impacts performance, defaults to false.
63+
log_requests = false

include/bitcoin/server.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include <bitcoin/server/version.hpp>
2525
#include <bitcoin/server/worker.hpp>
2626
#include <bitcoin/server/config/config.hpp>
27-
#include <bitcoin/server/config/endpoint.hpp>
2827
#include <bitcoin/server/config/settings.hpp>
2928
#include <bitcoin/server/service/blockchain.hpp>
3029
#include <bitcoin/server/service/compat.hpp>

include/bitcoin/server/config/config.hpp

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,43 @@
2525
#include <vector>
2626
#include <boost/filesystem.hpp>
2727
#include <boost/program_options.hpp>
28+
#include <bitcoin/server/config/settings.hpp>
2829
#include <bitcoin/server/define.hpp>
2930

3031
namespace libbitcoin {
3132
namespace server {
3233

34+
// Log names.
3335
#define LOG_WORKER "worker"
3436
#define LOG_REQUEST "request"
3537

36-
class config_type;
38+
// Not localizable.
39+
#define BS_HELP_VARIABLE "help"
40+
#define BS_SETTINGS_VARIABLE "settings"
41+
#define BS_VERSION_VARIABLE "version"
42+
43+
// This must be lower case but the env var part can be any case.
44+
#define BS_CONFIG_VARIABLE "config"
45+
46+
// This must match the case of the env var.
47+
#define BS_ENVIRONMENT_VARIABLE_PREFIX "BS_"
48+
49+
class settings_type;
50+
51+
class BCS_API config_type
52+
{
53+
public:
54+
const boost::program_options::options_description load_settings();
55+
const boost::program_options::options_description load_environment();
56+
const boost::program_options::options_description load_options();
57+
const boost::program_options::positional_options_description
58+
load_arguments();
59+
60+
settings_type settings;
61+
};
3762

3863
/**
39-
* Lod configurable vlaues from environment variables, settings file, and
64+
* Load configurable values from environment variables, settings file, and
4065
* command line positional and non-positional options.
4166
*/
4267
bool BCS_API load_config(config_type& metadata, std::string& message, int argc,

include/bitcoin/server/config/endpoint.hpp

Lines changed: 0 additions & 60 deletions
This file was deleted.

include/bitcoin/server/config/settings.hpp

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,17 @@
2525
#include <vector>
2626
#include <boost/filesystem.hpp>
2727
#include <boost/program_options.hpp>
28-
#include <bitcoin/server/config/endpoint.hpp>
28+
#include <bitcoin/node.hpp>
2929
#include <bitcoin/server/define.hpp>
3030

31-
// Not localizable.
32-
#define BS_HELP_VARIABLE "help"
33-
#define BS_SETTINGS_VARIABLE "settings"
34-
#define BS_VERSION_VARIABLE "version"
35-
36-
// This must be lower case but the env var part can be any case.
37-
#define BS_CONFIG_VARIABLE "config"
38-
39-
// This must match the case of the env var.
40-
#define BS_ENVIRONMENT_VARIABLE_PREFIX "BS_"
41-
4231
namespace libbitcoin {
4332
namespace server {
4433

45-
struct BCS_API settings_type
34+
class BCS_API settings_type
35+
: public node::settings
4636
{
37+
public:
38+
4739
// options
4840
bool help;
4941
bool initchain;
@@ -55,36 +47,18 @@ struct BCS_API settings_type
5547

5648
// settings
5749
bool log_requests;
58-
bool listener_enabled;
5950
bool publisher_enabled;
60-
uint32_t tx_pool_capacity;
61-
uint32_t out_connections;
62-
uint32_t history_height;
63-
endpoint_type unique_name;
64-
endpoint_type service;
65-
endpoint_type heartbeat;
66-
endpoint_type tx_publish;
67-
endpoint_type block_publish;
68-
boost::filesystem::path hosts_file;
51+
node::endpoint_type unique_name;
52+
node::endpoint_type query_endpoint;
53+
node::endpoint_type heartbeat_endpoint;
54+
node::endpoint_type tx_publish_endpoint;
55+
node::endpoint_type block_publish_endpoint;
6956
boost::filesystem::path debug_file;
7057
boost::filesystem::path error_file;
7158
boost::filesystem::path cert_file;
7259
boost::filesystem::path client_certs_path;
73-
boost::filesystem::path blockchain_path;
74-
std::vector<endpoint_type> clients;
75-
std::vector<endpoint_type> peers;
76-
};
77-
78-
class BCS_API config_type
79-
{
80-
public:
81-
const boost::program_options::options_description load_settings();
82-
const boost::program_options::options_description load_environment();
83-
const boost::program_options::options_description load_options();
84-
const boost::program_options::positional_options_description
85-
load_arguments();
86-
87-
settings_type settings;
60+
std::vector<node::endpoint_type> clients;
61+
std::vector<node::endpoint_type> peers;
8862
};
8963

9064
} // namespace server

0 commit comments

Comments
 (0)