Remove node dependency from secure library (#2033)
This commit is contained in:
parent
6a3de92dd7
commit
b169798598
34 changed files with 51 additions and 68 deletions
|
@ -341,7 +341,7 @@ if (NANO_GUI OR RAIBLOCKS_GUI)
|
|||
nano/qt/qt.hpp)
|
||||
|
||||
target_link_libraries(qt
|
||||
secure nano_lib node libminiupnpc-static Qt5::Gui Qt5::Widgets)
|
||||
node secure nano_lib libminiupnpc-static Qt5::Gui Qt5::Widgets)
|
||||
|
||||
target_compile_definitions(qt
|
||||
PRIVATE
|
||||
|
|
|
@ -821,7 +821,7 @@ TEST (block_store, upgrade_v2_v3)
|
|||
ASSERT_FALSE (store.account_get (transaction, nano::test_genesis_key.pub, info));
|
||||
info.rep_block = 42;
|
||||
nano::account_info_v5 info_old (info.head, info.rep_block, info.open_block, info.balance, info.modified);
|
||||
auto status (mdb_put (store.env.tx (transaction), store.accounts_v0, nano::mdb_val (nano::test_genesis_key.pub), info_old.val (), 0));
|
||||
auto status (mdb_put (store.env.tx (transaction), store.accounts_v0, nano::mdb_val (nano::test_genesis_key.pub), nano::mdb_val (sizeof (info_old), &info_old), 0));
|
||||
assert (status == 0);
|
||||
}
|
||||
nano::logger_mt logger;
|
||||
|
@ -853,7 +853,7 @@ TEST (block_store, upgrade_v3_v4)
|
|||
auto transaction (store.tx_begin_write ());
|
||||
store.version_put (transaction, 3);
|
||||
nano::pending_info_v3 info (key1.pub, 100, key2.pub);
|
||||
auto status (mdb_put (store.env.tx (transaction), store.pending_v0, nano::mdb_val (key3.pub), info.val (), 0));
|
||||
auto status (mdb_put (store.env.tx (transaction), store.pending_v0, nano::mdb_val (key3.pub), nano::mdb_val (sizeof (info), &info), 0));
|
||||
ASSERT_EQ (0, status);
|
||||
}
|
||||
nano::logger_mt logger;
|
||||
|
@ -1734,7 +1734,7 @@ void modify_genesis_account_info_to_v5 (nano::mdb_store & store, nano::transacti
|
|||
nano::account_info info;
|
||||
store.account_get (transaction_a, nano::test_genesis_key.pub, info);
|
||||
nano::account_info_v5 info_old (info.head, info.rep_block, info.open_block, info.balance, info.modified);
|
||||
auto status (mdb_put (store.env.tx (transaction_a), store.accounts_v0, nano::mdb_val (nano::test_genesis_key.pub), info_old.val (), 0));
|
||||
auto status (mdb_put (store.env.tx (transaction_a), store.accounts_v0, nano::mdb_val (nano::test_genesis_key.pub), nano::mdb_val (sizeof (info_old), &info_old), 0));
|
||||
assert (status == 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <nano/core_test/testutil.hpp>
|
||||
#include <nano/node/stats.hpp>
|
||||
#include <nano/lib/stats.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
|
||||
#include <crypto/cryptopp/filters.h>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <nano/lib/jsonconfig.hpp>
|
||||
#include <nano/node/testing.hpp>
|
||||
#include <nano/node/transport/udp.hpp>
|
||||
#include <nano/node/working.hpp>
|
||||
#include <nano/secure/working.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <nano/lib/logger_mt.hpp>
|
||||
#include <nano/node/lmdb.hpp>
|
||||
#include <nano/secure/blockstore.hpp>
|
||||
#include <nano/secure/versioning.hpp>
|
||||
|
||||
|
@ -17,7 +19,7 @@ TEST (versioning, account_info_v1)
|
|||
auto transaction (store.tx_begin_write ());
|
||||
nano::block_sideband sideband (nano::block_type::open, 0, 0, 0, 0, 0);
|
||||
store.block_put (transaction, open.hash (), open, sideband);
|
||||
auto status (mdb_put (store.env.tx (transaction), store.accounts_v0, nano::mdb_val (account), v1.val (), 0));
|
||||
auto status (mdb_put (store.env.tx (transaction), store.accounts_v0, nano::mdb_val (account), nano::mdb_val (sizeof (v1), &v1), 0));
|
||||
ASSERT_EQ (0, status);
|
||||
store.version_put (transaction, 1);
|
||||
}
|
||||
|
@ -53,7 +55,7 @@ TEST (versioning, account_info_v5)
|
|||
auto transaction (store.tx_begin_write ());
|
||||
nano::block_sideband sideband (nano::block_type::open, 0, 0, 0, 0, 0);
|
||||
store.block_put (transaction, open.hash (), open, sideband);
|
||||
auto status (mdb_put (store.env.tx (transaction), store.accounts_v0, nano::mdb_val (account), v5.val (), 0));
|
||||
auto status (mdb_put (store.env.tx (transaction), store.accounts_v0, nano::mdb_val (account), nano::mdb_val (sizeof (v5), &v5), 0));
|
||||
ASSERT_EQ (0, status);
|
||||
store.version_put (transaction, 5);
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@ add_library (nano_lib
|
|||
rpcconfig.cpp
|
||||
numbers.hpp
|
||||
numbers.cpp
|
||||
stats.hpp
|
||||
stats.cpp
|
||||
timer.hpp
|
||||
utility.hpp
|
||||
utility.cpp
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <nano/node/stats.hpp>
|
||||
#include <nano/lib/stats.hpp>
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/format.hpp>
|
|
@ -141,6 +141,14 @@ public:
|
|||
boost::asio::executor_work_guard<boost::asio::io_context::executor_type> io_guard;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns seconds passed since unix epoch (posix time)
|
||||
*/
|
||||
inline uint64_t seconds_since_epoch ()
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::seconds> (std::chrono::system_clock::now ().time_since_epoch ()).count ();
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
class observer_set final
|
||||
{
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include <nano/node/json_handler.hpp>
|
||||
#include <nano/node/node.hpp>
|
||||
#include <nano/node/openclwork.hpp>
|
||||
#include <nano/node/working.hpp>
|
||||
#include <nano/rpc/rpc.hpp>
|
||||
#include <nano/secure/working.hpp>
|
||||
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
#include <nano/nano_wallet/icon.hpp>
|
||||
#include <nano/node/cli.hpp>
|
||||
#include <nano/node/ipc.hpp>
|
||||
#include <nano/node/working.hpp>
|
||||
#include <nano/rpc/rpc.hpp>
|
||||
#include <nano/rpc/rpc_request_processor.hpp>
|
||||
#include <nano/secure/working.hpp>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/log/expressions.hpp>
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
#include <nano/node/ipc.hpp>
|
||||
#include <nano/node/json_handler.hpp>
|
||||
#include <nano/node/node_rpc_config.hpp>
|
||||
#include <nano/node/working.hpp>
|
||||
#include <nano/qt/qt.hpp>
|
||||
#include <nano/rpc/rpc.hpp>
|
||||
#include <nano/secure/working.hpp>
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#include <nano/lib/errors.hpp>
|
||||
#include <nano/lib/utility.hpp>
|
||||
#include <nano/node/cli.hpp>
|
||||
#include <nano/node/working.hpp>
|
||||
#include <nano/rpc/rpc.hpp>
|
||||
#include <nano/secure/working.hpp>
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
|
|
|
@ -76,8 +76,6 @@ add_library (node
|
|||
signatures.cpp
|
||||
socket.hpp
|
||||
socket.cpp
|
||||
stats.hpp
|
||||
stats.cpp
|
||||
voting.hpp
|
||||
voting.cpp
|
||||
wallet.hpp
|
||||
|
@ -86,7 +84,6 @@ add_library (node
|
|||
websocket.cpp
|
||||
websocketconfig.hpp
|
||||
websocketconfig.cpp
|
||||
working.hpp
|
||||
xorshift.hpp)
|
||||
|
||||
target_link_libraries (node
|
||||
|
|
|
@ -410,12 +410,4 @@ public:
|
|||
virtual void node_id_handshake (nano::node_id_handshake const &) = 0;
|
||||
virtual ~message_visitor ();
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns seconds passed since unix epoch (posix time)
|
||||
*/
|
||||
inline uint64_t seconds_since_epoch ()
|
||||
{
|
||||
return std::chrono::duration_cast<std::chrono::seconds> (std::chrono::system_clock::now ().time_since_epoch ()).count ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#include <nano/lib/logger_mt.hpp>
|
||||
#include <nano/lib/numbers.hpp>
|
||||
#include <nano/lib/stats.hpp>
|
||||
#include <nano/lib/utility.hpp>
|
||||
#include <nano/node/active_transactions.hpp>
|
||||
#include <nano/node/confirmation_height_processor.hpp>
|
||||
#include <nano/node/stats.hpp>
|
||||
#include <nano/secure/blockstore.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
|
||||
|
|
|
@ -1086,7 +1086,7 @@ void nano::mdb_store::upgrade_v1_to_v2 (nano::transaction const & transaction_a)
|
|||
block = block_get (transaction_a, block->previous ());
|
||||
}
|
||||
v2.open_block = block->hash ();
|
||||
auto status (mdb_put (env.tx (transaction_a), accounts_v0, nano::mdb_val (account), v2.val (), 0));
|
||||
auto status (mdb_put (env.tx (transaction_a), accounts_v0, nano::mdb_val (account), nano::mdb_val (sizeof (v2), &v2), 0));
|
||||
release_assert (status == 0);
|
||||
account = account.number () + 1;
|
||||
}
|
||||
|
@ -1110,7 +1110,7 @@ void nano::mdb_store::upgrade_v2_to_v3 (nano::transaction const & transaction_a)
|
|||
assert (!visitor.result.is_zero ());
|
||||
info.rep_block = visitor.result;
|
||||
auto impl (boost::polymorphic_downcast<nano::mdb_iterator<nano::account, nano::account_info_v5> *> (i.get ()));
|
||||
mdb_cursor_put (impl->cursor, nano::mdb_val (account_l), info.val (), MDB_CURRENT);
|
||||
mdb_cursor_put (impl->cursor, nano::mdb_val (account_l), nano::mdb_val (sizeof (info), &info), MDB_CURRENT);
|
||||
representation_add (transaction_a, visitor.result, info.balance.number ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/lib/stats.hpp>
|
||||
#include <nano/lib/work.hpp>
|
||||
#include <nano/node/active_transactions.hpp>
|
||||
#include <nano/node/blockprocessor.hpp>
|
||||
|
@ -13,7 +14,6 @@
|
|||
#include <nano/node/portmapping.hpp>
|
||||
#include <nano/node/repcrawler.hpp>
|
||||
#include <nano/node/signatures.hpp>
|
||||
#include <nano/node/stats.hpp>
|
||||
#include <nano/node/wallet.hpp>
|
||||
#include <nano/node/websocket.hpp>
|
||||
#include <nano/secure/ledger.hpp>
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
#include <nano/lib/errors.hpp>
|
||||
#include <nano/lib/jsonconfig.hpp>
|
||||
#include <nano/lib/numbers.hpp>
|
||||
#include <nano/lib/stats.hpp>
|
||||
#include <nano/node/diagnosticsconfig.hpp>
|
||||
#include <nano/node/ipcconfig.hpp>
|
||||
#include <nano/node/logging.hpp>
|
||||
#include <nano/node/stats.hpp>
|
||||
#include <nano/node/websocketconfig.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <nano/lib/stats.hpp>
|
||||
#include <nano/node/node.hpp>
|
||||
#include <nano/node/stats.hpp>
|
||||
#include <nano/node/transport/tcp.hpp>
|
||||
|
||||
nano::transport::channel_tcp::channel_tcp (nano::node & node_a, std::shared_ptr<nano::socket> socket_a) :
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/lib/stats.hpp>
|
||||
#include <nano/node/common.hpp>
|
||||
#include <nano/node/socket.hpp>
|
||||
#include <nano/node/stats.hpp>
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <nano/crypto_lib/random_pool.hpp>
|
||||
#include <nano/lib/stats.hpp>
|
||||
#include <nano/node/node.hpp>
|
||||
#include <nano/node/stats.hpp>
|
||||
#include <nano/node/transport/udp.hpp>
|
||||
|
||||
nano::transport::channel_udp::channel_udp (nano::transport::udp_channels & channels_a, nano::endpoint const & endpoint_a, unsigned network_version_a) :
|
||||
|
|
|
@ -440,7 +440,7 @@ nano::wallet_value nano::wallet_store::entry_get_raw (nano::transaction const &
|
|||
|
||||
void nano::wallet_store::entry_put_raw (nano::transaction const & transaction_a, nano::public_key const & pub_a, nano::wallet_value const & entry_a)
|
||||
{
|
||||
auto status (mdb_put (tx (transaction_a), handle, nano::mdb_val (pub_a), entry_a.val (), 0));
|
||||
auto status (mdb_put (tx (transaction_a), handle, nano::mdb_val (pub_a), nano::mdb_val (sizeof (entry_a), const_cast<nano::wallet_value *> (&entry_a)), 0));
|
||||
assert (status == 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,16 +33,17 @@ add_library (secure
|
|||
${PLATFORM_SECURE_SOURCE}
|
||||
${CMAKE_BINARY_DIR}/bootstrap_weights_live.cpp
|
||||
${CMAKE_BINARY_DIR}/bootstrap_weights_beta.cpp
|
||||
common.cpp
|
||||
common.hpp
|
||||
blockstore.cpp
|
||||
common.cpp
|
||||
blockstore.hpp
|
||||
ledger.cpp
|
||||
blockstore.cpp
|
||||
ledger.hpp
|
||||
utility.cpp
|
||||
ledger.cpp
|
||||
utility.hpp
|
||||
utility.cpp
|
||||
versioning.hpp
|
||||
versioning.cpp)
|
||||
versioning.cpp
|
||||
working.hpp)
|
||||
|
||||
target_link_libraries(secure
|
||||
nano_lib
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#include <nano/node/common.hpp>
|
||||
#include <nano/node/wallet.hpp>
|
||||
#include <nano/secure/blockstore.hpp>
|
||||
|
||||
#include <boost/endian/conversion.hpp>
|
||||
|
|
|
@ -3,10 +3,8 @@
|
|||
#include <nano/lib/config.hpp>
|
||||
#include <nano/lib/interface.h>
|
||||
#include <nano/lib/numbers.hpp>
|
||||
#include <nano/node/common.hpp>
|
||||
#include <nano/secure/blockstore.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
#include <nano/secure/versioning.hpp>
|
||||
|
||||
#include <boost/endian/conversion.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <nano/lib/stats.hpp>
|
||||
#include <nano/lib/utility.hpp>
|
||||
#include <nano/lib/work.hpp>
|
||||
#include <nano/node/common.hpp>
|
||||
#include <nano/node/stats.hpp>
|
||||
#include <nano/secure/blockstore.hpp>
|
||||
#include <nano/secure/ledger.hpp>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <nano/node/working.hpp>
|
||||
#include <nano/secure/working.hpp>
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <nano/node/working.hpp>
|
||||
#include <nano/secure/working.hpp>
|
||||
|
||||
#include <pwd.h>
|
||||
#include <sys/types.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include <nano/node/working.hpp>
|
||||
#include <nano/secure/working.hpp>
|
||||
|
||||
#include <shlobj.h>
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
#include <nano/lib/config.hpp>
|
||||
#include <nano/lib/interface.h>
|
||||
#include <nano/node/logging.hpp>
|
||||
#include <nano/node/working.hpp>
|
||||
#include <nano/secure/utility.hpp>
|
||||
#include <nano/secure/working.hpp>
|
||||
|
||||
static std::vector<boost::filesystem::path> all_unique_paths;
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include <nano/secure/versioning.hpp>
|
||||
|
||||
#include <lmdb/libraries/liblmdb/lmdb.h>
|
||||
|
||||
nano::account_info_v1::account_info_v1 (MDB_val const & val_a)
|
||||
{
|
||||
assert (val_a.mv_size == sizeof (*this));
|
||||
|
@ -15,11 +17,6 @@ modified (modified_a)
|
|||
{
|
||||
}
|
||||
|
||||
nano::mdb_val nano::account_info_v1::val () const
|
||||
{
|
||||
return nano::mdb_val (sizeof (*this), const_cast<nano::account_info_v1 *> (this));
|
||||
}
|
||||
|
||||
nano::pending_info_v3::pending_info_v3 (MDB_val const & val_a)
|
||||
{
|
||||
assert (val_a.mv_size == sizeof (*this));
|
||||
|
@ -34,11 +31,6 @@ destination (destination_a)
|
|||
{
|
||||
}
|
||||
|
||||
nano::mdb_val nano::pending_info_v3::val () const
|
||||
{
|
||||
return nano::mdb_val (sizeof (*this), const_cast<nano::pending_info_v3 *> (this));
|
||||
}
|
||||
|
||||
nano::account_info_v5::account_info_v5 (MDB_val const & val_a)
|
||||
{
|
||||
assert (val_a.mv_size == sizeof (*this));
|
||||
|
@ -55,11 +47,6 @@ modified (modified_a)
|
|||
{
|
||||
}
|
||||
|
||||
nano::mdb_val nano::account_info_v5::val () const
|
||||
{
|
||||
return nano::mdb_val (sizeof (*this), const_cast<nano::account_info_v5 *> (this));
|
||||
}
|
||||
|
||||
nano::account_info_v13::account_info_v13 (nano::block_hash const & head_a, nano::block_hash const & rep_block_a, nano::block_hash const & open_block_a, nano::amount const & balance_a, uint64_t modified_a, uint64_t block_count_a, nano::epoch epoch_a) :
|
||||
head (head_a),
|
||||
rep_block (rep_block_a),
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <nano/lib/blocks.hpp>
|
||||
#include <nano/node/lmdb.hpp>
|
||||
#include <nano/secure/common.hpp>
|
||||
#include <nano/secure/utility.hpp>
|
||||
|
||||
struct MDB_val;
|
||||
|
||||
namespace nano
|
||||
{
|
||||
class account_info_v1 final
|
||||
|
@ -12,7 +14,6 @@ public:
|
|||
account_info_v1 () = default;
|
||||
explicit account_info_v1 (MDB_val const &);
|
||||
account_info_v1 (nano::block_hash const &, nano::block_hash const &, nano::amount const &, uint64_t);
|
||||
nano::mdb_val val () const;
|
||||
nano::block_hash head{ 0 };
|
||||
nano::block_hash rep_block{ 0 };
|
||||
nano::amount balance{ 0 };
|
||||
|
@ -24,7 +25,6 @@ public:
|
|||
pending_info_v3 () = default;
|
||||
explicit pending_info_v3 (MDB_val const &);
|
||||
pending_info_v3 (nano::account const &, nano::amount const &, nano::account const &);
|
||||
nano::mdb_val val () const;
|
||||
nano::account source{ 0 };
|
||||
nano::amount amount{ 0 };
|
||||
nano::account destination{ 0 };
|
||||
|
@ -35,7 +35,6 @@ public:
|
|||
account_info_v5 () = default;
|
||||
explicit account_info_v5 (MDB_val const &);
|
||||
account_info_v5 (nano::block_hash const &, nano::block_hash const &, nano::block_hash const &, nano::amount const &, uint64_t);
|
||||
nano::mdb_val val () const;
|
||||
nano::block_hash head{ 0 };
|
||||
nano::block_hash rep_block{ 0 };
|
||||
nano::block_hash open_block{ 0 };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue