Disable compilation/usage of diskhash on Windows (#3372)

* Disable compilation/usage of diskhash on Windows

* Fix formatting

* Fix CMake formatting

* Take out ledger_walker header from the Windows compilation as well

* Prevent diskhash library from being referenced on Windows
This commit is contained in:
theohax 2021-07-08 16:21:47 +03:00 committed by GitHub
commit 3cfc81f8a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 40 additions and 18 deletions

View file

@ -379,8 +379,10 @@ find_package(Boost 1.70.0 REQUIRED COMPONENTS filesystem log log_setup thread
program_options system) program_options system)
# diskhash # diskhash
add_library(diskhash STATIC ${CMAKE_SOURCE_DIR}/diskhash/src/diskhash.c) if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
include_directories(diskhash/src) add_library(diskhash STATIC ${CMAKE_SOURCE_DIR}/diskhash/src/diskhash.c)
include_directories(diskhash/src)
endif()
# RocksDB # RocksDB
include_directories(rocksdb/include) include_directories(rocksdb/include)

View file

@ -6,6 +6,9 @@
#include <numeric> #include <numeric>
// TODO: keep this until diskhash builds fine on Windows
#ifndef _WIN32
using namespace std::chrono_literals; using namespace std::chrono_literals;
TEST (ledger_walker, genesis_block) TEST (ledger_walker, genesis_block)
@ -218,3 +221,5 @@ TEST (ledger_walker, ladder_geometry)
EXPECT_EQ (amounts_expected_itr, amounts_expected_backwards.crend ()); EXPECT_EQ (amounts_expected_itr, amounts_expected_backwards.crend ());
} }
#endif // _WIN32 -- TODO: keep this until diskhash builds fine on Windows

View file

@ -150,6 +150,10 @@ add_library(
write_database_queue.cpp write_database_queue.cpp
xorshift.hpp) xorshift.hpp)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(DISKHASH diskhash)
endif()
target_link_libraries( target_link_libraries(
node node
rpc rpc
@ -166,7 +170,7 @@ target_link_libraries(
Boost::thread Boost::thread
Boost::boost Boost::boost
rocksdb rocksdb
diskhash ${DISKHASH}
${CMAKE_DL_LIBS} ${CMAKE_DL_LIBS}
${psapi_lib}) ${psapi_lib})

View file

@ -1,3 +1,6 @@
// TODO: keep this until diskhash builds fine on Windows
#ifndef _WIN32
#include <nano/lib/blocks.hpp> #include <nano/lib/blocks.hpp>
#include <nano/lib/errors.hpp> #include <nano/lib/errors.hpp>
#include <nano/node/ledger_walker.hpp> #include <nano/node/ledger_walker.hpp>
@ -173,3 +176,5 @@ std::shared_ptr<nano::block> nano::ledger_walker::dequeue_block (nano::transacti
return block; return block;
} }
#endif // _WIN32 -- TODO: keep this until diskhash builds fine on Windows

View file

@ -1,3 +1,6 @@
// TODO: keep this until diskhash builds fine on Windows
#ifndef _WIN32
#pragma once #pragma once
#include <nano/lib/numbers.hpp> #include <nano/lib/numbers.hpp>
@ -58,3 +61,5 @@ private:
}; };
} }
#endif // _WIN32 -- TODO: keep this until diskhash builds fine on Windows

View file

@ -32,9 +32,9 @@ std::shared_ptr<nano::node> nano::system::add_node (nano::node_flags node_flags_
std::shared_ptr<nano::node> nano::system::add_node (nano::node_config const & node_config_a, nano::node_flags node_flags_a, nano::transport::transport_type type_a) std::shared_ptr<nano::node> nano::system::add_node (nano::node_config const & node_config_a, nano::node_flags node_flags_a, nano::transport::transport_type type_a)
{ {
auto node (std::make_shared<nano::node> (io_ctx, nano::unique_path (), node_config_a, work, node_flags_a, node_sequence++)); auto node (std::make_shared<nano::node> (io_ctx, nano::unique_path (), node_config_a, work, node_flags_a, node_sequence++));
for (auto i: initialization_blocks) for (auto i : initialization_blocks)
{ {
auto result = node->ledger.process (node->store.tx_begin_write(), *i); auto result = node->ledger.process (node->store.tx_begin_write (), *i);
debug_assert (result.code == nano::process_result::progress); debug_assert (result.code == nano::process_result::progress);
} }
debug_assert (!node->init_error ()); debug_assert (!node->init_error ());
@ -154,27 +154,27 @@ void nano::system::ledger_initialization_set (std::vector<nano::keypair> const &
nano::block_hash previous = nano::genesis_hash; nano::block_hash previous = nano::genesis_hash;
auto amount = (nano::genesis_amount - reserve.number ()) / reps.size (); auto amount = (nano::genesis_amount - reserve.number ()) / reps.size ();
auto balance = nano::genesis_amount; auto balance = nano::genesis_amount;
for (auto const & i: reps) for (auto const & i : reps)
{ {
balance -= amount; balance -= amount;
nano::state_block_builder builder; nano::state_block_builder builder;
builder.account (nano::dev_genesis_key.pub) builder.account (nano::dev_genesis_key.pub)
.previous (previous) .previous (previous)
.representative(nano::dev_genesis_key.pub) .representative (nano::dev_genesis_key.pub)
.link (i.pub) .link (i.pub)
.balance (balance) .balance (balance)
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub) .sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
.work (*work.generate (previous)); .work (*work.generate (previous));
initialization_blocks.emplace_back (builder.build_shared ()); initialization_blocks.emplace_back (builder.build_shared ());
previous = initialization_blocks.back ()->hash (); previous = initialization_blocks.back ()->hash ();
builder.make_block (); builder.make_block ();
builder.account (i.pub) builder.account (i.pub)
.previous (0) .previous (0)
.representative(i.pub) .representative (i.pub)
.link (previous) .link (previous)
.balance (amount) .balance (amount)
.sign (i.prv, i.pub) .sign (i.prv, i.pub)
.work (*work.generate (i.pub)); .work (*work.generate (i.pub));
initialization_blocks.emplace_back (builder.build_shared ()); initialization_blocks.emplace_back (builder.build_shared ());
} }
} }

View file

@ -54,6 +54,7 @@ public:
std::chrono::time_point<std::chrono::steady_clock, std::chrono::duration<double>> deadline{ std::chrono::steady_clock::time_point::max () }; std::chrono::time_point<std::chrono::steady_clock, std::chrono::duration<double>> deadline{ std::chrono::steady_clock::time_point::max () };
double deadline_scaling_factor{ 1.0 }; double deadline_scaling_factor{ 1.0 };
unsigned node_sequence{ 0 }; unsigned node_sequence{ 0 };
private: private:
std::vector<std::shared_ptr<nano::block>> initialization_blocks; std::vector<std::shared_ptr<nano::block>> initialization_blocks;
}; };