Skip to content

Commit 1ae6ca2

Browse files
committed
Merge pull request #62 from evoskuil/master
Use bc stdio and fstream i/o wrappers, missing nuget deps.
2 parents 3f1fd45 + 7489c6d commit 1ae6ca2

File tree

12 files changed

+46
-29
lines changed

12 files changed

+46
-29
lines changed

builds/msvc/vs2013/bitcoin-server/bitcoin-server.props

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
<DisableSpecificWarnings>4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
1616
<EnablePREfast>false</EnablePREfast>
1717
<PreprocessorDefinitions>_WIN32_WINNT=0x0600;%(PreprocessorDefinitions)</PreprocessorDefinitions>
18-
<PreprocessorDefinitions Condition="'$(DebugOrRelease)' == 'Release'">BITCOIN_DISABLE_ASSERTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
1918
</ClCompile>
19+
<Link Condition="$(Configuration.IndexOf('Debug')) != -1">
20+
<AdditionalOptions>/OPT:NOLBR /IGNORE:4099 %(AdditionalOptions)</AdditionalOptions>
21+
</Link>
2022
</ItemDefinitionGroup>
2123

2224
<!-- Dependencies -->

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
<Import Project="..\..\..\..\..\..\nuget\boost.1.56.0.0\build\native\boost.targets" Condition="Exists('..\..\..\..\..\..\nuget\boost.1.56.0.0\build\native\boost.targets')" />
117117
<Import Project="..\..\..\..\..\..\nuget\boost_date_time-vc120.1.56.0.0\build\native\boost_date_time-vc120.targets" Condition="Exists('..\..\..\..\..\..\nuget\boost_date_time-vc120.1.56.0.0\build\native\boost_date_time-vc120.targets')" />
118118
<Import Project="..\..\..\..\..\..\nuget\boost_filesystem-vc120.1.56.0.0\build\native\boost_filesystem-vc120.targets" Condition="Exists('..\..\..\..\..\..\nuget\boost_filesystem-vc120.1.56.0.0\build\native\boost_filesystem-vc120.targets')" />
119+
<Import Project="..\..\..\..\..\..\nuget\boost_locale-vc120.1.56.0.0\build\native\boost_locale-vc120.targets" Condition="Exists('..\..\..\..\..\..\nuget\boost_locale-vc120.1.56.0.0\build\native\boost_locale-vc120.targets')" />
119120
<Import Project="..\..\..\..\..\..\nuget\boost_program_options-vc120.1.56.0.0\build\native\boost_program_options-vc120.targets" Condition="Exists('..\..\..\..\..\..\nuget\boost_program_options-vc120.1.56.0.0\build\native\boost_program_options-vc120.targets')" />
120121
<Import Project="..\..\..\..\..\..\nuget\boost_regex-vc120.1.56.0.0\build\native\boost_regex-vc120.targets" Condition="Exists('..\..\..\..\..\..\nuget\boost_regex-vc120.1.56.0.0\build\native\boost_regex-vc120.targets')" />
121122
<Import Project="..\..\..\..\..\..\nuget\boost_system-vc120.1.56.0.0\build\native\boost_system-vc120.targets" Condition="Exists('..\..\..\..\..\..\nuget\boost_system-vc120.1.56.0.0\build\native\boost_system-vc120.targets')" />
@@ -133,6 +134,7 @@
133134
<Error Condition="!Exists('..\..\..\..\..\..\nuget\boost.1.56.0.0\build\native\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\nuget\boost.1.56.0.0\build\native\boost.targets'))" />
134135
<Error Condition="!Exists('..\..\..\..\..\..\nuget\boost_date_time-vc120.1.56.0.0\build\native\boost_date_time-vc120.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\nuget\boost_date_time-vc120.1.56.0.0\build\native\boost_date_time-vc120.targets'))" />
135136
<Error Condition="!Exists('..\..\..\..\..\..\nuget\boost_filesystem-vc120.1.56.0.0\build\native\boost_filesystem-vc120.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\nuget\boost_filesystem-vc120.1.56.0.0\build\native\boost_filesystem-vc120.targets'))" />
137+
<Error Condition="!Exists('..\..\..\..\..\..\nuget\boost_locale-vc120.1.56.0.0\build\native\boost_locale-vc120.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\nuget\boost_locale-vc120.1.56.0.0\build\native\boost_locale-vc120.targets'))" />
136138
<Error Condition="!Exists('..\..\..\..\..\..\nuget\boost_program_options-vc120.1.56.0.0\build\native\boost_program_options-vc120.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\nuget\boost_program_options-vc120.1.56.0.0\build\native\boost_program_options-vc120.targets'))" />
137139
<Error Condition="!Exists('..\..\..\..\..\..\nuget\boost_regex-vc120.1.56.0.0\build\native\boost_regex-vc120.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\nuget\boost_regex-vc120.1.56.0.0\build\native\boost_regex-vc120.targets'))" />
138140
<Error Condition="!Exists('..\..\..\..\..\..\nuget\boost_system-vc120.1.56.0.0\build\native\boost_system-vc120.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\..\nuget\boost_system-vc120.1.56.0.0\build\native\boost_system-vc120.targets'))" />

builds/msvc/vs2013/bitcoin-server/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<package id="boost" version="1.56.0.0" targetFramework="Native" />
44
<package id="boost_date_time-vc120" version="1.56.0.0" targetFramework="Native" />
55
<package id="boost_filesystem-vc120" version="1.56.0.0" targetFramework="Native" />
6+
<package id="boost_locale-vc120" version="1.56.0.0" targetFramework="Native" />
67
<package id="boost_program_options-vc120" version="1.56.0.0" targetFramework="Native" />
78
<package id="boost_regex-vc120" version="1.56.0.0" targetFramework="Native" />
89
<package id="boost_system-vc120" version="1.56.0.0" targetFramework="Native" />

builds/msvc/vs2013/libbitcoin-blockchain.import.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
<ItemDefinitionGroup>
1717
<ClCompile>
1818
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\libbitcoin-blockchain\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
19-
<PreprocessorDefinitions Condition="$(Configuration.IndexOf('Release')) != -1">BITCOIN_DISABLE_ASSERTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
2019
<PreprocessorDefinitions Condition="'$(Linkage-libbitcoin-blockchain)' == 'static' Or '$(Linkage-libbitcoin-blockchain)' == 'ltcg'">BCB_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
2120
</ClCompile>
2221
<Link>

builds/msvc/vs2013/libbitcoin-consensus.import.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<ClCompile>
1818
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\..\libbitcoin-consensus\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
1919
<PreprocessorDefinitions Condition="'$(Option-secp256k1)' == 'true'">USE_SECP256K1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
20-
<PreprocessorDefinitions Condition="'$(Linkage-libbitcoin-consensus)' == 'static' Or '$(Linkage-libbitcoin-consensus)' == 'ltcg'">BCX_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
20+
<PreprocessorDefinitions Condition="'$(Linkage-libbitcoin-consensus)' == 'static' Or '$(Linkage-libbitcoin-consensus)' == 'ltcg'">BCK_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
2121
</ClCompile>
2222
<Link>
2323
<!-- $(PlatformToolset) is hard wired to v120 to allow for linkage by PlatformToolset=CTP_Nov2013 callers. -->

src/config.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
*/
2020
#include "config.hpp"
2121

