Created
February 18, 2020 12:37
-
-
Save wezrule/ab90069d569d43f6869af1d21c67ca48 to your computer and use it in GitHub Desktop.
1 million block batch add
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TEST (block_processor, mass_add) | |
{ | |
nano::system system; | |
nano::node_config node_config (nano::get_available_port (), system.logging); | |
node_config.frontiers_confirmation = nano::frontiers_confirmation_mode::disabled; | |
auto node = system.add_node (node_config); | |
nano::genesis genesis; | |
nano::keypair key; | |
system.wallet (0)->insert_adhoc (nano::test_genesis_key.prv); | |
auto const num_blocks = 1000000; | |
auto latest_genesis = node->latest (nano::test_genesis_key.pub); | |
std::vector<std::shared_ptr<nano::state_block>> state_blocks; | |
{ | |
for (auto i = 0; i < num_blocks; ++i) | |
{ | |
auto send (std::make_shared<nano::state_block> (nano::test_genesis_key.pub, latest_genesis, nano::test_genesis_key.pub, nano::genesis_amount - i - 1, nano::test_genesis_key.pub, nano::test_genesis_key.prv, nano::test_genesis_key.pub, *system.work.generate (latest_genesis))); | |
latest_genesis = send->hash (); | |
state_blocks.push_back (send); | |
} | |
} | |
nano::timer<> timer; | |
timer.start (); | |
for (auto const & block : state_blocks) | |
{ | |
node->block_processor.add (block, nano::seconds_since_epoch ()); | |
} | |
system.deadline_set (1000s); | |
while (node->ledger.cache.block_count != num_blocks + 1) | |
{ | |
ASSERT_NO_ERROR (system.poll ()); | |
} | |
node->block_processor.flush (); | |
std::cout << "Time: " << timer.since_start ().count () << "ms" << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment