From 960cc1700980bff43d67182720b3f43335848dd8 Mon Sep 17 00:00:00 2001 From: Cathal Tummon Date: Mon, 22 Oct 2018 18:37:10 +0100 Subject: [PATCH] Fix MSVC linker error using rai_bootstrap_weights (#1317) --- appveyor.yml | 13 +------------ rai/node/node.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f8b4792e..6cfa2ce1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,18 +19,7 @@ install: cmake -DRAIBLOCKS_GUI=ON -DACTIVE_NETWORK=%NETWORK% -DQt5_DIR="C:\Qt\5.9\msvc2017_64\lib\cmake\Qt5" -DRAIBLOCKS_SIMD_OPTIMIZATIONS=TRUE -DBoost_COMPILER="-vc141" -DBOOST_ROOT="C:/Libraries/boost_1_66_0" -DBOOST_LIBRARYDIR="C:/Libraries/boost_1_66_0/lib64-msvc-14.1" -G "Visual Studio 15 2017 Win64" -DIPHLPAPI_LIBRARY="C:/Program Files (x86)/Windows Kits/10/Lib/10.0.14393.0/um/x64/iphlpapi.lib" -DWINSOCK2_LIBRARY="C:/Program Files (x86)/Windows Kits/10/Lib/10.0.14393.0/um/x64/WS2_32.lib" -DGIT_COMMIT=%GIT_COMMIT% -- ps: >- - $size_t=select-string -path ".\bootstrap_weights.cpp" -Pattern "rai_bootstrap_weights_size"| foreach {$_.Line} - - $old_size_t = "extern const size_t rai_bootstrap_weights_size;" - - $char=select-string -path ".\bootstrap_weights.cpp" -Pattern "char rai_bootstrap_weights"| foreach {$_.Line} - - $old_char = [regex]::Escape("extern const char rai_bootstrap_weights[];") - - select-string -path ".\rai\node\node.cpp" -Pattern $old_size_t -SimpleMatch | %{$curpath=$_.path; (get-content $curpath -Raw) -replace $old_char, $char| Out-File $curpath} - - select-string -path ".\rai\node\node.cpp" -Pattern $old_size_t -SimpleMatch | %{$curpath=$_.path; (get-content $curpath -Raw) -replace $old_size_t, $size_t| Out-File $curpath} + - ps: Invoke-WebRequest -Uri https://download.microsoft.com/download/5/7/b/57b2947c-7221-4f33-b35e-2fc78cb10df4/vc_redist.x64.exe -OutFile .\vc_redist.x64.exe build: diff --git a/rai/node/node.cpp b/rai/node/node.cpp index 9cf15d42..332612eb 100644 --- a/rai/node/node.cpp +++ b/rai/node/node.cpp @@ -26,6 +26,12 @@ unsigned constexpr rai::active_transactions::announce_interval_ms; size_t constexpr rai::block_arrival::arrival_size_min; std::chrono::seconds constexpr rai::block_arrival::arrival_time_min; +namespace rai +{ +extern unsigned char rai_bootstrap_weights[]; +extern size_t rai_bootstrap_weights_size; +} + rai::network::network (rai::node & node_a, uint16_t port) : buffer_container (node_a.stats, rai::network::buffer_size, 4096), // 2Mb receive buffer socket (node_a.service, rai::endpoint (boost::asio::ip::address_v6::any (), port)), @@ -1464,8 +1470,6 @@ stats (config.stat_config) peers.online_weight_minimum = config.online_weight_minimum.number (); if (rai::rai_network == rai::rai_networks::rai_live_network || rai::rai_network == rai::rai_networks::rai_beta_network) { - extern const char rai_bootstrap_weights[]; - extern const size_t rai_bootstrap_weights_size; rai::bufferstream weight_stream ((const uint8_t *)rai_bootstrap_weights, rai_bootstrap_weights_size); rai::uint128_union block_height; if (!rai::read (weight_stream, block_height))