22-
#include <iostream>
2322
#include <string>
2423
#include <boost/filesystem.hpp>
2524
#include <boost/program_options.hpp>
@@ -79,11 +78,10 @@ static bool load_configuration_variables(variables_map& variables,
7978
error_code code;
8079
if (!config_path.empty() && exists(config_path, code))
8180
{
82-
const auto& path = config_path.generic_string();
83-
std::ifstream file(path);
81+
bc::ifstream file(config_path.string());
8482
if (!file.good())
8583
{
86-
BOOST_THROW_EXCEPTION(reading_file(path.c_str()));
84+
BOOST_THROW_EXCEPTION(reading_file(config_path.string().c_str()));
8785
}
8886

8987
const auto config = parse_config_file(file, config_settings);

src/echo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
* You should have received a copy of the GNU Affero General Public License
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
20-
#include <iostream>
2120
#include "echo.hpp"
2221

22+
#include <iostream>
23+
#include <bitcoin/bitcoin.hpp>
24+
2325
namespace libbitcoin {
2426
namespace server {
2527

@@ -32,7 +34,7 @@ stdout_wrapper::stdout_wrapper(stdout_wrapper&& other)
3234
}
3335
stdout_wrapper::~stdout_wrapper()
3436
{
35-
std::cout << stream_.str() << std::endl;
37+
bc::cout << stream_.str() << std::endl;
3638
}
3739

3840
stdout_wrapper echo()

src/main.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/**
22
* Copyright (c) 2011-2015 libbitcoin developers (see AUTHORS)
33
*
44
* This file is part of libbitcoin-server.
@@ -17,16 +17,20 @@
1717
* You should have received a copy of the GNU Affero General Public License
1818
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1919
*/
20-
#include <iostream>
2120
#include <bitcoin/bitcoin.hpp>
2221
#include "server.hpp"
2322

23+
BC_USE_LIBBITCOIN_MAIN
24+
2425
/**
25-
* Server entry point.
26+
* Invoke this program with the raw arguments provided on the command line.
27+
* All console input and output streams for the application originate here.
28+
* @param argc The number of elements in the argv array.
29+
* @param argv The array of arguments, including the process.
30+
* @return The numeric result to return via console exit.
2631
*/
27-
int main(int argc, char* argv[])
32+
int bc::main(int argc, char* argv[])
2833
{
29-
// I/O injection.
3034
return bc::server::dispatch(argc, const_cast<const char**>(argv),
31-
std::cin, std::cout, std::cerr);
35+
bc::cin, bc::cout, bc::cerr);
3236
}

src/node_impl.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ using std::placeholders::_4;
3939

4040
const time_duration retry_start_duration = seconds(30);
4141

42+
constexpr std::ofstream::openmode log_open_mode =
43+
std::ofstream::out | std::ofstream::app;
44+
4245
static std::string make_log_string(log_level level,
4346
const std::string& domain, const std::string& body, bool log_requests)
4447
{
@@ -71,16 +74,18 @@ void log_to_both(std::ostream& device, std::ofstream& file, log_level level,
7174
}
7275

7376
node_impl::node_impl(settings_type& config)
77+
: outfile_(config.debug_file.string(), log_open_mode),
78+
errfile_(config.error_file.string(), log_open_mode),
7479
// Threadpools and the number of threads they spawn.
7580
// 6 threads spawned in total.
76-
: network_pool_(1), disk_pool_(6), mem_pool_(1),
81+
network_pool_(1), disk_pool_(6), mem_pool_(1),
7782
// Networking related services.
7883
hosts_(network_pool_),
7984
handshake_(network_pool_),
8085
network_(network_pool_),
8186
protocol_(network_pool_, hosts_, handshake_, network_),
8287
// Blockchain database service.
83-
chain_(disk_pool_, config.blockchain_path.generic_string(),
88+
chain_(disk_pool_, config.blockchain_path.string(),
8489
{config.history_height}),
8590
// Poll new blocks, tx memory pool and tx indexer.
8691
poller_(mem_pool_, chain_),
@@ -95,27 +100,26 @@ node_impl::node_impl(settings_type& config)
95100

96101
bool node_impl::start(settings_type& config)
97102
{
98-
auto file_mode = std::ofstream::out | std::ofstream::app;
99-
outfile_.open(config.debug_file.generic_string(), file_mode);
100-
errfile_.open(config.error_file.generic_string(), file_mode);
101103
log_debug().set_output_function(
102104
std::bind(log_to_file, std::ref(outfile_),
103105
_1, _2, _3, config.log_requests));
104106
log_info().set_output_function(
105-
std::bind(log_to_both, std::ref(std::cout), std::ref(outfile_),
107+
std::bind(log_to_both, std::ref(bc::cout), std::ref(outfile_),
106108
_1, _2, _3, config.log_requests));
107109
log_warning().set_output_function(
108110
std::bind(log_to_file, std::ref(errfile_),
109111
_1, _2, _3, config.log_requests));
110112
log_error().set_output_function(
111-
std::bind(log_to_both, std::ref(std::cerr), std::ref(errfile_),
113+
std::bind(log_to_both, std::ref(bc::cerr), std::ref(errfile_),
112114
_1, _2, _3, config.log_requests));
113115
log_fatal().set_output_function(
114-
std::bind(log_to_both, std::ref(std::cerr), std::ref(errfile_),
116+
std::bind(log_to_both, std::ref(bc::cerr), std::ref(errfile_),
115117
_1, _2, _3, config.log_requests));
118+
116119
// Subscribe to new connections.
117120
protocol_.subscribe_channel(
118121
std::bind(&node_impl::monitor_tx, this, _1, _2));
122+
119123
// Start blockchain.
120124
if (!chain_.start())
121125
{
@@ -124,24 +128,28 @@ bool node_impl::start(settings_type& config)
124128
}
125129
chain_.subscribe_reorganize(
126130
std::bind(&node_impl::reorganize, this, _1, _2, _3, _4));
131+
127132
// Start transaction pool
128133
txpool_.set_capacity(config.tx_pool_capacity);
129134
txpool_.start();
135+
130136
// Outgoing connections setting in config file before we
131137
// start p2p network subsystem.
132138
int outgoing_connections = boost::lexical_cast<int>(
133139
config.out_connections);
134140
protocol_.set_max_outbound(outgoing_connections);
135-
protocol_.set_hosts_filename(config.hosts_file.generic_string());
141+
protocol_.set_hosts_filename(config.hosts_file.string());
136142
if (!config.listener_enabled)
137143
protocol_.disable_listener();
144+
138145
for (const auto& endpoint: config.peers)
139146
{
140147
log_info(LOG_NODE) << "Adding node: "
141148
<< endpoint.get_host() << " " << endpoint.get_port();
142149
protocol_.maintain_connection(endpoint.get_host(),
143150
endpoint.get_port());
144151
}
152+
145153
start_session();
146154
return true;
147155
}

src/node_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#ifndef LIBBITCOIN_SERVER_NODE_IMPL_HPP
2121
#define LIBBITCOIN_SERVER_NODE_IMPL_HPP
2222

23+
#include <bitcoin/bitcoin.hpp>
2324
#include <bitcoin/node.hpp>
2425
#include "settings.hpp"
2526

@@ -76,7 +77,7 @@ class node_impl
7677
const bc::chain::blockchain::block_list& new_blocks,
7778
const bc::chain::blockchain::block_list& replaced_blocks);
7879

79-
std::ofstream outfile_, errfile_;
80+
bc::ofstream outfile_, errfile_;
8081
// Threadpools
8182
bc::threadpool network_pool_, disk_pool_, mem_pool_;
8283
// Services

0 commit comments

Comments
 (0)