Removing landing project.
This commit is contained in:
parent
cdf2046c48
commit
2f9d8b24bf
3 changed files with 2 additions and 233 deletions
|
@ -213,7 +213,6 @@ if (RAIBLOCKS_TEST)
|
|||
rai/core_test/daemon.cpp
|
||||
rai/core_test/entry.cpp
|
||||
rai/core_test/gap_cache.cpp
|
||||
rai/core_test/landing.cpp
|
||||
rai/core_test/ledger.cpp
|
||||
rai/core_test/message.cpp
|
||||
rai/core_test/message_parser.cpp
|
||||
|
@ -230,11 +229,8 @@ if (RAIBLOCKS_TEST)
|
|||
add_executable (slow_test
|
||||
rai/slow_test/node.cpp)
|
||||
|
||||
add_executable (rai_landing
|
||||
rai/rai_landing/entry.cpp)
|
||||
|
||||
set_target_properties (core_test slow_test rai_landing PROPERTIES COMPILE_FLAGS "${PLATFORM_CXX_FLAGS} ${PLATFORM_COMPILE_FLAGS} -DQT_NO_KEYWORDS -DACTIVE_NETWORK=${ACTIVE_NETWORK} -DRAIBLOCKS_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} -DRAIBLOCKS_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} -DBOOST_ASIO_HAS_STD_ARRAY=1 -DRAIBLOCKS_VERSION_PATCH=${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
set_target_properties (core_test slow_test rai_landing PROPERTIES LINK_FLAGS "${PLATFORM_LINK_FLAGS}")
|
||||
set_target_properties (core_test slow_test PROPERTIES COMPILE_FLAGS "${PLATFORM_CXX_FLAGS} ${PLATFORM_COMPILE_FLAGS} -DQT_NO_KEYWORDS -DACTIVE_NETWORK=${ACTIVE_NETWORK} -DRAIBLOCKS_VERSION_MAJOR=${CPACK_PACKAGE_VERSION_MAJOR} -DRAIBLOCKS_VERSION_MINOR=${CPACK_PACKAGE_VERSION_MINOR} -DBOOST_ASIO_HAS_STD_ARRAY=1 -DRAIBLOCKS_VERSION_PATCH=${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
set_target_properties (core_test slow_test PROPERTIES LINK_FLAGS "${PLATFORM_LINK_FLAGS}")
|
||||
endif (RAIBLOCKS_TEST)
|
||||
|
||||
if (RAIBLOCKS_GUI)
|
||||
|
@ -291,8 +287,6 @@ if (RAIBLOCKS_TEST)
|
|||
target_link_libraries (core_test node secure lmdb xxhash ed25519 argon2 blake2 cryptopp gtest_main gtest libminiupnpc-static ${Boost_ATOMIC_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_THREAD_LIBRARY} ${PLATFORM_LIBS})
|
||||
|
||||
target_link_libraries (slow_test node secure lmdb xxhash ed25519 argon2 blake2 cryptopp gtest_main gtest libminiupnpc-static ${Boost_ATOMIC_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_THREAD_LIBRARY} ${PLATFORM_LIBS})
|
||||
|
||||
target_link_libraries (rai_landing node secure lmdb xxhash ed25519 argon2 blake2 cryptopp libminiupnpc-static ${Boost_ATOMIC_LIBRARY} ${Boost_CHRONO_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_LOG_LIBRARY} ${Boost_LOG_SETUP_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_THREAD_LIBRARY} ${PLATFORM_LIBS})
|
||||
endif (RAIBLOCKS_TEST)
|
||||
|
||||
if (RAIBLOCKS_GUI)
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <rai/node/testing.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
TEST (landing, serialization)
|
||||
{
|
||||
rai::landing_store store1 (0, 1, 2, 3);
|
||||
auto file (rai::unique_path ());
|
||||
{
|
||||
std::ofstream stream;
|
||||
stream.open (file.string ());
|
||||
ASSERT_FALSE (stream.fail ());
|
||||
store1.serialize (stream);
|
||||
}
|
||||
std::ifstream stream;
|
||||
stream.open (file.string ());
|
||||
ASSERT_FALSE (stream.fail ());
|
||||
bool error;
|
||||
rai::landing_store store2 (error, stream);
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_EQ (store1, store2);
|
||||
}
|
||||
|
||||
TEST (landing, overwrite)
|
||||
{
|
||||
rai::landing_store store1 (0, 1, 2, 3);
|
||||
auto file (rai::unique_path ());
|
||||
for (auto i (0); i < 10; ++i)
|
||||
{
|
||||
store1.last += i;
|
||||
{
|
||||
std::ofstream stream;
|
||||
stream.open (file.string ());
|
||||
ASSERT_FALSE (stream.fail ());
|
||||
store1.serialize (stream);
|
||||
}
|
||||
{
|
||||
std::ifstream stream;
|
||||
stream.open (file.string ());
|
||||
ASSERT_FALSE (stream.fail ());
|
||||
bool error;
|
||||
rai::landing_store store2 (error, stream);
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_EQ (store1, store2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST (landing, start)
|
||||
{
|
||||
rai::system system (24000, 1);
|
||||
rai::keypair key;
|
||||
auto path (rai::unique_path ());
|
||||
rai::landing_store store (rai::test_genesis_key.pub, key.pub, std::numeric_limits <uint64_t>::max (), std::numeric_limits <uint64_t>::max ());
|
||||
rai::landing landing (*system.nodes [0], system.wallet(0), store, path);
|
||||
}
|
|
@ -1,168 +0,0 @@
|
|||
#include <rai/node/testing.hpp>
|
||||
|
||||
#include <rai/node/working.hpp>
|
||||
|
||||
#include <boost/make_shared.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <fstream>
|
||||
|
||||
namespace rai
|
||||
{
|
||||
class landing_config
|
||||
{
|
||||
public:
|
||||
landing_config (boost::filesystem::path const & application_path_a) :
|
||||
landing_file ("landing.json"),
|
||||
node (application_path_a)
|
||||
{
|
||||
rai::random_pool.GenerateBlock (wallet.bytes.data (), wallet.bytes.size ());
|
||||
assert (!wallet.is_zero ());
|
||||
}
|
||||
bool deserialize_json (bool & upgraded_a, boost::property_tree::ptree & tree_a)
|
||||
{
|
||||
auto error (false);
|
||||
try
|
||||
{
|
||||
if (!tree_a.empty ())
|
||||
{
|
||||
auto wallet_l (tree_a.get <std::string> ("wallet"));
|
||||
auto & node_l (tree_a.get_child ("node"));
|
||||
try
|
||||
{
|
||||
error |= wallet.decode_hex (wallet_l);
|
||||
error |= node.deserialize_json (upgraded_a, node_l);
|
||||
}
|
||||
catch (std::logic_error const &)
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
upgraded_a = true;
|
||||
serialize_json (tree_a);
|
||||
}
|
||||
}
|
||||
catch (std::runtime_error const &)
|
||||
{
|
||||
error = true;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
void serialize_json (boost::property_tree::ptree & tree_a) const
|
||||
{
|
||||
std::string wallet_l;
|
||||
wallet.encode_hex (wallet_l);
|
||||
tree_a.put ("wallet", wallet_l);
|
||||
boost::property_tree::ptree node_l;
|
||||
node.serialize_json (node_l);
|
||||
tree_a.add_child ("node", node_l);
|
||||
}
|
||||
std::string landing_file;
|
||||
rai::uint256_union wallet;
|
||||
rai::node_config node;
|
||||
};
|
||||
}
|
||||
|
||||
int main (int argc, char * const * argv)
|
||||
{
|
||||
auto working (rai::working_path ());
|
||||
boost::filesystem::create_directories (working);
|
||||
rai::landing_config config (working);
|
||||
auto config_path ((working / "config.json").string ());
|
||||
std::fstream config_file;
|
||||
rai::open_or_create (config_file, config_path);
|
||||
if (!config_file.fail ())
|
||||
{
|
||||
auto error (rai::fetch_object (config, config_file));
|
||||
if (!error)
|
||||
{
|
||||
rai::landing_store store;
|
||||
{
|
||||
std::ifstream store_stream;
|
||||
store_stream.open ((working / "landing.json").string ());
|
||||
if (!store_stream.fail ())
|
||||
{
|
||||
rai::landing_store loaded_store (error, store_stream);
|
||||
store = loaded_store;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ofstream store_stream;
|
||||
store_stream.open ((working / "landing.json").string ());
|
||||
if (!store_stream.fail ())
|
||||
{
|
||||
store.serialize (store_stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!error)
|
||||
{
|
||||
rai::node_init init;
|
||||
auto service (boost::make_shared <boost::asio::io_service> ());
|
||||
rai::work_pool work (config.node.work_threads, nullptr);
|
||||
rai::alarm alarm (*service);
|
||||
auto node (std::make_shared <rai::node> (init, *service, working, alarm, config.node, work));
|
||||
if (!init.error ())
|
||||
{
|
||||
node->start ();
|
||||
rai::thread_runner runner (*service, node->config.io_threads);
|
||||
auto wallet (node->wallets.open (config.wallet));
|
||||
if (wallet == nullptr)
|
||||
{
|
||||
wallet = node->wallets.create (config.wallet);
|
||||
}
|
||||
rai::landing landing (*node, wallet, store, working / "landing.json");
|
||||
auto now (landing.seconds_since_epoch ());
|
||||
std::cout << boost::str (boost::format ("Current time: %1%\n") % now);
|
||||
if (now - store.last > 0)
|
||||
{
|
||||
std::cout << boost::str (boost::format ("The last distribution was %1% seconds ago\n") % (now - store.last));
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << boost::str (boost::format ("Distribution will begin in %1% seconds\n") % (store.last - now));
|
||||
}
|
||||
{
|
||||
rai::transaction transaction (node->store.environment, nullptr, true);
|
||||
auto wallet_entry (wallet->store.begin (transaction));
|
||||
if (wallet_entry == wallet->store.end ())
|
||||
{
|
||||
auto pub (wallet->store.deterministic_insert (transaction));
|
||||
wallet_entry = wallet->store.begin (transaction);
|
||||
store.destination = pub;
|
||||
store.source = pub;
|
||||
store.start = now;
|
||||
store.last = now;
|
||||
landing.write_store ();
|
||||
}
|
||||
assert (wallet_entry != wallet->store.end ());
|
||||
std::cout << boost::str (boost::format ("Landing account: %1%\n") % store.source.to_account ());
|
||||
std::cout << boost::str (boost::format ("Destination account: %1%\n") % store.destination.to_account ());
|
||||
++wallet_entry;
|
||||
assert (wallet_entry == wallet->store.end ());
|
||||
}
|
||||
std::cout << "Type a line to start\n";
|
||||
std::string line;
|
||||
std::cin >> line;
|
||||
landing.distribute_ongoing ();
|
||||
runner.join ();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Error initializing node\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Error loading configuration\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Error deserializing config file\n";
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue