Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable compilation/usage of diskhash on Windows #3372

Merged
merged 5 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,10 @@ find_package(Boost 1.70.0 REQUIRED COMPONENTS filesystem log log_setup thread
program_options system)

# diskhash
add_library(diskhash STATIC ${CMAKE_SOURCE_DIR}/diskhash/src/diskhash.c)
include_directories(diskhash/src)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
add_library(diskhash STATIC ${CMAKE_SOURCE_DIR}/diskhash/src/diskhash.c)
include_directories(diskhash/src)
endif()

# RocksDB
include_directories(rocksdb/include)
Expand Down
5 changes: 5 additions & 0 deletions nano/core_test/ledger_walker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

#include <numeric>

// TODO: keep this until diskhash builds fine on Windows
#ifndef _WIN32

using namespace std::chrono_literals;

TEST (ledger_walker, genesis_block)
Expand Down Expand Up @@ -218,3 +221,5 @@ TEST (ledger_walker, ladder_geometry)

EXPECT_EQ (amounts_expected_itr, amounts_expected_backwards.crend ());
}

#endif // _WIN32 -- TODO: keep this until diskhash builds fine on Windows
6 changes: 5 additions & 1 deletion nano/node/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ add_library(
write_database_queue.cpp
xorshift.hpp)

if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(DISKHASH diskhash)
endif()

target_link_libraries(
node
rpc
Expand All @@ -166,7 +170,7 @@ target_link_libraries(
Boost::thread
Boost::boost
rocksdb
diskhash
${DISKHASH}
${CMAKE_DL_LIBS}
${psapi_lib})

Expand Down
5 changes: 5 additions & 0 deletions nano/node/ledger_walker.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// TODO: keep this until diskhash builds fine on Windows
#ifndef _WIN32

#include <nano/lib/blocks.hpp>
#include <nano/lib/errors.hpp>
#include <nano/node/ledger_walker.hpp>
Expand Down Expand Up @@ -173,3 +176,5 @@ std::shared_ptr<nano::block> nano::ledger_walker::dequeue_block (nano::transacti

return block;
}

#endif // _WIN32 -- TODO: keep this until diskhash builds fine on Windows
5 changes: 5 additions & 0 deletions nano/node/ledger_walker.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// TODO: keep this until diskhash builds fine on Windows
#ifndef _WIN32

#pragma once

#include <nano/lib/numbers.hpp>
Expand Down Expand Up @@ -58,3 +61,5 @@ class ledger_walker final
};

}

#endif // _WIN32 -- TODO: keep this until diskhash builds fine on Windows
30 changes: 15 additions & 15 deletions nano/test_common/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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 (!node->init_error ());
Expand Down Expand Up @@ -154,27 +154,27 @@ void nano::system::ledger_initialization_set (std::vector<nano::keypair> const &
nano::block_hash previous = nano::genesis_hash;
auto amount = (nano::genesis_amount - reserve.number ()) / reps.size ();
auto balance = nano::genesis_amount;
for (auto const & i: reps)
for (auto const & i : reps)
{
balance -= amount;
nano::state_block_builder builder;
builder.account (nano::dev_genesis_key.pub)
.previous (previous)
.representative(nano::dev_genesis_key.pub)
.link (i.pub)
.balance (balance)
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
.work (*work.generate (previous));
.previous (previous)
.representative (nano::dev_genesis_key.pub)
.link (i.pub)
.balance (balance)
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
.work (*work.generate (previous));
initialization_blocks.emplace_back (builder.build_shared ());
previous = initialization_blocks.back ()->hash ();
builder.make_block ();
builder.account (i.pub)
.previous (0)
.representative(i.pub)
.link (previous)
.balance (amount)
.sign (i.prv, i.pub)
.work (*work.generate (i.pub));
.previous (0)
.representative (i.pub)
.link (previous)
.balance (amount)
.sign (i.prv, i.pub)
.work (*work.generate (i.pub));
initialization_blocks.emplace_back (builder.build_shared ());
}
}
Expand Down
1 change: 1 addition & 0 deletions nano/test_common/system.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class system final
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 };
unsigned node_sequence{ 0 };

private:
std::vector<std::shared_ptr<nano::block>> initialization_blocks;
};
Expand Down