Updating and applying formatting changes. (#3209)
This commit is contained in:
parent
bca5142309
commit
8d0a03e23d
188 changed files with 4409 additions and 4406 deletions
|
@ -7,22 +7,23 @@ Standard: Cpp11
|
|||
TabWidth: 4
|
||||
IndentWidth: 4
|
||||
PointerAlignment: Middle
|
||||
UseTab: ForIndentation
|
||||
UseTab: ForContinuationAndIndentation
|
||||
BreakBeforeBraces: Custom
|
||||
AlignEscapedNewlines: Left
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: false
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
BreakConstructorInitializersBeforeComma: true
|
||||
BreakConstructorInitializers: AfterColon
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 0
|
||||
ContinuationIndentWidth: 0
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
IndentCaseLabels: true
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterEnum: true
|
||||
AfterStruct: true
|
||||
SplitEmptyFunction: true
|
||||
|
@ -33,6 +34,7 @@ BraceWrapping:
|
|||
AfterClass: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
SortIncludes: true
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -462,13 +462,13 @@ TEST (block_builder, from)
|
|||
std::error_code ec;
|
||||
nano::block_builder builder;
|
||||
auto block = builder
|
||||
.state ()
|
||||
.account_address ("xrb_15nhh1kzw3x8ohez6s75wy3jr6dqgq65oaede1fzk5hqxk4j8ehz7iqtb3to")
|
||||
.previous_hex ("FEFBCE274E75148AB31FF63EFB3082EF1126BF72BF3FA9C76A97FD5A9F0EBEC5")
|
||||
.balance_dec ("2251569974100400000000000000000000")
|
||||
.representative_address ("xrb_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou")
|
||||
.link_hex ("E16DD58C1EFA8B521545B0A74375AA994D9FC43828A4266D75ECF57F07A7EE86")
|
||||
.build (ec);
|
||||
.state ()
|
||||
.account_address ("xrb_15nhh1kzw3x8ohez6s75wy3jr6dqgq65oaede1fzk5hqxk4j8ehz7iqtb3to")
|
||||
.previous_hex ("FEFBCE274E75148AB31FF63EFB3082EF1126BF72BF3FA9C76A97FD5A9F0EBEC5")
|
||||
.balance_dec ("2251569974100400000000000000000000")
|
||||
.representative_address ("xrb_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou")
|
||||
.link_hex ("E16DD58C1EFA8B521545B0A74375AA994D9FC43828A4266D75ECF57F07A7EE86")
|
||||
.build (ec);
|
||||
ASSERT_EQ (block->hash ().to_string (), "2D243F8F92CDD0AD94A1D456A6B15F3BE7A6FCBD98D4C5831D06D15C818CD81F");
|
||||
|
||||
auto block2 = builder.state ().from (*block).build (ec);
|
||||
|
@ -495,13 +495,13 @@ TEST (block_builder, state)
|
|||
std::error_code ec;
|
||||
nano::block_builder builder;
|
||||
auto block = builder
|
||||
.state ()
|
||||
.account_address ("xrb_15nhh1kzw3x8ohez6s75wy3jr6dqgq65oaede1fzk5hqxk4j8ehz7iqtb3to")
|
||||
.previous_hex ("FEFBCE274E75148AB31FF63EFB3082EF1126BF72BF3FA9C76A97FD5A9F0EBEC5")
|
||||
.balance_dec ("2251569974100400000000000000000000")
|
||||
.representative_address ("xrb_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou")
|
||||
.link_hex ("E16DD58C1EFA8B521545B0A74375AA994D9FC43828A4266D75ECF57F07A7EE86")
|
||||
.build (ec);
|
||||
.state ()
|
||||
.account_address ("xrb_15nhh1kzw3x8ohez6s75wy3jr6dqgq65oaede1fzk5hqxk4j8ehz7iqtb3to")
|
||||
.previous_hex ("FEFBCE274E75148AB31FF63EFB3082EF1126BF72BF3FA9C76A97FD5A9F0EBEC5")
|
||||
.balance_dec ("2251569974100400000000000000000000")
|
||||
.representative_address ("xrb_1stofnrxuz3cai7ze75o174bpm7scwj9jn3nxsn8ntzg784jf1gzn1jjdkou")
|
||||
.link_hex ("E16DD58C1EFA8B521545B0A74375AA994D9FC43828A4266D75ECF57F07A7EE86")
|
||||
.build (ec);
|
||||
ASSERT_EQ (block->hash ().to_string (), "2D243F8F92CDD0AD94A1D456A6B15F3BE7A6FCBD98D4C5831D06D15C818CD81F");
|
||||
ASSERT_TRUE (block->source ().is_zero ());
|
||||
ASSERT_TRUE (block->destination ().is_zero ());
|
||||
|
@ -514,14 +514,14 @@ TEST (block_builder, state_missing_rep)
|
|||
std::error_code ec;
|
||||
nano::block_builder builder;
|
||||
auto block = builder
|
||||
.state ()
|
||||
.account_address ("xrb_15nhh1kzw3x8ohez6s75wy3jr6dqgq65oaede1fzk5hqxk4j8ehz7iqtb3to")
|
||||
.previous_hex ("FEFBCE274E75148AB31FF63EFB3082EF1126BF72BF3FA9C76A97FD5A9F0EBEC5")
|
||||
.balance_dec ("2251569974100400000000000000000000")
|
||||
.link_hex ("E16DD58C1EFA8B521545B0A74375AA994D9FC43828A4266D75ECF57F07A7EE86")
|
||||
.sign_zero ()
|
||||
.work (0)
|
||||
.build (ec);
|
||||
.state ()
|
||||
.account_address ("xrb_15nhh1kzw3x8ohez6s75wy3jr6dqgq65oaede1fzk5hqxk4j8ehz7iqtb3to")
|
||||
.previous_hex ("FEFBCE274E75148AB31FF63EFB3082EF1126BF72BF3FA9C76A97FD5A9F0EBEC5")
|
||||
.balance_dec ("2251569974100400000000000000000000")
|
||||
.link_hex ("E16DD58C1EFA8B521545B0A74375AA994D9FC43828A4266D75ECF57F07A7EE86")
|
||||
.sign_zero ()
|
||||
.work (0)
|
||||
.build (ec);
|
||||
ASSERT_EQ (ec, nano::error_common::missing_representative);
|
||||
}
|
||||
|
||||
|
@ -536,15 +536,15 @@ TEST (block_builder, state_equality)
|
|||
|
||||
// With builder
|
||||
auto block2 = builder
|
||||
.state ()
|
||||
.account (key1.pub)
|
||||
.previous (1)
|
||||
.representative (key2.pub)
|
||||
.balance (2)
|
||||
.link (4)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (5)
|
||||
.build (ec);
|
||||
.state ()
|
||||
.account (key1.pub)
|
||||
.previous (1)
|
||||
.representative (key2.pub)
|
||||
.balance (2)
|
||||
.link (4)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (5)
|
||||
.build (ec);
|
||||
|
||||
ASSERT_NO_ERROR (ec);
|
||||
ASSERT_EQ (block1.hash (), block2->hash ());
|
||||
|
@ -570,11 +570,11 @@ TEST (block_builder, open)
|
|||
std::error_code ec;
|
||||
nano::block_builder builder;
|
||||
auto block = builder
|
||||
.open ()
|
||||
.account_address ("xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3")
|
||||
.representative_address ("xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3")
|
||||
.source_hex ("E89208DD038FBB269987689621D52292AE9C35941A7484756ECCED92A65093BA")
|
||||
.build (ec);
|
||||
.open ()
|
||||
.account_address ("xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3")
|
||||
.representative_address ("xrb_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3")
|
||||
.source_hex ("E89208DD038FBB269987689621D52292AE9C35941A7484756ECCED92A65093BA")
|
||||
.build (ec);
|
||||
ASSERT_EQ (block->hash ().to_string (), "991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948");
|
||||
ASSERT_EQ (block->source ().to_string (), "E89208DD038FBB269987689621D52292AE9C35941A7484756ECCED92A65093BA");
|
||||
ASSERT_TRUE (block->destination ().is_zero ());
|
||||
|
@ -592,13 +592,13 @@ TEST (block_builder, open_equality)
|
|||
|
||||
// With builder
|
||||
auto block2 = builder
|
||||
.open ()
|
||||
.source (1)
|
||||
.account (key2.pub)
|
||||
.representative (key1.pub)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (5)
|
||||
.build (ec);
|
||||
.open ()
|
||||
.source (1)
|
||||
.account (key2.pub)
|
||||
.representative (key1.pub)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (5)
|
||||
.build (ec);
|
||||
|
||||
ASSERT_NO_ERROR (ec);
|
||||
ASSERT_EQ (block1.hash (), block2->hash ());
|
||||
|
@ -610,10 +610,10 @@ TEST (block_builder, change)
|
|||
std::error_code ec;
|
||||
nano::block_builder builder;
|
||||
auto block = builder
|
||||
.change ()
|
||||
.representative_address ("xrb_3rropjiqfxpmrrkooej4qtmm1pueu36f9ghinpho4esfdor8785a455d16nf")
|
||||
.previous_hex ("088EE46429CA936F76C4EAA20B97F6D33E5D872971433EE0C1311BCB98764456")
|
||||
.build (ec);
|
||||
.change ()
|
||||
.representative_address ("xrb_3rropjiqfxpmrrkooej4qtmm1pueu36f9ghinpho4esfdor8785a455d16nf")
|
||||
.previous_hex ("088EE46429CA936F76C4EAA20B97F6D33E5D872971433EE0C1311BCB98764456")
|
||||
.build (ec);
|
||||
ASSERT_EQ (block->hash ().to_string (), "13552AC3928E93B5C6C215F61879358E248D4A5246B8B3D1EEC5A566EDCEE077");
|
||||
ASSERT_TRUE (block->source ().is_zero ());
|
||||
ASSERT_TRUE (block->destination ().is_zero ());
|
||||
|
@ -631,12 +631,12 @@ TEST (block_builder, change_equality)
|
|||
|
||||
// With builder
|
||||
auto block2 = builder
|
||||
.change ()
|
||||
.previous (1)
|
||||
.representative (key1.pub)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (5)
|
||||
.build (ec);
|
||||
.change ()
|
||||
.previous (1)
|
||||
.representative (key1.pub)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (5)
|
||||
.build (ec);
|
||||
|
||||
ASSERT_NO_ERROR (ec);
|
||||
ASSERT_EQ (block1.hash (), block2->hash ());
|
||||
|
@ -648,11 +648,11 @@ TEST (block_builder, send)
|
|||
std::error_code ec;
|
||||
nano::block_builder builder;
|
||||
auto block = builder
|
||||
.send ()
|
||||
.destination_address ("xrb_1gys8r4crpxhp94n4uho5cshaho81na6454qni5gu9n53gksoyy1wcd4udyb")
|
||||
.previous_hex ("F685856D73A488894F7F3A62BC3A88E17E985F9969629FF3FDD4A0D4FD823F24")
|
||||
.balance_hex ("00F035A9C7D818E7C34148C524FFFFEE")
|
||||
.build (ec);
|
||||
.send ()
|
||||
.destination_address ("xrb_1gys8r4crpxhp94n4uho5cshaho81na6454qni5gu9n53gksoyy1wcd4udyb")
|
||||
.previous_hex ("F685856D73A488894F7F3A62BC3A88E17E985F9969629FF3FDD4A0D4FD823F24")
|
||||
.balance_hex ("00F035A9C7D818E7C34148C524FFFFEE")
|
||||
.build (ec);
|
||||
ASSERT_EQ (block->hash ().to_string (), "4560E7B1F3735D082700CFC2852F5D1F378F7418FD24CEF1AD45AB69316F15CD");
|
||||
ASSERT_TRUE (block->source ().is_zero ());
|
||||
ASSERT_EQ (block->destination ().to_account (), "nano_1gys8r4crpxhp94n4uho5cshaho81na6454qni5gu9n53gksoyy1wcd4udyb");
|
||||
|
@ -670,13 +670,13 @@ TEST (block_builder, send_equality)
|
|||
|
||||
// With builder
|
||||
auto block2 = builder
|
||||
.send ()
|
||||
.previous (1)
|
||||
.destination (key1.pub)
|
||||
.balance (2)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (5)
|
||||
.build (ec);
|
||||
.send ()
|
||||
.previous (1)
|
||||
.destination (key1.pub)
|
||||
.balance (2)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (5)
|
||||
.build (ec);
|
||||
|
||||
ASSERT_NO_ERROR (ec);
|
||||
ASSERT_EQ (block1.hash (), block2->hash ());
|
||||
|
@ -694,12 +694,12 @@ TEST (block_builder, receive_equality)
|
|||
|
||||
// With builder
|
||||
auto block2 = builder
|
||||
.receive ()
|
||||
.previous (1)
|
||||
.source (2)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (5)
|
||||
.build (ec);
|
||||
.receive ()
|
||||
.previous (1)
|
||||
.source (2)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (5)
|
||||
.build (ec);
|
||||
|
||||
ASSERT_NO_ERROR (ec);
|
||||
ASSERT_EQ (block1.hash (), block2->hash ());
|
||||
|
@ -711,10 +711,10 @@ TEST (block_builder, receive)
|
|||
std::error_code ec;
|
||||
nano::block_builder builder;
|
||||
auto block = builder
|
||||
.receive ()
|
||||
.previous_hex ("59660153194CAC5DAC08509D87970BF86F6AEA943025E2A7ED7460930594950E")
|
||||
.source_hex ("7B2B0A29C1B235FDF9B4DEF2984BB3573BD1A52D28246396FBB3E4C5FE662135")
|
||||
.build (ec);
|
||||
.receive ()
|
||||
.previous_hex ("59660153194CAC5DAC08509D87970BF86F6AEA943025E2A7ED7460930594950E")
|
||||
.source_hex ("7B2B0A29C1B235FDF9B4DEF2984BB3573BD1A52D28246396FBB3E4C5FE662135")
|
||||
.build (ec);
|
||||
ASSERT_EQ (block->hash ().to_string (), "6C004BF911D9CF2ED75CF6EC45E795122AD5D093FF5A83EDFBA43EC4A3EDC722");
|
||||
ASSERT_EQ (block->source ().to_string (), "7B2B0A29C1B235FDF9B4DEF2984BB3573BD1A52D28246396FBB3E4C5FE662135");
|
||||
ASSERT_TRUE (block->destination ().is_zero ());
|
||||
|
|
|
@ -1434,7 +1434,7 @@ TEST (mdb_block_store, upgrade_v16_v17)
|
|||
nano::state_block block2 (nano::dev_genesis_key.pub, block1.hash (), nano::dev_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio - 1, nano::dev_genesis_key.pub, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (block1.hash ()));
|
||||
nano::state_block block3 (nano::dev_genesis_key.pub, block2.hash (), nano::dev_genesis_key.pub, nano::genesis_amount - nano::Gxrb_ratio - 2, nano::dev_genesis_key.pub, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *pool.generate (block2.hash ()));
|
||||
|
||||
auto code = [&block1, &block2, &block3](auto confirmation_height, nano::block_hash const & expected_cemented_frontier) {
|
||||
auto code = [&block1, &block2, &block3] (auto confirmation_height, nano::block_hash const & expected_cemented_frontier) {
|
||||
auto path (nano::unique_path ());
|
||||
nano::mdb_val value;
|
||||
{
|
||||
|
@ -1854,7 +1854,7 @@ TEST (mdb_block_store, upgrade_backup)
|
|||
fs::create_directory (dir);
|
||||
auto path = dir / "data.ldb";
|
||||
/** Returns 'dir' if backup file cannot be found */
|
||||
auto get_backup_path = [&dir]() {
|
||||
auto get_backup_path = [&dir] () {
|
||||
for (fs::directory_iterator itr (dir); itr != fs::directory_iterator (); ++itr)
|
||||
{
|
||||
if (itr->path ().filename ().string ().find ("data_backup_") != std::string::npos)
|
||||
|
|
|
@ -20,7 +20,7 @@ TEST (distributed_work, no_peers)
|
|||
nano::block_hash hash{ 1 };
|
||||
boost::optional<uint64_t> work;
|
||||
std::atomic<bool> done{ false };
|
||||
auto callback = [&work, &done](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&work, &done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
work = work_a;
|
||||
done = true;
|
||||
|
@ -54,7 +54,7 @@ TEST (distributed_work, no_peers_cancel)
|
|||
auto & node = *system.add_node (node_config);
|
||||
nano::block_hash hash{ 1 };
|
||||
bool done{ false };
|
||||
auto callback_to_cancel = [&done](boost::optional<uint64_t> work_a) {
|
||||
auto callback_to_cancel = [&done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_FALSE (work_a.is_initialized ());
|
||||
done = true;
|
||||
};
|
||||
|
@ -83,7 +83,7 @@ TEST (distributed_work, no_peers_multi)
|
|||
nano::block_hash hash{ 1 };
|
||||
unsigned total{ 10 };
|
||||
std::atomic<unsigned> count{ 0 };
|
||||
auto callback = [&count](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&count] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
++count;
|
||||
};
|
||||
|
@ -127,7 +127,7 @@ TEST (distributed_work, peer)
|
|||
nano::block_hash hash{ 1 };
|
||||
boost::optional<uint64_t> work;
|
||||
std::atomic<bool> done{ false };
|
||||
auto callback = [&work, &done](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&work, &done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
work = work_a;
|
||||
done = true;
|
||||
|
@ -153,7 +153,7 @@ TEST (distributed_work, peer_malicious)
|
|||
nano::block_hash hash{ 1 };
|
||||
boost::optional<uint64_t> work;
|
||||
std::atomic<bool> done{ false };
|
||||
auto callback = [&work, &done](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&work, &done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
work = work_a;
|
||||
done = true;
|
||||
|
@ -193,7 +193,7 @@ TEST (distributed_work, peer_multi)
|
|||
nano::block_hash hash{ 1 };
|
||||
boost::optional<uint64_t> work;
|
||||
std::atomic<bool> done{ false };
|
||||
auto callback = [&work, &done](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&work, &done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
work = work_a;
|
||||
done = true;
|
||||
|
@ -232,7 +232,7 @@ TEST (distributed_work, fail_resolve)
|
|||
nano::block_hash hash{ 1 };
|
||||
boost::optional<uint64_t> work;
|
||||
std::atomic<bool> done{ false };
|
||||
auto callback = [&work, &done](boost::optional<uint64_t> work_a) {
|
||||
auto callback = [&work, &done] (boost::optional<uint64_t> work_a) {
|
||||
ASSERT_TRUE (work_a.is_initialized ());
|
||||
work = work_a;
|
||||
done = true;
|
||||
|
|
|
@ -26,25 +26,25 @@ TEST (election, quorum_minimum_flip_success)
|
|||
nano::keypair key1;
|
||||
nano::block_builder builder;
|
||||
auto send1 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta ())
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta ())
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
node1.work_generate_blocking (*send1);
|
||||
nano::keypair key2;
|
||||
auto send2 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta ())
|
||||
.link (key2.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta ())
|
||||
.link (key2.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
node1.work_generate_blocking (*send2);
|
||||
node1.process_active (send1);
|
||||
node1.process_active (send2);
|
||||
|
@ -70,25 +70,25 @@ TEST (election, quorum_minimum_flip_fail)
|
|||
nano::keypair key1;
|
||||
nano::block_builder builder;
|
||||
auto send1 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta () - 1)
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta () - 1)
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
node1.work_generate_blocking (*send1);
|
||||
nano::keypair key2;
|
||||
auto send2 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta () - 1)
|
||||
.link (key2.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta () - 1)
|
||||
.link (key2.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
node1.work_generate_blocking (*send2);
|
||||
node1.process_active (send1);
|
||||
node1.process_active (send2);
|
||||
|
@ -114,14 +114,14 @@ TEST (election, quorum_minimum_confirm_success)
|
|||
nano::keypair key1;
|
||||
nano::block_builder builder;
|
||||
auto send1 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta ())
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta ())
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
node1.work_generate_blocking (*send1);
|
||||
node1.process_active (send1);
|
||||
node1.block_processor.flush ();
|
||||
|
@ -146,14 +146,14 @@ TEST (election, quorum_minimum_confirm_fail)
|
|||
nano::keypair key1;
|
||||
nano::block_builder builder;
|
||||
auto send1 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta () - 1)
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (node1.online_reps.delta () - 1)
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
node1.work_generate_blocking (*send1);
|
||||
node1.process_active (send1);
|
||||
node1.block_processor.flush ();
|
||||
|
@ -181,34 +181,34 @@ TEST (election, quorum_minimum_update_weight_before_quorum_checks)
|
|||
nano::keypair key1;
|
||||
nano::block_builder builder;
|
||||
auto send1 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (amount)
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (amount)
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build_shared ();
|
||||
node1.work_generate_blocking (*send1);
|
||||
auto open1 = builder.state ()
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (key1.pub)
|
||||
.balance (nano::genesis_amount - amount)
|
||||
.link (send1->hash ())
|
||||
.work (0)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.build_shared ();
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (key1.pub)
|
||||
.balance (nano::genesis_amount - amount)
|
||||
.link (send1->hash ())
|
||||
.work (0)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.build_shared ();
|
||||
nano::keypair key2;
|
||||
auto send2 = builder.state ()
|
||||
.account (key1.pub)
|
||||
.previous (open1->hash ())
|
||||
.representative (key1.pub)
|
||||
.balance (3)
|
||||
.link (key2.pub)
|
||||
.work (0)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.build_shared ();
|
||||
.account (key1.pub)
|
||||
.previous (open1->hash ())
|
||||
.representative (key1.pub)
|
||||
.balance (3)
|
||||
.link (key2.pub)
|
||||
.work (0)
|
||||
.sign (key1.prv, key1.pub)
|
||||
.build_shared ();
|
||||
node1.work_generate_blocking (*open1);
|
||||
node1.work_generate_blocking (*send2);
|
||||
node1.process_active (send1);
|
||||
|
|
|
@ -17,7 +17,7 @@ class fake_websocket_client
|
|||
{
|
||||
public:
|
||||
fake_websocket_client (unsigned port) :
|
||||
socket (std::make_shared<boost::beast::websocket::stream<boost::asio::ip::tcp::socket>> (ioc))
|
||||
socket (std::make_shared<boost::beast::websocket::stream<boost::asio::ip::tcp::socket>> (ioc))
|
||||
{
|
||||
std::string const host = "::1";
|
||||
boost::asio::ip::tcp::resolver resolver{ ioc };
|
||||
|
@ -31,7 +31,7 @@ public:
|
|||
{
|
||||
if (socket->is_open ())
|
||||
{
|
||||
socket->async_close (boost::beast::websocket::close_code::normal, [socket = this->socket](boost::beast::error_code const & ec) {
|
||||
socket->async_close (boost::beast::websocket::close_code::normal, [socket = this->socket] (boost::beast::error_code const & ec) {
|
||||
// A synchronous close usually hangs in tests when the server's io_context stops looping
|
||||
// An async_close solves this problem
|
||||
});
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
debug_assert (deadline > 0s);
|
||||
boost::optional<std::string> result;
|
||||
auto buffer (std::make_shared<boost::beast::flat_buffer> ());
|
||||
socket->async_read (*buffer, [&result, &buffer, socket = this->socket](boost::beast::error_code const & ec, std::size_t const /*n*/) {
|
||||
socket->async_read (*buffer, [&result, &buffer, socket = this->socket] (boost::beast::error_code const & ec, std::size_t const /*n*/) {
|
||||
if (!ec)
|
||||
{
|
||||
std::ostringstream res;
|
||||
|
|
|
@ -35,14 +35,14 @@ class work_peer_connection : public std::enable_shared_from_this<work_peer_conne
|
|||
const std::string generic_error = "Unable to parse JSON";
|
||||
|
||||
public:
|
||||
work_peer_connection (asio::io_context & ioc_a, work_peer_type const type_a, nano::work_version const version_a, nano::work_pool & pool_a, std::function<void(bool const)> on_generation_a, std::function<void()> on_cancel_a) :
|
||||
socket (ioc_a),
|
||||
type (type_a),
|
||||
version (version_a),
|
||||
work_pool (pool_a),
|
||||
on_generation (on_generation_a),
|
||||
on_cancel (on_cancel_a),
|
||||
timer (ioc_a)
|
||||
work_peer_connection (asio::io_context & ioc_a, work_peer_type const type_a, nano::work_version const version_a, nano::work_pool & pool_a, std::function<void (bool const)> on_generation_a, std::function<void ()> on_cancel_a) :
|
||||
socket (ioc_a),
|
||||
type (type_a),
|
||||
version (version_a),
|
||||
work_pool (pool_a),
|
||||
on_generation (on_generation_a),
|
||||
on_cancel (on_cancel_a),
|
||||
timer (ioc_a)
|
||||
{
|
||||
}
|
||||
void start ()
|
||||
|
@ -58,14 +58,14 @@ private:
|
|||
beast::flat_buffer buffer{ 8192 };
|
||||
http::request<http::string_body> request;
|
||||
http::response<http::dynamic_body> response;
|
||||
std::function<void(bool const)> on_generation;
|
||||
std::function<void()> on_cancel;
|
||||
std::function<void (bool const)> on_generation;
|
||||
std::function<void ()> on_cancel;
|
||||
asio::deadline_timer timer;
|
||||
|
||||
void read_request ()
|
||||
{
|
||||
auto this_l = shared_from_this ();
|
||||
http::async_read (socket, buffer, request, [this_l](beast::error_code ec, std::size_t const /*size_a*/) {
|
||||
http::async_read (socket, buffer, request, [this_l] (beast::error_code ec, std::size_t const /*size_a*/) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->process_request ();
|
||||
|
@ -110,7 +110,7 @@ private:
|
|||
{
|
||||
auto this_l = shared_from_this ();
|
||||
response.content_length (response.body ().size ());
|
||||
http::async_write (socket, response, [this_l](beast::error_code ec, std::size_t /*size_a*/) {
|
||||
http::async_write (socket, response, [this_l] (beast::error_code ec, std::size_t /*size_a*/) {
|
||||
this_l->socket.shutdown (tcp::socket::shutdown_send, ec);
|
||||
this_l->socket.close ();
|
||||
});
|
||||
|
@ -143,7 +143,7 @@ private:
|
|||
auto hash = hash_a;
|
||||
auto request_difficulty = nano::work_threshold_base (version);
|
||||
auto this_l (shared_from_this ());
|
||||
work_pool.generate (version, hash, request_difficulty, [this_l, hash](boost::optional<uint64_t> work_a) {
|
||||
work_pool.generate (version, hash, request_difficulty, [this_l, hash] (boost::optional<uint64_t> work_a) {
|
||||
auto result = work_a.value_or (0);
|
||||
auto result_difficulty (nano::work_difficulty (this_l->version, hash, result));
|
||||
static nano::network_params params;
|
||||
|
@ -157,7 +157,7 @@ private:
|
|||
beast::ostream (this_l->response.body ()) << ostream.str ();
|
||||
// Delay response by 500ms as a slow peer, immediate async call for a good peer
|
||||
this_l->timer.expires_from_now (boost::posix_time::milliseconds (this_l->type == work_peer_type::slow ? 500 : 0));
|
||||
this_l->timer.async_wait ([this_l, result](const boost::system::error_code & ec) {
|
||||
this_l->timer.async_wait ([this_l, result] (const boost::system::error_code & ec) {
|
||||
if (this_l->on_generation)
|
||||
{
|
||||
this_l->on_generation (result != 0);
|
||||
|
@ -200,12 +200,12 @@ class fake_work_peer : public std::enable_shared_from_this<fake_work_peer>
|
|||
public:
|
||||
fake_work_peer () = delete;
|
||||
fake_work_peer (nano::work_pool & pool_a, asio::io_context & ioc_a, unsigned short port_a, work_peer_type const type_a, nano::work_version const version_a = nano::work_version::work_1) :
|
||||
pool (pool_a),
|
||||
endpoint (tcp::v4 (), port_a),
|
||||
ioc (ioc_a),
|
||||
acceptor (ioc_a, endpoint),
|
||||
type (type_a),
|
||||
version (version_a)
|
||||
pool (pool_a),
|
||||
endpoint (tcp::v4 (), port_a),
|
||||
ioc (ioc_a),
|
||||
acceptor (ioc_a, endpoint),
|
||||
type (type_a),
|
||||
version (version_a)
|
||||
{
|
||||
}
|
||||
void start ()
|
||||
|
@ -226,7 +226,7 @@ private:
|
|||
std::weak_ptr<fake_work_peer> this_w (shared_from_this ());
|
||||
auto connection (std::make_shared<work_peer_connection> (
|
||||
ioc, type, version, pool,
|
||||
[this_w](bool const good_generation) {
|
||||
[this_w] (bool const good_generation) {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
if (good_generation)
|
||||
|
@ -239,13 +239,13 @@ private:
|
|||
}
|
||||
};
|
||||
},
|
||||
[this_w]() {
|
||||
[this_w] () {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
++this_l->cancels;
|
||||
}
|
||||
}));
|
||||
acceptor.async_accept (connection->socket, [connection, this_w](beast::error_code ec) {
|
||||
acceptor.async_accept (connection->socket, [connection, this_w] (beast::error_code ec) {
|
||||
if (!ec)
|
||||
{
|
||||
if (auto this_l = this_w.lock ())
|
||||
|
|
|
@ -69,8 +69,8 @@ TEST (frontiers_confirmation, prioritize_frontiers)
|
|||
|
||||
auto transaction = node->store.tx_begin_read ();
|
||||
constexpr auto num_accounts = 5;
|
||||
auto priority_orders_match = [](auto const & cementable_frontiers, auto const & desired_order) {
|
||||
return std::equal (desired_order.begin (), desired_order.end (), cementable_frontiers.template get<1> ().begin (), cementable_frontiers.template get<1> ().end (), [](nano::account const & account, nano::cementable_account const & cementable_account) {
|
||||
auto priority_orders_match = [] (auto const & cementable_frontiers, auto const & desired_order) {
|
||||
return std::equal (desired_order.begin (), desired_order.end (), cementable_frontiers.template get<1> ().begin (), cementable_frontiers.template get<1> ().end (), [] (nano::account const & account, nano::cementable_account const & cementable_account) {
|
||||
return (account == cementable_account.account);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -29,17 +29,17 @@ TEST (ipc, asynchronous)
|
|||
auto req (nano::ipc::prepare_request (nano::ipc::payload_encoding::json_v1, std::string (R"({"action": "block_count"})")));
|
||||
auto res (std::make_shared<std::vector<uint8_t>> ());
|
||||
std::atomic<bool> call_completed{ false };
|
||||
client.async_connect ("::1", 24077, [&client, &req, &res, &call_completed](nano::error err) {
|
||||
client.async_write (req, [&client, &req, &res, &call_completed](nano::error err_a, size_t size_a) {
|
||||
client.async_connect ("::1", 24077, [&client, &req, &res, &call_completed] (nano::error err) {
|
||||
client.async_write (req, [&client, &req, &res, &call_completed] (nano::error err_a, size_t size_a) {
|
||||
ASSERT_NO_ERROR (static_cast<std::error_code> (err_a));
|
||||
ASSERT_EQ (size_a, req.size ());
|
||||
// Read length
|
||||
client.async_read (res, sizeof (uint32_t), [&client, &res, &call_completed](nano::error err_read_a, size_t size_read_a) {
|
||||
client.async_read (res, sizeof (uint32_t), [&client, &res, &call_completed] (nano::error err_read_a, size_t size_read_a) {
|
||||
ASSERT_NO_ERROR (static_cast<std::error_code> (err_read_a));
|
||||
ASSERT_EQ (size_read_a, sizeof (uint32_t));
|
||||
uint32_t payload_size_l = boost::endian::big_to_native (*reinterpret_cast<uint32_t *> (res->data ()));
|
||||
// Read json payload
|
||||
client.async_read (res, payload_size_l, [&res, &call_completed](nano::error err_read_a, size_t size_read_a) {
|
||||
client.async_read (res, payload_size_l, [&res, &call_completed] (nano::error err_read_a, size_t size_read_a) {
|
||||
std::string payload (res->begin (), res->end ());
|
||||
std::stringstream ss;
|
||||
ss << payload;
|
||||
|
@ -68,7 +68,7 @@ TEST (ipc, synchronous)
|
|||
|
||||
// Start blocking IPC client in a separate thread
|
||||
std::atomic<bool> call_completed{ false };
|
||||
std::thread client_thread ([&client, &call_completed]() {
|
||||
std::thread client_thread ([&client, &call_completed] () {
|
||||
client.connect ("::1", 24077);
|
||||
std::string response (nano::ipc::request (nano::ipc::payload_encoding::json_v1, client, std::string (R"({"action": "block_count"})")));
|
||||
std::stringstream ss;
|
||||
|
|
|
@ -843,14 +843,14 @@ TEST (votes, add_existing)
|
|||
nano::keypair key1;
|
||||
nano::block_builder builder;
|
||||
std::shared_ptr<nano::block> send1 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub) // No representative, blocks can't confirm
|
||||
.balance (nano::genesis_amount / 2 - nano::Gxrb_ratio)
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub) // No representative, blocks can't confirm
|
||||
.balance (nano::genesis_amount / 2 - nano::Gxrb_ratio)
|
||||
.link (key1.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build ();
|
||||
node1.work_generate_blocking (*send1);
|
||||
ASSERT_EQ (nano::process_result::progress, node1.ledger.process (node1.store.tx_begin_write (), *send1).code);
|
||||
auto election1 = node1.active.insert (send1);
|
||||
|
@ -861,14 +861,14 @@ TEST (votes, add_existing)
|
|||
ASSERT_EQ (1, election1.election->last_votes[nano::dev_genesis_key.pub].timestamp);
|
||||
nano::keypair key2;
|
||||
std::shared_ptr<nano::block> send2 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub) // No representative, blocks can't confirm
|
||||
.balance (nano::genesis_amount / 2 - nano::Gxrb_ratio)
|
||||
.link (key2.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub) // No representative, blocks can't confirm
|
||||
.balance (nano::genesis_amount / 2 - nano::Gxrb_ratio)
|
||||
.link (key2.pub)
|
||||
.work (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.build ();
|
||||
node1.work_generate_blocking (*send2);
|
||||
auto vote2 (std::make_shared<nano::vote> (nano::dev_genesis_key.pub, nano::dev_genesis_key.prv, 2, send2));
|
||||
// Pretend we've waited the timeout
|
||||
|
@ -2637,14 +2637,14 @@ TEST (ledger, epoch_open_pending)
|
|||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
auto epoch_open = builder.state ()
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (0)
|
||||
.balance (0)
|
||||
.link (node1.ledger.epoch_link (nano::epoch::epoch_1))
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (key1.pub))
|
||||
.build_shared ();
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (0)
|
||||
.balance (0)
|
||||
.link (node1.ledger.epoch_link (nano::epoch::epoch_1))
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (key1.pub))
|
||||
.build_shared ();
|
||||
auto process_result (node1.ledger.process (node1.store.tx_begin_write (), *epoch_open));
|
||||
ASSERT_EQ (nano::process_result::gap_epoch_open_pending, process_result.code);
|
||||
ASSERT_EQ (nano::signature_verification::valid_epoch, process_result.verified);
|
||||
|
@ -2658,14 +2658,14 @@ TEST (ledger, epoch_open_pending)
|
|||
ASSERT_EQ (blocks[0].verified, nano::signature_verification::valid_epoch);
|
||||
// New block to process epoch open
|
||||
auto send1 = builder.state ()
|
||||
.account (nano::genesis_account)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
.account (nano::genesis_account)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
node1.block_processor.add (send1);
|
||||
node1.block_processor.flush ();
|
||||
ASSERT_TRUE (node1.ledger.block_exists (epoch_open->hash ()));
|
||||
|
@ -2686,24 +2686,24 @@ TEST (ledger, block_hash_account_conflict)
|
|||
* in the ledger and not an account
|
||||
*/
|
||||
auto send1 = builder.state ()
|
||||
.account (nano::genesis_account)
|
||||
.previous (genesis.hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (genesis.hash ()))
|
||||
.build_shared ();
|
||||
.account (nano::genesis_account)
|
||||
.previous (genesis.hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (genesis.hash ()))
|
||||
.build_shared ();
|
||||
|
||||
auto receive1 = builder.state ()
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (100)
|
||||
.link (send1->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*pool.generate (key1.pub))
|
||||
.build_shared ();
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (100)
|
||||
.link (send1->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*pool.generate (key1.pub))
|
||||
.build_shared ();
|
||||
|
||||
/*
|
||||
* Note that the below link is a block hash when this is intended
|
||||
|
@ -2712,28 +2712,28 @@ TEST (ledger, block_hash_account_conflict)
|
|||
* for arbitrary accounts.
|
||||
*/
|
||||
auto send2 = builder.state ()
|
||||
.account (key1.pub)
|
||||
.previous (receive1->hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (90)
|
||||
.link (receive1->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*pool.generate (receive1->hash ()))
|
||||
.build_shared ();
|
||||
.account (key1.pub)
|
||||
.previous (receive1->hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (90)
|
||||
.link (receive1->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*pool.generate (receive1->hash ()))
|
||||
.build_shared ();
|
||||
|
||||
/*
|
||||
* Generate an epoch open for the account with the same value as the block hash
|
||||
*/
|
||||
auto receive1_hash = receive1->hash ();
|
||||
auto open_epoch1 = builder.state ()
|
||||
.account (reinterpret_cast<nano::account const &> (receive1_hash))
|
||||
.previous (0)
|
||||
.representative (0)
|
||||
.balance (0)
|
||||
.link (node1.ledger.epoch_link (nano::epoch::epoch_1))
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (receive1->hash ()))
|
||||
.build_shared ();
|
||||
.account (reinterpret_cast<nano::account const &> (receive1_hash))
|
||||
.previous (0)
|
||||
.representative (0)
|
||||
.balance (0)
|
||||
.link (node1.ledger.epoch_link (nano::epoch::epoch_1))
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (receive1->hash ()))
|
||||
.build_shared ();
|
||||
|
||||
node1.work_generate_blocking (*send1);
|
||||
node1.work_generate_blocking (*receive1);
|
||||
|
@ -3040,27 +3040,27 @@ TEST (ledger, zero_rep)
|
|||
nano::genesis genesis;
|
||||
nano::block_builder builder;
|
||||
auto block1 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (genesis.hash ())
|
||||
.representative (0)
|
||||
.balance (nano::genesis_amount)
|
||||
.link (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (genesis.hash ()))
|
||||
.build ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (genesis.hash ())
|
||||
.representative (0)
|
||||
.balance (nano::genesis_amount)
|
||||
.link (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (genesis.hash ()))
|
||||
.build ();
|
||||
auto transaction (node1.store.tx_begin_write ());
|
||||
ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, *block1).code);
|
||||
ASSERT_EQ (0, node1.ledger.cache.rep_weights.representation_get (nano::dev_genesis_key.pub));
|
||||
ASSERT_EQ (nano::genesis_amount, node1.ledger.cache.rep_weights.representation_get (0));
|
||||
auto block2 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (block1->hash ())
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount)
|
||||
.link (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (block1->hash ()))
|
||||
.build ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (block1->hash ())
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount)
|
||||
.link (0)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (block1->hash ()))
|
||||
.build ();
|
||||
ASSERT_EQ (nano::process_result::progress, node1.ledger.process (transaction, *block2).code);
|
||||
ASSERT_EQ (nano::genesis_amount, node1.ledger.cache.rep_weights.representation_get (nano::dev_genesis_key.pub));
|
||||
ASSERT_EQ (0, node1.ledger.cache.rep_weights.representation_get (0));
|
||||
|
@ -3081,7 +3081,7 @@ TEST (ledger, work_validation)
|
|||
nano::keypair key;
|
||||
|
||||
// With random work the block doesn't pass, then modifies the block with sufficient work and ensures a correct result
|
||||
auto process_block = [&store, &ledger, &pool](nano::block & block_a, nano::block_details const details_a) {
|
||||
auto process_block = [&store, &ledger, &pool] (nano::block & block_a, nano::block_details const details_a) {
|
||||
auto threshold = nano::work_threshold (block_a.work_version (), details_a);
|
||||
// Rarely failed with random work, so modify until it doesn't have enough difficulty
|
||||
while (block_a.difficulty () >= threshold)
|
||||
|
@ -3096,59 +3096,59 @@ TEST (ledger, work_validation)
|
|||
std::error_code ec;
|
||||
|
||||
auto send = *builder.send ()
|
||||
.previous (nano::genesis_hash)
|
||||
.destination (gen.pub)
|
||||
.balance (nano::genesis_amount - 1)
|
||||
.sign (gen.prv, gen.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
.previous (nano::genesis_hash)
|
||||
.destination (gen.pub)
|
||||
.balance (nano::genesis_amount - 1)
|
||||
.sign (gen.prv, gen.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
ASSERT_FALSE (ec);
|
||||
|
||||
auto receive = *builder.receive ()
|
||||
.previous (send.hash ())
|
||||
.source (send.hash ())
|
||||
.sign (gen.prv, gen.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
.previous (send.hash ())
|
||||
.source (send.hash ())
|
||||
.sign (gen.prv, gen.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
ASSERT_FALSE (ec);
|
||||
|
||||
auto change = *builder.change ()
|
||||
.previous (receive.hash ())
|
||||
.representative (key.pub)
|
||||
.sign (gen.prv, gen.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
.previous (receive.hash ())
|
||||
.representative (key.pub)
|
||||
.sign (gen.prv, gen.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
ASSERT_FALSE (ec);
|
||||
|
||||
auto state = *builder.state ()
|
||||
.account (gen.pub)
|
||||
.previous (change.hash ())
|
||||
.representative (gen.pub)
|
||||
.balance (nano::genesis_amount - 1)
|
||||
.link (key.pub)
|
||||
.sign (gen.prv, gen.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
.account (gen.pub)
|
||||
.previous (change.hash ())
|
||||
.representative (gen.pub)
|
||||
.balance (nano::genesis_amount - 1)
|
||||
.link (key.pub)
|
||||
.sign (gen.prv, gen.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
ASSERT_FALSE (ec);
|
||||
|
||||
auto open = *builder.open ()
|
||||
.account (key.pub)
|
||||
.source (state.hash ())
|
||||
.representative (key.pub)
|
||||
.sign (key.prv, key.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
.account (key.pub)
|
||||
.source (state.hash ())
|
||||
.representative (key.pub)
|
||||
.sign (key.prv, key.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
ASSERT_FALSE (ec);
|
||||
|
||||
auto epoch = *builder.state ()
|
||||
.account (key.pub)
|
||||
.previous (open.hash ())
|
||||
.balance (1)
|
||||
.representative (key.pub)
|
||||
.link (ledger.epoch_link (nano::epoch::epoch_1))
|
||||
.sign (gen.prv, gen.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
.account (key.pub)
|
||||
.previous (open.hash ())
|
||||
.balance (1)
|
||||
.representative (key.pub)
|
||||
.link (ledger.epoch_link (nano::epoch::epoch_1))
|
||||
.sign (gen.prv, gen.pub)
|
||||
.work (0)
|
||||
.build (ec);
|
||||
ASSERT_FALSE (ec);
|
||||
|
||||
process_block (send, {});
|
||||
|
@ -3174,36 +3174,36 @@ TEST (ledger, dependents_confirmed)
|
|||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
auto send1 = builder.state ()
|
||||
.account (nano::genesis_account)
|
||||
.previous (genesis.hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (genesis.hash ()))
|
||||
.build_shared ();
|
||||
.account (nano::genesis_account)
|
||||
.previous (genesis.hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (genesis.hash ()))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send1).code);
|
||||
ASSERT_TRUE (ledger.dependents_confirmed (transaction, *send1));
|
||||
auto send2 = builder.state ()
|
||||
.account (nano::genesis_account)
|
||||
.previous (send1->hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 200)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (send1->hash ()))
|
||||
.build_shared ();
|
||||
.account (nano::genesis_account)
|
||||
.previous (send1->hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 200)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (send1->hash ()))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send2).code);
|
||||
ASSERT_FALSE (ledger.dependents_confirmed (transaction, *send2));
|
||||
auto receive1 = builder.state ()
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (100)
|
||||
.link (send1->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*pool.generate (key1.pub))
|
||||
.build_shared ();
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (100)
|
||||
.link (send1->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*pool.generate (key1.pub))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *receive1).code);
|
||||
ASSERT_FALSE (ledger.dependents_confirmed (transaction, *receive1));
|
||||
nano::confirmation_height_info height;
|
||||
|
@ -3212,14 +3212,14 @@ TEST (ledger, dependents_confirmed)
|
|||
ledger.store.confirmation_height_put (transaction, nano::genesis_account, height);
|
||||
ASSERT_TRUE (ledger.dependents_confirmed (transaction, *receive1));
|
||||
auto receive2 = builder.state ()
|
||||
.account (key1.pub)
|
||||
.previous (receive1->hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (200)
|
||||
.link (send2->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*pool.generate (receive1->hash ()))
|
||||
.build_shared ();
|
||||
.account (key1.pub)
|
||||
.previous (receive1->hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (200)
|
||||
.link (send2->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*pool.generate (receive1->hash ()))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *receive2).code);
|
||||
ASSERT_FALSE (ledger.dependents_confirmed (transaction, *receive2));
|
||||
ASSERT_TRUE (ledger.store.confirmation_height_get (transaction, key1.pub, height));
|
||||
|
@ -3247,14 +3247,14 @@ TEST (ledger, block_confirmed)
|
|||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
nano::keypair key1;
|
||||
auto send1 = builder.state ()
|
||||
.account (nano::genesis_account)
|
||||
.previous (genesis.hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (genesis.hash ()))
|
||||
.build ();
|
||||
.account (nano::genesis_account)
|
||||
.previous (genesis.hash ())
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (genesis.hash ()))
|
||||
.build ();
|
||||
// Must be safe against non-existing blocks
|
||||
ASSERT_FALSE (ledger.block_confirmed (transaction, send1->hash ()));
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send1).code);
|
||||
|
@ -3289,7 +3289,7 @@ TEST (ledger, cache)
|
|||
auto genesis_weight = nano::genesis_amount - i;
|
||||
auto pruned_count = i;
|
||||
|
||||
auto cache_check = [&, i](nano::ledger_cache const & cache_a) {
|
||||
auto cache_check = [&, i] (nano::ledger_cache const & cache_a) {
|
||||
ASSERT_EQ (account_count, cache_a.account_count);
|
||||
ASSERT_EQ (block_count, cache_a.block_count);
|
||||
ASSERT_EQ (cemented_count, cache_a.cemented_count);
|
||||
|
@ -3300,23 +3300,23 @@ TEST (ledger, cache)
|
|||
nano::keypair key;
|
||||
auto const latest = ledger.latest (store->tx_begin_read (), nano::genesis_account);
|
||||
auto send = builder.state ()
|
||||
.account (nano::genesis_account)
|
||||
.previous (latest)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - (i + 1))
|
||||
.link (key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (latest))
|
||||
.build ();
|
||||
.account (nano::genesis_account)
|
||||
.previous (latest)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - (i + 1))
|
||||
.link (key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (latest))
|
||||
.build ();
|
||||
auto open = builder.state ()
|
||||
.account (key.pub)
|
||||
.previous (0)
|
||||
.representative (key.pub)
|
||||
.balance (1)
|
||||
.link (send->hash ())
|
||||
.sign (key.prv, key.pub)
|
||||
.work (*pool.generate (key.pub))
|
||||
.build ();
|
||||
.account (key.pub)
|
||||
.previous (0)
|
||||
.representative (key.pub)
|
||||
.balance (1)
|
||||
.link (send->hash ())
|
||||
.sign (key.prv, key.pub)
|
||||
.work (*pool.generate (key.pub))
|
||||
.build ();
|
||||
{
|
||||
auto transaction (store->tx_begin_write ());
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (transaction, *send).code);
|
||||
|
@ -3778,14 +3778,14 @@ TEST (ledger, migrate_lmdb_to_rocksdb)
|
|||
nano::work_pool pool (std::numeric_limits<unsigned>::max ());
|
||||
|
||||
auto send = nano::state_block_builder ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (0)
|
||||
.link (nano::account (10))
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (0)
|
||||
.link (nano::account (10))
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
|
||||
nano::endpoint_key endpoint_key (address.to_bytes (), port);
|
||||
auto version = 99;
|
||||
|
@ -3865,14 +3865,14 @@ TEST (ledger, unconfirmed_frontiers)
|
|||
nano::keypair key;
|
||||
auto const latest = ledger.latest (store->tx_begin_read (), nano::genesis_account);
|
||||
auto send = builder.make_block ()
|
||||
.account (nano::genesis_account)
|
||||
.previous (latest)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.link (key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (latest))
|
||||
.build ();
|
||||
.account (nano::genesis_account)
|
||||
.previous (latest)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - 100)
|
||||
.link (key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*pool.generate (latest))
|
||||
.build ();
|
||||
|
||||
ASSERT_EQ (nano::process_result::progress, ledger.process (store->tx_begin_write (), *send).code);
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ TEST (locks, condition_variable_wait_until)
|
|||
|
||||
nano::condition_variable cv;
|
||||
nano::mutex mutex;
|
||||
auto impl = [&](auto time_to_sleep) {
|
||||
auto impl = [&] (auto time_to_sleep) {
|
||||
std::atomic<bool> notified{ false };
|
||||
std::atomic<bool> finished{ false };
|
||||
nano::unique_lock<nano::mutex> lk (mutex);
|
||||
|
|
|
@ -17,7 +17,7 @@ public:
|
|||
using value_type = T;
|
||||
|
||||
explicit record_allocations_new_delete_allocator (std::vector<size_t> * allocated) :
|
||||
allocated (allocated)
|
||||
allocated (allocated)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ TEST (network, tcp_connection)
|
|||
std::atomic<bool> done1 (false);
|
||||
std::string message1;
|
||||
acceptor.async_accept (incoming,
|
||||
[&done1, &message1](boost::system::error_code const & ec_a) {
|
||||
[&done1, &message1] (boost::system::error_code const & ec_a) {
|
||||
if (ec_a)
|
||||
{
|
||||
message1 = ec_a.message ();
|
||||
|
@ -36,7 +36,7 @@ TEST (network, tcp_connection)
|
|||
std::atomic<bool> done2 (false);
|
||||
std::string message2;
|
||||
connector.async_connect (boost::asio::ip::tcp::endpoint (boost::asio::ip::address_v4::loopback (), port),
|
||||
[&done2, &message2](boost::system::error_code const & ec_a) {
|
||||
[&done2, &message2] (boost::system::error_code const & ec_a) {
|
||||
if (ec_a)
|
||||
{
|
||||
message2 = ec_a.message ();
|
||||
|
@ -283,7 +283,7 @@ TEST (network, send_insufficient_work_udp)
|
|||
auto block (std::make_shared<nano::send_block> (0, 1, 20, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, 0));
|
||||
nano::publish publish (block);
|
||||
nano::transport::channel_udp channel (node1.network.udp_channels, node2.network.endpoint (), node1.network_params.protocol.protocol_version);
|
||||
channel.send (publish, [](boost::system::error_code const & ec, size_t size) {});
|
||||
channel.send (publish, [] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_EQ (0, node1.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work) != 0);
|
||||
ASSERT_EQ (1, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
|
@ -298,27 +298,27 @@ TEST (network, send_insufficient_work)
|
|||
auto block1 (std::make_shared<nano::send_block> (0, 1, 20, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, 0));
|
||||
nano::publish publish1 (block1);
|
||||
auto tcp_channel (node1.network.tcp_channels.find_channel (nano::transport::map_endpoint_to_tcp (node2.network.endpoint ())));
|
||||
tcp_channel->send (publish1, [](boost::system::error_code const & ec, size_t size) {});
|
||||
tcp_channel->send (publish1, [] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_EQ (0, node1.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work) != 0);
|
||||
ASSERT_EQ (1, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
// Legacy block work between epoch_2_recieve & epoch_1
|
||||
auto block2 (std::make_shared<nano::send_block> (block1->hash (), 1, 20, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, system.work_generate_limited (block1->hash (), node1.network_params.network.publish_thresholds.epoch_2_receive, node1.network_params.network.publish_thresholds.epoch_1 - 1)));
|
||||
nano::publish publish2 (block2);
|
||||
tcp_channel->send (publish2, [](boost::system::error_code const & ec, size_t size) {});
|
||||
tcp_channel->send (publish2, [] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work) != 1);
|
||||
ASSERT_EQ (2, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
// Legacy block work epoch_1
|
||||
auto block3 (std::make_shared<nano::send_block> (block2->hash (), 1, 20, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *system.work.generate (block2->hash (), node1.network_params.network.publish_thresholds.epoch_2)));
|
||||
nano::publish publish3 (block3);
|
||||
tcp_channel->send (publish3, [](boost::system::error_code const & ec, size_t size) {});
|
||||
tcp_channel->send (publish3, [] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_EQ (0, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in));
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) != 0);
|
||||
ASSERT_EQ (1, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in));
|
||||
// State block work epoch_2_recieve
|
||||
auto block4 (std::make_shared<nano::state_block> (nano::dev_genesis_key.pub, block1->hash (), nano::dev_genesis_key.pub, 20, 1, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, system.work_generate_limited (block1->hash (), node1.network_params.network.publish_thresholds.epoch_2_receive, node1.network_params.network.publish_thresholds.epoch_1 - 1)));
|
||||
nano::publish publish4 (block4);
|
||||
tcp_channel->send (publish4, [](boost::system::error_code const & ec, size_t size) {});
|
||||
tcp_channel->send (publish4, [] (boost::system::error_code const & ec, size_t size) {});
|
||||
ASSERT_TIMELY (10s, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in) != 0);
|
||||
ASSERT_EQ (1, node2.stats.count (nano::stat::type::message, nano::stat::detail::publish, nano::stat::dir::in));
|
||||
ASSERT_EQ (2, node2.stats.count (nano::stat::type::error, nano::stat::detail::insufficient_work));
|
||||
|
@ -405,7 +405,7 @@ TEST (network, receive_weight_change)
|
|||
system.wallet (1)->store.representative_set (transaction, key2.pub);
|
||||
}
|
||||
ASSERT_NE (nullptr, system.wallet (0)->send_action (nano::dev_genesis_key.pub, key2.pub, system.nodes[0]->config.receive_minimum.number ()));
|
||||
ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&](std::shared_ptr<nano::node> const & node_a) { return node_a->weight (key2.pub) == system.nodes[0]->config.receive_minimum.number (); }));
|
||||
ASSERT_TIMELY (10s, std::all_of (system.nodes.begin (), system.nodes.end (), [&] (std::shared_ptr<nano::node> const & node_a) { return node_a->weight (key2.pub) == system.nodes[0]->config.receive_minimum.number (); }));
|
||||
}
|
||||
|
||||
TEST (parse_endpoint, valid)
|
||||
|
@ -496,7 +496,7 @@ TEST (network, ipv6_bind_send_ipv4)
|
|||
auto finish1 (false);
|
||||
nano::endpoint endpoint3;
|
||||
boost::asio::ip::udp::socket socket1 (io_ctx, endpoint1);
|
||||
socket1.async_receive_from (boost::asio::buffer (bytes1.data (), bytes1.size ()), endpoint3, [&finish1](boost::system::error_code const & error, size_t size_a) {
|
||||
socket1.async_receive_from (boost::asio::buffer (bytes1.data (), bytes1.size ()), endpoint3, [&finish1] (boost::system::error_code const & error, size_t size_a) {
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_EQ (16, size_a);
|
||||
finish1 = true;
|
||||
|
@ -504,7 +504,7 @@ TEST (network, ipv6_bind_send_ipv4)
|
|||
boost::asio::ip::udp::socket socket2 (io_ctx, endpoint2);
|
||||
nano::endpoint endpoint5 (boost::asio::ip::address_v4::loopback (), port1);
|
||||
nano::endpoint endpoint6 (boost::asio::ip::address_v6::v4_mapped (boost::asio::ip::address_v4::loopback ()), port2);
|
||||
socket2.async_send_to (boost::asio::buffer (std::array<uint8_t, 16>{}, 16), endpoint5, [](boost::system::error_code const & error, size_t size_a) {
|
||||
socket2.async_send_to (boost::asio::buffer (std::array<uint8_t, 16>{}, 16), endpoint5, [] (boost::system::error_code const & error, size_t size_a) {
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_EQ (16, size_a);
|
||||
});
|
||||
|
@ -518,11 +518,11 @@ TEST (network, ipv6_bind_send_ipv4)
|
|||
ASSERT_EQ (endpoint6, endpoint3);
|
||||
std::array<uint8_t, 16> bytes2;
|
||||
nano::endpoint endpoint4;
|
||||
socket2.async_receive_from (boost::asio::buffer (bytes2.data (), bytes2.size ()), endpoint4, [](boost::system::error_code const & error, size_t size_a) {
|
||||
socket2.async_receive_from (boost::asio::buffer (bytes2.data (), bytes2.size ()), endpoint4, [] (boost::system::error_code const & error, size_t size_a) {
|
||||
ASSERT_FALSE (!error);
|
||||
ASSERT_EQ (16, size_a);
|
||||
});
|
||||
socket1.async_send_to (boost::asio::buffer (std::array<uint8_t, 16>{}, 16), endpoint6, [](boost::system::error_code const & error, size_t size_a) {
|
||||
socket1.async_send_to (boost::asio::buffer (std::array<uint8_t, 16>{}, 16), endpoint6, [] (boost::system::error_code const & error, size_t size_a) {
|
||||
ASSERT_FALSE (error);
|
||||
ASSERT_EQ (16, size_a);
|
||||
});
|
||||
|
@ -635,7 +635,7 @@ TEST (message_buffer_manager, one_buffer_multithreaded)
|
|||
{
|
||||
nano::stat stats;
|
||||
nano::message_buffer_manager buffer (stats, 512, 1);
|
||||
boost::thread thread ([&buffer]() {
|
||||
boost::thread thread ([&buffer] () {
|
||||
auto done (false);
|
||||
while (!done)
|
||||
{
|
||||
|
@ -663,7 +663,7 @@ TEST (message_buffer_manager, many_buffers_multithreaded)
|
|||
std::vector<boost::thread> threads;
|
||||
for (auto i (0); i < 4; ++i)
|
||||
{
|
||||
threads.push_back (boost::thread ([&buffer]() {
|
||||
threads.push_back (boost::thread ([&buffer] () {
|
||||
auto done (false);
|
||||
while (!done)
|
||||
{
|
||||
|
@ -679,7 +679,7 @@ TEST (message_buffer_manager, many_buffers_multithreaded)
|
|||
std::atomic_int count (0);
|
||||
for (auto i (0); i < 4; ++i)
|
||||
{
|
||||
threads.push_back (boost::thread ([&buffer, &count]() {
|
||||
threads.push_back (boost::thread ([&buffer, &count] () {
|
||||
auto done (false);
|
||||
for (auto i (0); !done && i < 1000; ++i)
|
||||
{
|
||||
|
@ -723,9 +723,9 @@ TEST (tcp_listener, tcp_node_id_handshake)
|
|||
nano::node_id_handshake node_id_handshake (cookie, boost::none);
|
||||
auto input (node_id_handshake.to_shared_const_buffer ());
|
||||
std::atomic<bool> write_done (false);
|
||||
socket->async_connect (bootstrap_endpoint, [&input, socket, &write_done](boost::system::error_code const & ec) {
|
||||
socket->async_connect (bootstrap_endpoint, [&input, socket, &write_done] (boost::system::error_code const & ec) {
|
||||
ASSERT_FALSE (ec);
|
||||
socket->async_write (input, [&input, &write_done](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_write (input, [&input, &write_done] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
ASSERT_EQ (input.size (), size_a);
|
||||
write_done = true;
|
||||
|
@ -738,7 +738,7 @@ TEST (tcp_listener, tcp_node_id_handshake)
|
|||
nano::node_id_handshake node_id_handshake_response (boost::none, response_zero);
|
||||
auto output (node_id_handshake_response.to_bytes ());
|
||||
std::atomic<bool> done (false);
|
||||
socket->async_read (output, output->size (), [&output, &done](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (output, output->size (), [&output, &done] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
ASSERT_EQ (output->size (), size_a);
|
||||
done = true;
|
||||
|
@ -752,7 +752,7 @@ TEST (tcp_listener, tcp_listener_timeout_empty)
|
|||
auto node0 (system.nodes[0]);
|
||||
auto socket (std::make_shared<nano::socket> (*node0));
|
||||
std::atomic<bool> connected (false);
|
||||
socket->async_connect (node0->bootstrap.endpoint (), [&connected](boost::system::error_code const & ec) {
|
||||
socket->async_connect (node0->bootstrap.endpoint (), [&connected] (boost::system::error_code const & ec) {
|
||||
ASSERT_FALSE (ec);
|
||||
connected = true;
|
||||
});
|
||||
|
@ -777,9 +777,9 @@ TEST (tcp_listener, tcp_listener_timeout_node_id_handshake)
|
|||
auto cookie (node0->network.syn_cookies.assign (nano::transport::map_tcp_to_endpoint (node0->bootstrap.endpoint ())));
|
||||
nano::node_id_handshake node_id_handshake (cookie, boost::none);
|
||||
auto input (node_id_handshake.to_shared_const_buffer ());
|
||||
socket->async_connect (node0->bootstrap.endpoint (), [&input, socket](boost::system::error_code const & ec) {
|
||||
socket->async_connect (node0->bootstrap.endpoint (), [&input, socket] (boost::system::error_code const & ec) {
|
||||
ASSERT_FALSE (ec);
|
||||
socket->async_write (input, [&input](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_write (input, [&input] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
ASSERT_EQ (input.size (), size_a);
|
||||
});
|
||||
|
@ -818,7 +818,7 @@ TEST (network, replace_port)
|
|||
auto wrong_endpoint = nano::endpoint (node1->network.endpoint ().address (), nano::get_available_port ());
|
||||
auto channel0 (node0->network.udp_channels.insert (wrong_endpoint, node1->network_params.protocol.protocol_version));
|
||||
ASSERT_NE (nullptr, channel0);
|
||||
node0->network.udp_channels.modify (channel0, [&node1](std::shared_ptr<nano::transport::channel> const & channel_a) {
|
||||
node0->network.udp_channels.modify (channel0, [&node1] (std::shared_ptr<nano::transport::channel> const & channel_a) {
|
||||
channel_a->set_node_id (node1->node_id.pub);
|
||||
});
|
||||
auto peers_list (node0->network.list (std::numeric_limits<size_t>::max ()));
|
||||
|
@ -960,7 +960,7 @@ TEST (peer_exclusion, validate)
|
|||
nano::tcp_endpoint oldest (boost::asio::ip::address_v6::v4_mapped (boost::asio::ip::address_v4 (0x0)), 0);
|
||||
ASSERT_EQ (peers_by_endpoint.end (), peers_by_endpoint.find (oldest.address ()));
|
||||
|
||||
auto to_seconds = [](std::chrono::steady_clock::time_point const & timepoint) {
|
||||
auto to_seconds = [] (std::chrono::steady_clock::time_point const & timepoint) {
|
||||
return static_cast<double> (std::chrono::duration_cast<std::chrono::seconds> (timepoint.time_since_epoch ()).count ());
|
||||
};
|
||||
nano::tcp_endpoint first (boost::asio::ip::address_v6::v4_mapped (boost::asio::ip::address_v4 (0x1)), 0);
|
||||
|
@ -1117,7 +1117,7 @@ TEST (network, cleanup_purge)
|
|||
ASSERT_EQ (0, node1.network.size ());
|
||||
|
||||
std::weak_ptr<nano::node> node_w = node1.shared ();
|
||||
node1.network.tcp_channels.start_tcp (node2->network.endpoint (), [node_w](std::shared_ptr<nano::transport::channel> const & channel_a) {
|
||||
node1.network.tcp_channels.start_tcp (node2->network.endpoint (), [node_w] (std::shared_ptr<nano::transport::channel> const & channel_a) {
|
||||
if (auto node_l = node_w.lock ())
|
||||
{
|
||||
node_l->network.send_keepalive (channel_a);
|
||||
|
|
|
@ -10,7 +10,7 @@ TEST (network_filter, unit)
|
|||
{
|
||||
nano::genesis genesis;
|
||||
nano::network_filter filter (1);
|
||||
auto one_block = [&filter](std::shared_ptr<nano::block> const & block_a, bool expect_duplicate_a) {
|
||||
auto one_block = [&filter] (std::shared_ptr<nano::block> const & block_a, bool expect_duplicate_a) {
|
||||
nano::publish message (block_a);
|
||||
auto bytes (message.to_bytes ());
|
||||
nano::bufferstream stream (bytes->data (), bytes->size ());
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -20,8 +20,8 @@ TEST (peer_container, no_recontact)
|
|||
auto observed_disconnect (false);
|
||||
nano::endpoint endpoint1 (boost::asio::ip::address_v6::loopback (), 10000);
|
||||
ASSERT_EQ (0, network.size ());
|
||||
network.channel_observer = [&observed_peer](std::shared_ptr<nano::transport::channel> const &) { ++observed_peer; };
|
||||
node1.network.disconnect_observer = [&observed_disconnect]() { observed_disconnect = true; };
|
||||
network.channel_observer = [&observed_peer] (std::shared_ptr<nano::transport::channel> const &) { ++observed_peer; };
|
||||
node1.network.disconnect_observer = [&observed_disconnect] () { observed_disconnect = true; };
|
||||
auto channel (network.udp_channels.insert (endpoint1, node1.network_params.protocol.protocol_version));
|
||||
ASSERT_EQ (1, network.size ());
|
||||
ASSERT_EQ (channel, network.udp_channels.insert (endpoint1, node1.network_params.protocol.protocol_version));
|
||||
|
@ -61,12 +61,12 @@ TEST (peer_container, split)
|
|||
nano::endpoint endpoint2 (boost::asio::ip::address_v6::loopback (), 101);
|
||||
auto channel1 (node1.network.udp_channels.insert (endpoint1, 0));
|
||||
ASSERT_NE (nullptr, channel1);
|
||||
node1.network.udp_channels.modify (channel1, [&now](auto channel) {
|
||||
node1.network.udp_channels.modify (channel1, [&now] (auto channel) {
|
||||
channel->set_last_packet_received (now - std::chrono::seconds (1));
|
||||
});
|
||||
auto channel2 (node1.network.udp_channels.insert (endpoint2, 0));
|
||||
ASSERT_NE (nullptr, channel2);
|
||||
node1.network.udp_channels.modify (channel2, [&now](auto channel) {
|
||||
node1.network.udp_channels.modify (channel2, [&now] (auto channel) {
|
||||
channel->set_last_packet_received (now + std::chrono::seconds (1));
|
||||
});
|
||||
ASSERT_EQ (2, node1.network.size ());
|
||||
|
@ -84,7 +84,7 @@ TEST (channels, fill_random_clear)
|
|||
std::array<nano::endpoint, 8> target;
|
||||
std::fill (target.begin (), target.end (), nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000));
|
||||
system.nodes[0]->network.random_fill (target);
|
||||
ASSERT_TRUE (std::all_of (target.begin (), target.end (), [](nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::any (), 0); }));
|
||||
ASSERT_TRUE (std::all_of (target.begin (), target.end (), [] (nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::any (), 0); }));
|
||||
}
|
||||
|
||||
TEST (channels, fill_random_full)
|
||||
|
@ -97,7 +97,7 @@ TEST (channels, fill_random_full)
|
|||
std::array<nano::endpoint, 8> target;
|
||||
std::fill (target.begin (), target.end (), nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000));
|
||||
system.nodes[0]->network.random_fill (target);
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.end (), [](nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000); }));
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.end (), [] (nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000); }));
|
||||
}
|
||||
|
||||
TEST (channels, fill_random_part)
|
||||
|
@ -111,9 +111,9 @@ TEST (channels, fill_random_part)
|
|||
}
|
||||
std::fill (target.begin (), target.end (), nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000));
|
||||
system.nodes[0]->network.random_fill (target);
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.begin () + half, [](nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000); }));
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.begin () + half, [](nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 0); }));
|
||||
ASSERT_TRUE (std::all_of (target.begin () + half, target.end (), [](nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::any (), 0); }));
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.begin () + half, [] (nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 10000); }));
|
||||
ASSERT_TRUE (std::none_of (target.begin (), target.begin () + half, [] (nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::loopback (), 0); }));
|
||||
ASSERT_TRUE (std::all_of (target.begin () + half, target.end (), [] (nano::endpoint const & endpoint_a) { return endpoint_a == nano::endpoint (boost::asio::ip::address_v6::any (), 0); }));
|
||||
}
|
||||
|
||||
TEST (peer_container, list_fanout)
|
||||
|
@ -125,7 +125,7 @@ TEST (peer_container, list_fanout)
|
|||
ASSERT_EQ (0, node.network.fanout ());
|
||||
auto list1 (node.network.list (node.network.fanout ()));
|
||||
ASSERT_TRUE (list1.empty ());
|
||||
auto add_peer = [&node](const uint16_t port_a) {
|
||||
auto add_peer = [&node] (const uint16_t port_a) {
|
||||
ASSERT_NE (nullptr, node.network.udp_channels.insert (nano::endpoint (boost::asio::ip::address_v6::loopback (), port_a), node.network_params.protocol.protocol_version));
|
||||
};
|
||||
add_peer (9998);
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
||||
TEST (processor_service, bad_send_signature)
|
||||
{
|
||||
nano::logger_mt logger;
|
||||
|
|
|
@ -53,37 +53,37 @@ TEST (request_aggregator, one_update)
|
|||
system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
nano::keypair key1;
|
||||
auto send1 = nano::state_block_builder ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (genesis.hash ())
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - nano::Gxrb_ratio)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*node.work_generate_blocking (genesis.hash ()))
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (genesis.hash ())
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - nano::Gxrb_ratio)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*node.work_generate_blocking (genesis.hash ()))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send1).code);
|
||||
node.confirmation_height_processor.add (send1);
|
||||
ASSERT_TIMELY (5s, node.ledger.block_confirmed (node.store.tx_begin_read (), send1->hash ()));
|
||||
auto send2 = nano::state_block_builder ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (send1->hash ())
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - 2 * nano::Gxrb_ratio)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*node.work_generate_blocking (send1->hash ()))
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (send1->hash ())
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - 2 * nano::Gxrb_ratio)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*node.work_generate_blocking (send1->hash ()))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send2).code);
|
||||
auto receive1 = nano::state_block_builder ()
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::Gxrb_ratio)
|
||||
.link (send1->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*node.work_generate_blocking (key1.pub))
|
||||
.build_shared ();
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::Gxrb_ratio)
|
||||
.link (send1->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*node.work_generate_blocking (key1.pub))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *receive1).code);
|
||||
std::vector<std::pair<nano::block_hash, nano::root>> request;
|
||||
request.emplace_back (send2->hash (), send2->root ());
|
||||
|
@ -120,35 +120,35 @@ TEST (request_aggregator, two)
|
|||
nano::keypair key1;
|
||||
nano::state_block_builder builder;
|
||||
auto send1 = builder.make_block ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (genesis.hash ())
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - 1)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*node.work_generate_blocking (genesis.hash ()))
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (genesis.hash ())
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - 1)
|
||||
.link (key1.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*node.work_generate_blocking (genesis.hash ()))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send1).code);
|
||||
node.confirmation_height_processor.add (send1);
|
||||
ASSERT_TIMELY (5s, node.ledger.block_confirmed (node.store.tx_begin_read (), send1->hash ()));
|
||||
auto send2 = builder.make_block ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (send1->hash ())
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - 2)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*node.work_generate_blocking (send1->hash ()))
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (send1->hash ())
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - 2)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*node.work_generate_blocking (send1->hash ()))
|
||||
.build_shared ();
|
||||
auto receive1 = builder.make_block ()
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (1)
|
||||
.link (send1->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*node.work_generate_blocking (key1.pub))
|
||||
.build_shared ();
|
||||
.account (key1.pub)
|
||||
.previous (0)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (1)
|
||||
.link (send1->hash ())
|
||||
.sign (key1.prv, key1.pub)
|
||||
.work (*node.work_generate_blocking (key1.pub))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send2).code);
|
||||
ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *receive1).code);
|
||||
std::vector<std::pair<nano::block_hash, nano::root>> request;
|
||||
|
@ -234,15 +234,15 @@ TEST (request_aggregator, split)
|
|||
{
|
||||
nano::block_builder builder;
|
||||
blocks.push_back (builder
|
||||
.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (previous)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - (i + 1))
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (previous))
|
||||
.build ());
|
||||
.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (previous)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - (i + 1))
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (previous))
|
||||
.build ());
|
||||
auto const & block = blocks.back ();
|
||||
previous = block->hash ();
|
||||
ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *block).code);
|
||||
|
@ -374,21 +374,21 @@ TEST (request_aggregator, cannot_vote)
|
|||
nano::genesis genesis;
|
||||
nano::state_block_builder builder;
|
||||
auto send1 = builder.make_block ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - 1)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - 1)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
auto send2 = builder.make_block ()
|
||||
.from (*send1)
|
||||
.previous (send1->hash ())
|
||||
.balance (send1->balance ().number () - 1)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (send1->hash ()))
|
||||
.build_shared ();
|
||||
.from (*send1)
|
||||
.previous (send1->hash ())
|
||||
.balance (send1->balance ().number () - 1)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (send1->hash ()))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, node.process (*send1).code);
|
||||
ASSERT_EQ (nano::process_result::progress, node.process (*send2).code);
|
||||
system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
|
|
|
@ -38,7 +38,7 @@ TEST (signature_checker, bulk_single_thread)
|
|||
}
|
||||
nano::signature_check_set check = { size, messages.data (), lengths.data (), pub_keys.data (), signatures.data (), verifications.data () };
|
||||
checker.verify (check);
|
||||
bool all_valid = std::all_of (verifications.cbegin (), verifications.cend (), [](auto verification) { return verification == 1; });
|
||||
bool all_valid = std::all_of (verifications.cbegin (), verifications.cend (), [] (auto verification) { return verification == 1; });
|
||||
ASSERT_TRUE (all_valid);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ TEST (signature_checker, many_multi_threaded)
|
|||
{
|
||||
nano::signature_checker checker (4);
|
||||
|
||||
auto signature_checker_work_func = [&checker]() {
|
||||
auto signature_checker_work_func = [&checker] () {
|
||||
nano::keypair key;
|
||||
nano::state_block block (key.pub, 0, key.pub, 0, 0, key.prv, key.pub, 0);
|
||||
auto block_hash = block.hash ();
|
||||
|
@ -97,7 +97,7 @@ TEST (signature_checker, many_multi_threaded)
|
|||
checker.verify (signature_checker_sets[i]);
|
||||
|
||||
// Confirm all but last are valid
|
||||
auto all_valid = std::all_of (verifications[i].cbegin (), verifications[i].cend () - 1, [](auto verification) { return verification == 1; });
|
||||
auto all_valid = std::all_of (verifications[i].cbegin (), verifications[i].cend () - 1, [] (auto verification) { return verification == 1; });
|
||||
ASSERT_TRUE (all_valid);
|
||||
ASSERT_EQ (verifications[i][last_signature_index], 0);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ TEST (signature_checker, one)
|
|||
{
|
||||
nano::signature_checker checker (0);
|
||||
|
||||
auto verify_block = [&checker](auto & block, auto result) {
|
||||
auto verify_block = [&checker] (auto & block, auto result) {
|
||||
std::vector<nano::uint256_union> hashes;
|
||||
std::vector<unsigned char const *> messages;
|
||||
std::vector<size_t> lengths;
|
||||
|
@ -152,7 +152,7 @@ TEST (signature_checker, boundary_checks)
|
|||
{
|
||||
// sizes container must be in incrementing order
|
||||
std::vector<size_t> sizes{ 0, 1 };
|
||||
auto add_boundary = [&sizes](size_t boundary) {
|
||||
auto add_boundary = [&sizes] (size_t boundary) {
|
||||
sizes.insert (sizes.end (), { boundary - 1, boundary, boundary + 1 });
|
||||
};
|
||||
|
||||
|
@ -194,7 +194,7 @@ TEST (signature_checker, boundary_checks)
|
|||
}
|
||||
nano::signature_check_set check = { size, messages.data (), lengths.data (), pub_keys.data (), signatures.data (), verifications.data () };
|
||||
checker.verify (check);
|
||||
bool all_valid = std::all_of (verifications.cbegin (), verifications.cend (), [](auto verification) { return verification == 1; });
|
||||
bool all_valid = std::all_of (verifications.cbegin (), verifications.cend (), [] (auto verification) { return verification == 1; });
|
||||
ASSERT_TRUE (all_valid);
|
||||
last_size = size;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ TEST (socket, drop_policy)
|
|||
|
||||
std::vector<std::shared_ptr<nano::socket>> connections;
|
||||
|
||||
auto func = [&](size_t total_message_count, nano::buffer_drop_policy drop_policy) {
|
||||
auto func = [&] (size_t total_message_count, nano::buffer_drop_policy drop_policy) {
|
||||
auto server_port (nano::get_available_port ());
|
||||
boost::asio::ip::tcp::endpoint endpoint (boost::asio::ip::address_v6::any (), server_port);
|
||||
|
||||
|
@ -28,7 +28,7 @@ TEST (socket, drop_policy)
|
|||
ASSERT_FALSE (ec);
|
||||
|
||||
// Accept connection, but don't read so the writer will drop.
|
||||
server_socket->on_connection ([&connections](std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
server_socket->on_connection ([&connections] (std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
connections.push_back (new_connection);
|
||||
return true;
|
||||
});
|
||||
|
@ -38,12 +38,12 @@ TEST (socket, drop_policy)
|
|||
nano::util::counted_completion write_completion (static_cast<unsigned> (total_message_count));
|
||||
|
||||
client->async_connect (boost::asio::ip::tcp::endpoint (boost::asio::ip::address_v6::loopback (), server_port),
|
||||
[&channel, total_message_count, node, &write_completion, &drop_policy, client](boost::system::error_code const & ec_a) mutable {
|
||||
[&channel, total_message_count, node, &write_completion, &drop_policy, client] (boost::system::error_code const & ec_a) mutable {
|
||||
for (int i = 0; i < total_message_count; i++)
|
||||
{
|
||||
std::vector<uint8_t> buff (1);
|
||||
channel.send_buffer (
|
||||
nano::shared_const_buffer (std::move (buff)), [&write_completion, client](boost::system::error_code const & ec, size_t size_a) mutable {
|
||||
nano::shared_const_buffer (std::move (buff)), [&write_completion, client] (boost::system::error_code const & ec, size_t size_a) mutable {
|
||||
client.reset ();
|
||||
write_completion.increment ();
|
||||
},
|
||||
|
@ -88,7 +88,7 @@ TEST (socket, concurrent_writes)
|
|||
|
||||
// We're expecting client_count*4 messages
|
||||
nano::util::counted_completion read_count_completion (total_message_count);
|
||||
std::function<void(std::shared_ptr<nano::socket> const &)> reader = [&read_count_completion, &total_message_count, &reader](std::shared_ptr<nano::socket> const & socket_a) {
|
||||
std::function<void (std::shared_ptr<nano::socket> const &)> reader = [&read_count_completion, &total_message_count, &reader] (std::shared_ptr<nano::socket> const & socket_a) {
|
||||
auto buff (std::make_shared<std::vector<uint8_t>> ());
|
||||
buff->resize (1);
|
||||
#ifndef _WIN32
|
||||
|
@ -100,7 +100,7 @@ TEST (socket, concurrent_writes)
|
|||
#endif
|
||||
#endif
|
||||
#endif
|
||||
socket_a->async_read (buff, 1, [&read_count_completion, &reader, &total_message_count, socket_a, buff](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_a->async_read (buff, 1, [&read_count_completion, &reader, &total_message_count, socket_a, buff] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
if (read_count_completion.increment () < total_message_count)
|
||||
|
@ -127,7 +127,7 @@ TEST (socket, concurrent_writes)
|
|||
std::vector<std::shared_ptr<nano::socket>> connections;
|
||||
|
||||
// On every new connection, start reading data
|
||||
server_socket->on_connection ([&connections, &reader](std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
server_socket->on_connection ([&connections, &reader] (std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
if (ec_a)
|
||||
{
|
||||
std::cerr << "on_connection: " << ec_a.message () << std::endl;
|
||||
|
@ -148,7 +148,7 @@ TEST (socket, concurrent_writes)
|
|||
auto client = std::make_shared<nano::socket> (*node, boost::none);
|
||||
clients.push_back (client);
|
||||
client->async_connect (boost::asio::ip::tcp::endpoint (boost::asio::ip::address_v4::loopback (), 25000),
|
||||
[&connection_count_completion](boost::system::error_code const & ec_a) {
|
||||
[&connection_count_completion] (boost::system::error_code const & ec_a) {
|
||||
if (ec_a)
|
||||
{
|
||||
std::cerr << "async_connect: " << ec_a.message () << std::endl;
|
||||
|
@ -175,7 +175,7 @@ TEST (socket, concurrent_writes)
|
|||
#endif
|
||||
#endif
|
||||
#endif
|
||||
client_threads.emplace_back ([&client, &message_count]() {
|
||||
client_threads.emplace_back ([&client, &message_count] () {
|
||||
for (int i = 0; i < message_count; i++)
|
||||
{
|
||||
std::vector<uint8_t> buff;
|
||||
|
|
|
@ -242,7 +242,7 @@ TEST (telemetry, basic)
|
|||
auto channel = node_client->network.find_channel (node_server->network.endpoint ());
|
||||
{
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &server_endpoint, &telemetry_data](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &server_endpoint, &telemetry_data] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_FALSE (response_a.error);
|
||||
ASSERT_EQ (server_endpoint, response_a.endpoint);
|
||||
telemetry_data = response_a.telemetry_data;
|
||||
|
@ -258,7 +258,7 @@ TEST (telemetry, basic)
|
|||
// Call again straight away. It should use the cache
|
||||
{
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &telemetry_data](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &telemetry_data] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_EQ (telemetry_data, response_a.telemetry_data);
|
||||
ASSERT_FALSE (response_a.error);
|
||||
done = true;
|
||||
|
@ -271,7 +271,7 @@ TEST (telemetry, basic)
|
|||
std::this_thread::sleep_for (nano::telemetry_cache_cutoffs::dev);
|
||||
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &telemetry_data](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &telemetry_data] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_NE (telemetry_data, response_a.telemetry_data);
|
||||
ASSERT_FALSE (response_a.error);
|
||||
done = true;
|
||||
|
@ -303,7 +303,7 @@ TEST (telemetry, over_udp)
|
|||
|
||||
std::atomic<bool> done{ false };
|
||||
auto channel = node_client->network.find_channel (node_server->network.endpoint ());
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &node_server](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &node_server] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_FALSE (response_a.error);
|
||||
nano::compare_default_telemetry_response_data (response_a.telemetry_data, node_server->network_params, node_server->config.bandwidth_limit, node_server->active.active_difficulty (), node_server->node_id);
|
||||
done = true;
|
||||
|
@ -330,7 +330,7 @@ TEST (telemetry, invalid_channel)
|
|||
auto node_server = system.nodes.back ();
|
||||
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (nullptr, [&done](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (nullptr, [&done] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_TRUE (response_a.error);
|
||||
done = true;
|
||||
});
|
||||
|
@ -349,9 +349,9 @@ TEST (telemetry, blocking_request)
|
|||
|
||||
// Request telemetry metrics
|
||||
std::atomic<bool> done{ false };
|
||||
std::function<void()> call_system_poll;
|
||||
std::function<void ()> call_system_poll;
|
||||
std::promise<void> promise;
|
||||
call_system_poll = [&call_system_poll, &workers = node_client->workers, &done, &system, &promise]() {
|
||||
call_system_poll = [&call_system_poll, &workers = node_client->workers, &done, &system, &promise] () {
|
||||
if (!done)
|
||||
{
|
||||
ASSERT_NO_ERROR (system.poll ());
|
||||
|
@ -392,7 +392,7 @@ TEST (telemetry, disconnects)
|
|||
ASSERT_TRUE (channel);
|
||||
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_TRUE (response_a.error);
|
||||
done = true;
|
||||
});
|
||||
|
@ -414,7 +414,7 @@ TEST (telemetry, dos_tcp)
|
|||
|
||||
nano::telemetry_req message;
|
||||
auto channel = node_client->network.tcp_channels.find_channel (nano::transport::map_endpoint_to_tcp (node_server->network.endpoint ()));
|
||||
channel->send (message, [](boost::system::error_code const & ec, size_t size_a) {
|
||||
channel->send (message, [] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
});
|
||||
|
||||
|
@ -423,7 +423,7 @@ TEST (telemetry, dos_tcp)
|
|||
auto orig = std::chrono::steady_clock::now ();
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
channel->send (message, [](boost::system::error_code const & ec, size_t size_a) {
|
||||
channel->send (message, [] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
});
|
||||
}
|
||||
|
@ -457,7 +457,7 @@ TEST (telemetry, dos_udp)
|
|||
|
||||
nano::telemetry_req message;
|
||||
auto channel (node_client->network.udp_channels.create (node_server->network.endpoint ()));
|
||||
channel->send (message, [](boost::system::error_code const & ec, size_t size_a) {
|
||||
channel->send (message, [] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
});
|
||||
|
||||
|
@ -466,7 +466,7 @@ TEST (telemetry, dos_udp)
|
|||
auto orig = std::chrono::steady_clock::now ();
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
channel->send (message, [](boost::system::error_code const & ec, size_t size_a) {
|
||||
channel->send (message, [] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
});
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ TEST (telemetry, disable_metrics)
|
|||
ASSERT_TRUE (channel);
|
||||
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_TRUE (response_a.error);
|
||||
done = true;
|
||||
});
|
||||
|
@ -511,7 +511,7 @@ TEST (telemetry, disable_metrics)
|
|||
// It should still be able to receive metrics though
|
||||
done = false;
|
||||
auto channel1 = node_server->network.find_channel (node_client->network.endpoint ());
|
||||
node_server->telemetry->get_metrics_single_peer_async (channel1, [&done, node_client](nano::telemetry_data_response const & response_a) {
|
||||
node_server->telemetry->get_metrics_single_peer_async (channel1, [&done, node_client] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_FALSE (response_a.error);
|
||||
nano::compare_default_telemetry_response_data (response_a.telemetry_data, node_client->network_params, node_client->config.bandwidth_limit, node_client->active.active_difficulty (), node_client->node_id);
|
||||
done = true;
|
||||
|
@ -536,7 +536,7 @@ TEST (telemetry, max_possible_size)
|
|||
wait_peer_connections (system);
|
||||
|
||||
auto channel = node_client->network.tcp_channels.find_channel (nano::transport::map_endpoint_to_tcp (node_server->network.endpoint ()));
|
||||
channel->send (message, [](boost::system::error_code const & ec, size_t size_a) {
|
||||
channel->send (message, [] (boost::system::error_code const & ec, size_t size_a) {
|
||||
ASSERT_FALSE (ec);
|
||||
});
|
||||
|
||||
|
@ -596,11 +596,11 @@ TEST (telemetry, remove_peer_different_genesis_udp)
|
|||
std::atomic<bool> done0{ false };
|
||||
std::atomic<bool> done1{ false };
|
||||
|
||||
node0->telemetry->get_metrics_single_peer_async (channel1, [&done0](nano::telemetry_data_response const & response_a) {
|
||||
node0->telemetry->get_metrics_single_peer_async (channel1, [&done0] (nano::telemetry_data_response const & response_a) {
|
||||
done0 = true;
|
||||
});
|
||||
|
||||
node1->telemetry->get_metrics_single_peer_async (channel0, [&done1](nano::telemetry_data_response const & response_a) {
|
||||
node1->telemetry->get_metrics_single_peer_async (channel0, [&done1] (nano::telemetry_data_response const & response_a) {
|
||||
done1 = true;
|
||||
});
|
||||
|
||||
|
@ -635,7 +635,7 @@ TEST (telemetry, remove_peer_invalid_signature)
|
|||
node->network.process_message (telemetry_ack, channel);
|
||||
|
||||
ASSERT_TIMELY (10s, node->stats.count (nano::stat::type::telemetry, nano::stat::detail::invalid_signature) > 0);
|
||||
ASSERT_NO_ERROR (system.poll_until_true (3s, [&node, address = channel->get_endpoint ().address ()]() -> bool {
|
||||
ASSERT_NO_ERROR (system.poll_until_true (3s, [&node, address = channel->get_endpoint ().address ()] () -> bool {
|
||||
nano::lock_guard<nano::mutex> guard (node->network.excluded_peers.mutex);
|
||||
return node->network.excluded_peers.peers.get<nano::peer_exclusion::tag_endpoint> ().count (address);
|
||||
}));
|
||||
|
@ -662,7 +662,7 @@ TEST (telemetry, maker_pruning)
|
|||
auto channel = node_client->network.find_channel (node_server->network.endpoint ());
|
||||
{
|
||||
std::atomic<bool> done{ false };
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &server_endpoint, &telemetry_data](nano::telemetry_data_response const & response_a) {
|
||||
node_client->telemetry->get_metrics_single_peer_async (channel, [&done, &server_endpoint, &telemetry_data] (nano::telemetry_data_response const & response_a) {
|
||||
ASSERT_FALSE (response_a.error);
|
||||
ASSERT_EQ (server_endpoint, response_a.endpoint);
|
||||
telemetry_data = response_a.telemetry_data;
|
||||
|
|
|
@ -95,7 +95,7 @@ TEST (thread, thread_pool)
|
|||
{
|
||||
std::atomic<bool> passed_sleep{ false };
|
||||
|
||||
auto func = [&passed_sleep]() {
|
||||
auto func = [&passed_sleep] () {
|
||||
std::this_thread::sleep_for (std::chrono::seconds (1));
|
||||
passed_sleep = true;
|
||||
};
|
||||
|
@ -122,7 +122,7 @@ TEST (thread_pool_alarm, one)
|
|||
std::atomic<bool> done (false);
|
||||
nano::mutex mutex;
|
||||
nano::condition_variable condition;
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&]() {
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&] () {
|
||||
{
|
||||
nano::lock_guard<nano::mutex> lock (mutex);
|
||||
done = true;
|
||||
|
@ -130,7 +130,7 @@ TEST (thread_pool_alarm, one)
|
|||
condition.notify_one ();
|
||||
});
|
||||
nano::unique_lock<nano::mutex> unique (mutex);
|
||||
condition.wait (unique, [&]() { return !!done; });
|
||||
condition.wait (unique, [&] () { return !!done; });
|
||||
}
|
||||
|
||||
TEST (thread_pool_alarm, many)
|
||||
|
@ -141,7 +141,7 @@ TEST (thread_pool_alarm, many)
|
|||
nano::condition_variable condition;
|
||||
for (auto i (0); i < 50; ++i)
|
||||
{
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&]() {
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&] () {
|
||||
{
|
||||
nano::lock_guard<nano::mutex> lock (mutex);
|
||||
count += 1;
|
||||
|
@ -150,7 +150,7 @@ TEST (thread_pool_alarm, many)
|
|||
});
|
||||
}
|
||||
nano::unique_lock<nano::mutex> unique (mutex);
|
||||
condition.wait (unique, [&]() { return count == 50; });
|
||||
condition.wait (unique, [&] () { return count == 50; });
|
||||
}
|
||||
|
||||
TEST (thread_pool_alarm, top_execution)
|
||||
|
@ -160,12 +160,12 @@ TEST (thread_pool_alarm, top_execution)
|
|||
int value2 (0);
|
||||
nano::mutex mutex;
|
||||
std::promise<bool> promise;
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&]() {
|
||||
workers.add_timed_task (std::chrono::steady_clock::now (), [&] () {
|
||||
nano::lock_guard<nano::mutex> lock (mutex);
|
||||
value1 = 1;
|
||||
value2 = 1;
|
||||
});
|
||||
workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (1), [&]() {
|
||||
workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::milliseconds (1), [&] () {
|
||||
nano::lock_guard<nano::mutex> lock (mutex);
|
||||
value2 = 2;
|
||||
promise.set_value (false);
|
||||
|
|
|
@ -191,14 +191,14 @@ TEST (vote_processor, no_broadcast_local)
|
|||
// Reduce the weight of genesis to 2x default min voting weight
|
||||
nano::keypair key;
|
||||
std::shared_ptr<nano::block> send = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.balance (2 * node.config.vote_minimum.number ())
|
||||
.link (key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build (ec);
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.balance (2 * node.config.vote_minimum.number ())
|
||||
.link (key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build (ec);
|
||||
ASSERT_FALSE (ec);
|
||||
ASSERT_EQ (nano::process_result::progress, node.process_local (send).code);
|
||||
ASSERT_EQ (2 * node.config.vote_minimum.number (), node.weight (nano::dev_genesis_key.pub));
|
||||
|
@ -228,14 +228,14 @@ TEST (vote_processor, no_broadcast_local)
|
|||
ASSERT_FALSE (node.wallets.reps ().exists (nano::dev_genesis_key.pub));
|
||||
|
||||
std::shared_ptr<nano::block> send2 = builder.state ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.previous (send->hash ())
|
||||
.balance (node.config.vote_minimum)
|
||||
.link (key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (send->hash ()))
|
||||
.build (ec);
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.previous (send->hash ())
|
||||
.balance (node.config.vote_minimum)
|
||||
.link (key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (send->hash ()))
|
||||
.build (ec);
|
||||
ASSERT_FALSE (ec);
|
||||
ASSERT_EQ (nano::process_result::progress, node.process_local (send2).code);
|
||||
ASSERT_EQ (node.config.vote_minimum, node.weight (nano::dev_genesis_key.pub));
|
||||
|
@ -257,14 +257,14 @@ TEST (vote_processor, no_broadcast_local)
|
|||
// Repeat test with a PR in the wallet
|
||||
// Increase the genesis weight again
|
||||
std::shared_ptr<nano::block> open = builder.state ()
|
||||
.account (key.pub)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.previous (0)
|
||||
.balance (nano::genesis_amount - 2 * node.config.vote_minimum.number ())
|
||||
.link (send->hash ())
|
||||
.sign (key.prv, key.pub)
|
||||
.work (*system.work.generate (key.pub))
|
||||
.build (ec);
|
||||
.account (key.pub)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.previous (0)
|
||||
.balance (nano::genesis_amount - 2 * node.config.vote_minimum.number ())
|
||||
.link (send->hash ())
|
||||
.sign (key.prv, key.pub)
|
||||
.work (*system.work.generate (key.pub))
|
||||
.build (ec);
|
||||
ASSERT_FALSE (ec);
|
||||
ASSERT_EQ (nano::process_result::progress, node.process_local (open).code);
|
||||
ASSERT_EQ (nano::genesis_amount - node.config.vote_minimum.number (), node.weight (nano::dev_genesis_key.pub));
|
||||
|
|
|
@ -66,7 +66,7 @@ TEST (vote_generator, cache)
|
|||
ASSERT_TIMELY (1s, !node.history.votes (epoch1->root (), epoch1->hash ()).empty ());
|
||||
auto votes (node.history.votes (epoch1->root (), epoch1->hash ()));
|
||||
ASSERT_FALSE (votes.empty ());
|
||||
ASSERT_TRUE (std::any_of (votes[0]->begin (), votes[0]->end (), [hash = epoch1->hash ()](nano::block_hash const & hash_a) { return hash_a == hash; }));
|
||||
ASSERT_TRUE (std::any_of (votes[0]->begin (), votes[0]->end (), [hash = epoch1->hash ()] (nano::block_hash const & hash_a) { return hash_a == hash; }));
|
||||
}
|
||||
|
||||
TEST (vote_generator, multiple_representatives)
|
||||
|
@ -97,7 +97,7 @@ TEST (vote_generator, multiple_representatives)
|
|||
auto votes (node.history.votes (send->root (), send->hash ()));
|
||||
for (auto const & account : { key1.pub, key2.pub, key3.pub, nano::dev_genesis_key.pub })
|
||||
{
|
||||
auto existing (std::find_if (votes.begin (), votes.end (), [&account](std::shared_ptr<nano::vote> const & vote_a) -> bool {
|
||||
auto existing (std::find_if (votes.begin (), votes.end (), [&account] (std::shared_ptr<nano::vote> const & vote_a) -> bool {
|
||||
return vote_a->account == account;
|
||||
}));
|
||||
ASSERT_NE (votes.end (), existing);
|
||||
|
@ -110,7 +110,7 @@ TEST (vote_generator, session)
|
|||
auto node (system.nodes[0]);
|
||||
system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
nano::vote_generator_session generator_session (node->active.generator);
|
||||
boost::thread thread ([node, &generator_session]() {
|
||||
boost::thread thread ([node, &generator_session] () {
|
||||
nano::thread_role::set (nano::thread_role::name::request_loop);
|
||||
generator_session.add (nano::genesis_account, nano::genesis_hash);
|
||||
ASSERT_EQ (0, node->stats.count (nano::stat::type::vote, nano::stat::detail::vote_indeterminate));
|
||||
|
@ -165,23 +165,23 @@ TEST (vote_spacing, vote_generator)
|
|||
wallet.insert_adhoc (nano::dev_genesis_key.prv);
|
||||
nano::state_block_builder builder;
|
||||
auto send1 = builder.make_block ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - nano::Gxrb_ratio)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - nano::Gxrb_ratio)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
auto send2 = builder.make_block ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - nano::Gxrb_ratio - 1)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - nano::Gxrb_ratio - 1)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send1).code);
|
||||
ASSERT_EQ (0, node.stats.count (nano::stat::type::vote_generator, nano::stat::detail::generator_broadcasts));
|
||||
node.active.generator.add (nano::genesis_hash, send1->hash ());
|
||||
|
@ -208,23 +208,23 @@ TEST (vote_spacing, rapid)
|
|||
wallet.insert_adhoc (nano::dev_genesis_key.prv);
|
||||
nano::state_block_builder builder;
|
||||
auto send1 = builder.make_block ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - nano::Gxrb_ratio)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - nano::Gxrb_ratio)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
auto send2 = builder.make_block ()
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - nano::Gxrb_ratio - 1)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
.account (nano::dev_genesis_key.pub)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::dev_genesis_key.pub)
|
||||
.balance (nano::genesis_amount - nano::Gxrb_ratio - 1)
|
||||
.link (nano::dev_genesis_key.pub)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build_shared ();
|
||||
ASSERT_EQ (nano::process_result::progress, node.ledger.process (node.store.tx_begin_write (), *send1).code);
|
||||
node.active.generator.add (nano::genesis_hash, send1->hash ());
|
||||
ASSERT_TIMELY (3s, node.stats.count (nano::stat::type::vote_generator, nano::stat::detail::generator_broadcasts) == 1);
|
||||
|
|
|
@ -198,11 +198,11 @@ TEST (wallet, send_async)
|
|||
nano::system system (1);
|
||||
system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
nano::keypair key2;
|
||||
std::thread thread ([&system]() {
|
||||
std::thread thread ([&system] () {
|
||||
ASSERT_TIMELY (10s, system.nodes[0]->balance (nano::dev_genesis_key.pub).is_zero ());
|
||||
});
|
||||
std::atomic<bool> success (false);
|
||||
system.wallet (0)->send_async (nano::dev_genesis_key.pub, key2.pub, std::numeric_limits<nano::uint128_t>::max (), [&success](std::shared_ptr<nano::block> const & block_a) { ASSERT_NE (nullptr, block_a); success = true; });
|
||||
system.wallet (0)->send_async (nano::dev_genesis_key.pub, key2.pub, std::numeric_limits<nano::uint128_t>::max (), [&success] (std::shared_ptr<nano::block> const & block_a) { ASSERT_NE (nullptr, block_a); success = true; });
|
||||
thread.join ();
|
||||
ASSERT_TIMELY (2s, success);
|
||||
}
|
||||
|
@ -846,7 +846,7 @@ TEST (wallet, password_race)
|
|||
nano::system system (1);
|
||||
nano::thread_runner runner (system.io_ctx, system.nodes[0]->config.io_threads);
|
||||
auto wallet = system.wallet (0);
|
||||
std::thread thread ([&wallet]() {
|
||||
std::thread thread ([&wallet] () {
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
auto transaction (wallet->wallets.tx_begin_write ());
|
||||
|
@ -884,21 +884,21 @@ TEST (wallet, password_race_corrupt_seed)
|
|||
std::vector<std::thread> threads;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
threads.emplace_back ([&wallet]() {
|
||||
threads.emplace_back ([&wallet] () {
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
auto transaction (wallet->wallets.tx_begin_write ());
|
||||
wallet->store.rekey (transaction, "0000");
|
||||
}
|
||||
});
|
||||
threads.emplace_back ([&wallet]() {
|
||||
threads.emplace_back ([&wallet] () {
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
auto transaction (wallet->wallets.tx_begin_write ());
|
||||
wallet->store.rekey (transaction, "1234");
|
||||
}
|
||||
});
|
||||
threads.emplace_back ([&wallet]() {
|
||||
threads.emplace_back ([&wallet] () {
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
auto transaction (wallet->wallets.tx_begin_read ());
|
||||
|
@ -1175,7 +1175,7 @@ TEST (wallet, foreach_representative_deadlock)
|
|||
system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
node.wallets.compute_reps ();
|
||||
ASSERT_EQ (1, node.wallets.reps ().voting);
|
||||
node.wallets.foreach_representative ([&node](nano::public_key const & pub, nano::raw_key const & prv) {
|
||||
node.wallets.foreach_representative ([&node] (nano::public_key const & pub, nano::raw_key const & prv) {
|
||||
if (node.wallets.mutex.try_lock ())
|
||||
{
|
||||
node.wallets.mutex.unlock ();
|
||||
|
@ -1201,14 +1201,14 @@ TEST (wallet, search_pending)
|
|||
wallet.insert_adhoc (nano::dev_genesis_key.prv);
|
||||
nano::block_builder builder;
|
||||
auto send = builder.state ()
|
||||
.account (nano::genesis_account)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - node.config.receive_minimum.number ())
|
||||
.link (nano::genesis_account)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build ();
|
||||
.account (nano::genesis_account)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - node.config.receive_minimum.number ())
|
||||
.link (nano::genesis_account)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build ();
|
||||
ASSERT_EQ (nano::process_result::progress, node.process (*send).code);
|
||||
|
||||
// Pending search should start an election
|
||||
|
|
|
@ -190,14 +190,14 @@ TEST (wallets, search_pending)
|
|||
wallet->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
nano::block_builder builder;
|
||||
auto send = builder.state ()
|
||||
.account (nano::genesis_account)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - node.config.receive_minimum.number ())
|
||||
.link (nano::genesis_account)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build ();
|
||||
.account (nano::genesis_account)
|
||||
.previous (nano::genesis_hash)
|
||||
.representative (nano::genesis_account)
|
||||
.balance (nano::genesis_amount - node.config.receive_minimum.number ())
|
||||
.link (nano::genesis_account)
|
||||
.sign (nano::dev_genesis_key.prv, nano::dev_genesis_key.pub)
|
||||
.work (*system.work.generate (nano::genesis_hash))
|
||||
.build ();
|
||||
ASSERT_EQ (nano::process_result::progress, node.process (*send).code);
|
||||
|
||||
// Pending search should start an election
|
||||
|
|
|
@ -28,7 +28,7 @@ TEST (websocket, subscription_edge)
|
|||
|
||||
ASSERT_EQ (0, node1->websocket_server->subscriber_count (nano::websocket::topic::confirmation));
|
||||
|
||||
auto task = ([config, &node1]() {
|
||||
auto task = ([config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
@ -65,7 +65,7 @@ TEST (websocket, active_difficulty)
|
|||
ASSERT_EQ (0, node1->websocket_server->subscriber_count (nano::websocket::topic::active_difficulty));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "active_difficulty", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
@ -129,7 +129,7 @@ TEST (websocket, confirmation)
|
|||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
std::atomic<bool> unsubscribed{ false };
|
||||
auto task = ([&ack_ready, &unsubscribed, config, &node1]() {
|
||||
auto task = ([&ack_ready, &unsubscribed, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
@ -186,7 +186,7 @@ TEST (websocket, stopped_election)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "stopped_election", "ack": "true"})json");
|
||||
client.await_ack ();
|
||||
|
@ -229,7 +229,7 @@ TEST (websocket, confirmation_options)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task1 = ([&ack_ready, config, &node1]() {
|
||||
auto task1 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": "true", "options": {"confirmation_type": "active_quorum", "accounts": ["xrb_invalid"]}})json");
|
||||
client.await_ack ();
|
||||
|
@ -258,7 +258,7 @@ TEST (websocket, confirmation_options)
|
|||
ASSERT_TIMELY (5s, future1.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
ack_ready = false;
|
||||
auto task2 = ([&ack_ready, config, &node1]() {
|
||||
auto task2 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": "true", "options": {"confirmation_type": "active_quorum", "all_local_accounts": "true", "include_election_info": "true"}})json");
|
||||
client.await_ack ();
|
||||
|
@ -309,7 +309,7 @@ TEST (websocket, confirmation_options)
|
|||
}
|
||||
|
||||
ack_ready = false;
|
||||
auto task3 = ([&ack_ready, config, &node1]() {
|
||||
auto task3 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": "true", "options": {"confirmation_type": "active_quorum", "all_local_accounts": "true"}})json");
|
||||
client.await_ack ();
|
||||
|
@ -343,7 +343,7 @@ TEST (websocket, confirmation_options_votes)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task1 = ([&ack_ready, config, &node1]() {
|
||||
auto task1 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": "true", "options": {"confirmation_type": "active_quorum", "include_election_info_with_votes": "true", "include_block": "false"}})json");
|
||||
client.await_ack ();
|
||||
|
@ -422,7 +422,7 @@ TEST (websocket, confirmation_options_update)
|
|||
|
||||
std::atomic<bool> added{ false };
|
||||
std::atomic<bool> deleted{ false };
|
||||
auto task = ([&added, &deleted, config, &node1]() {
|
||||
auto task = ([&added, &deleted, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
// Subscribe initially with empty options, everything will be filtered
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "confirmation", "ack": "true", "options": {}})json");
|
||||
|
@ -477,7 +477,7 @@ TEST (websocket, vote)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "vote", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
@ -517,7 +517,7 @@ TEST (websocket, vote_options_type)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "vote", "ack": true, "options": {"include_replays": "true", "include_indeterminate": "false"}})json");
|
||||
client.await_ack ();
|
||||
|
@ -559,7 +559,7 @@ TEST (websocket, vote_options_representatives)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task1 = ([&ack_ready, config, &node1]() {
|
||||
auto task1 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
std::string message = boost::str (boost::format (R"json({"action": "subscribe", "topic": "vote", "ack": "true", "options": {"representatives": ["%1%"]}})json") % nano::dev_genesis_key.pub.to_account ());
|
||||
client.send_message (message);
|
||||
|
@ -583,7 +583,7 @@ TEST (websocket, vote_options_representatives)
|
|||
auto balance = nano::genesis_amount;
|
||||
system.wallet (0)->insert_adhoc (nano::dev_genesis_key.prv);
|
||||
auto send_amount = node1->online_reps.delta () + 1;
|
||||
auto confirm_block = [&]() {
|
||||
auto confirm_block = [&] () {
|
||||
nano::block_hash previous (node1->latest (nano::dev_genesis_key.pub));
|
||||
balance -= send_amount;
|
||||
auto send (std::make_shared<nano::state_block> (nano::dev_genesis_key.pub, previous, nano::dev_genesis_key.pub, balance, key.pub, nano::dev_genesis_key.prv, nano::dev_genesis_key.pub, *system.work.generate (previous)));
|
||||
|
@ -594,7 +594,7 @@ TEST (websocket, vote_options_representatives)
|
|||
ASSERT_TIMELY (5s, future1.wait_for (0s) == std::future_status::ready);
|
||||
|
||||
ack_ready = false;
|
||||
auto task2 = ([&ack_ready, config, &node1]() {
|
||||
auto task2 = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "vote", "ack": "true", "options": {"representatives": ["xrb_invalid"]}})json");
|
||||
client.await_ack ();
|
||||
|
@ -628,7 +628,7 @@ TEST (websocket, work)
|
|||
|
||||
// Subscribe to work and wait for response asynchronously
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "work", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
@ -698,7 +698,7 @@ TEST (websocket, bootstrap)
|
|||
|
||||
// Subscribe to bootstrap and wait for response asynchronously
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "bootstrap", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
@ -747,7 +747,7 @@ TEST (websocket, bootstrap_exited)
|
|||
// Start bootstrap, exit after subscription
|
||||
std::atomic<bool> bootstrap_started{ false };
|
||||
nano::util::counted_completion subscribed_completion (1);
|
||||
std::thread bootstrap_thread ([node1, &system, &bootstrap_started, &subscribed_completion]() {
|
||||
std::thread bootstrap_thread ([node1, &system, &bootstrap_started, &subscribed_completion] () {
|
||||
std::shared_ptr<nano::bootstrap_attempt> attempt;
|
||||
while (attempt == nullptr)
|
||||
{
|
||||
|
@ -765,7 +765,7 @@ TEST (websocket, bootstrap_exited)
|
|||
|
||||
// Subscribe to bootstrap and wait for response asynchronously
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, &node1]() {
|
||||
auto task = ([&ack_ready, config, &node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "bootstrap", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
@ -809,7 +809,7 @@ TEST (websocket, ws_keepalive)
|
|||
config.websocket_config.port = nano::get_available_port ();
|
||||
auto node1 (system.add_node (config));
|
||||
|
||||
auto task = ([config]() {
|
||||
auto task = ([config] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "ping"})json");
|
||||
client.await_ack ();
|
||||
|
@ -838,7 +838,7 @@ TEST (websocket, telemetry)
|
|||
wait_peer_connections (system);
|
||||
|
||||
std::atomic<bool> done{ false };
|
||||
auto task = ([config = node1->config, &node1, &done]() {
|
||||
auto task = ([config = node1->config, &node1, &done] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "telemetry", "ack": true})json");
|
||||
client.await_ack ();
|
||||
|
@ -851,7 +851,7 @@ TEST (websocket, telemetry)
|
|||
|
||||
ASSERT_TIMELY (10s, done);
|
||||
|
||||
node1->telemetry->get_metrics_single_peer_async (node1->network.find_channel (node2->network.endpoint ()), [](auto const & response_a) {
|
||||
node1->telemetry->get_metrics_single_peer_async (node1->network.find_channel (node2->network.endpoint ()), [] (auto const & response_a) {
|
||||
ASSERT_FALSE (response_a.error);
|
||||
});
|
||||
|
||||
|
@ -888,7 +888,7 @@ TEST (websocket, new_unconfirmed_block)
|
|||
auto node1 (system.add_node (config));
|
||||
|
||||
std::atomic<bool> ack_ready{ false };
|
||||
auto task = ([&ack_ready, config, node1]() {
|
||||
auto task = ([&ack_ready, config, node1] () {
|
||||
fake_websocket_client client (config.websocket_config.port);
|
||||
client.send_message (R"json({"action": "subscribe", "topic": "new_unconfirmed_block", "ack": "true"})json");
|
||||
client.await_ack ();
|
||||
|
|
|
@ -50,7 +50,7 @@ TEST (work, cancel)
|
|||
{
|
||||
nano::root key (1);
|
||||
pool.generate (
|
||||
nano::work_version::work_1, key, nano::network_constants ().publish_thresholds.base, [&done](boost::optional<uint64_t> work_a) {
|
||||
nano::work_version::work_1, key, nano::network_constants ().publish_thresholds.base, [&done] (boost::optional<uint64_t> work_a) {
|
||||
done = !work_a;
|
||||
});
|
||||
pool.cancel (key);
|
||||
|
@ -69,12 +69,12 @@ TEST (work, cancel_many)
|
|||
nano::root key5 (3);
|
||||
nano::root key6 (1);
|
||||
nano::network_constants constants;
|
||||
pool.generate (nano::work_version::work_1, key1, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key2, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key3, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key4, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key5, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key6, constants.publish_thresholds.base, [](boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key1, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key2, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key3, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key4, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key5, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.generate (nano::work_version::work_1, key6, constants.publish_thresholds.base, [] (boost::optional<uint64_t>) {});
|
||||
pool.cancel (key1);
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ TEST (work, opencl)
|
|||
if (opencl != nullptr)
|
||||
{
|
||||
// 0 threads, should add 1 for managing OpenCL
|
||||
nano::work_pool pool (0, std::chrono::nanoseconds (0), [&opencl](nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> & ticket_a) {
|
||||
nano::work_pool pool (0, std::chrono::nanoseconds (0), [&opencl] (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> & ticket_a) {
|
||||
return opencl->generate_work (version_a, root_a, difficulty_a);
|
||||
});
|
||||
ASSERT_NE (nullptr, pool.opencl);
|
||||
|
@ -159,7 +159,7 @@ TEST (work, difficulty)
|
|||
|
||||
TEST (work, eco_pow)
|
||||
{
|
||||
auto work_func = [](std::promise<std::chrono::nanoseconds> & promise, std::chrono::nanoseconds interval) {
|
||||
auto work_func = [] (std::promise<std::chrono::nanoseconds> & promise, std::chrono::nanoseconds interval) {
|
||||
nano::work_pool pool (1, interval);
|
||||
constexpr auto num_iterations = 5;
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ TEST (work_watcher, confirm_while_generating)
|
|||
ASSERT_TIMELY (5s, 0 != node.work.size ());
|
||||
// Attach a callback to work cancellations
|
||||
std::atomic<bool> notified{ false };
|
||||
node.observers.work_cancel.add ([¬ified, &block1](nano::root const & root_a) {
|
||||
node.observers.work_cancel.add ([¬ified, &block1] (nano::root const & root_a) {
|
||||
EXPECT_EQ (root_a, block1->root ());
|
||||
notified = true;
|
||||
});
|
||||
|
|
|
@ -6,7 +6,7 @@ nano::ipc::flatbuffer_producer::flatbuffer_producer ()
|
|||
}
|
||||
|
||||
nano::ipc::flatbuffer_producer::flatbuffer_producer (std::shared_ptr<flatbuffers::FlatBufferBuilder> const & builder_a) :
|
||||
fbb (builder_a)
|
||||
fbb (builder_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace
|
|||
void read_message_loop (std::shared_ptr<nano::ipc::ipc_client> const & connection)
|
||||
{
|
||||
auto buffer (std::make_shared<std::vector<uint8_t>> ());
|
||||
connection->async_read_message (buffer, std::chrono::seconds::max (), [buffer, connection](nano::error error_a, size_t size_a) {
|
||||
connection->async_read_message (buffer, std::chrono::seconds::max (), [buffer, connection] (nano::error error_a, size_t size_a) {
|
||||
if (!error_a)
|
||||
{
|
||||
auto verifier (flatbuffers::Verifier (buffer->data (), buffer->size ()));
|
||||
|
@ -57,11 +57,11 @@ int main (int argc, char * const * argv)
|
|||
// be improved later to handle various options, including port and address.
|
||||
std::string ipc_address = "::1";
|
||||
uint16_t ipc_port = 7077;
|
||||
connection->async_connect (ipc_address, ipc_port, [connection](nano::error err) {
|
||||
connection->async_connect (ipc_address, ipc_port, [connection] (nano::error err) {
|
||||
if (!err)
|
||||
{
|
||||
nanoapi::TopicConfirmationT conf;
|
||||
connection->async_write (nano::ipc::shared_buffer_from (conf), [connection](nano::error err, size_t size) {
|
||||
connection->async_write (nano::ipc::shared_buffer_from (conf), [connection] (nano::error err, size_t size) {
|
||||
if (!err)
|
||||
{
|
||||
std::cout << "Awaiting confirmations..." << std::endl;
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
#include <nano/lib/asio.hpp>
|
||||
|
||||
nano::shared_const_buffer::shared_const_buffer (const std::vector<uint8_t> & data) :
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (data)),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (data)),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
{
|
||||
}
|
||||
|
||||
nano::shared_const_buffer::shared_const_buffer (std::vector<uint8_t> && data) :
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (std::move (data))),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (std::move (data))),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
{
|
||||
}
|
||||
|
||||
nano::shared_const_buffer::shared_const_buffer (uint8_t data) :
|
||||
shared_const_buffer (std::vector<uint8_t>{ data })
|
||||
shared_const_buffer (std::vector<uint8_t>{ data })
|
||||
{
|
||||
}
|
||||
|
||||
nano::shared_const_buffer::shared_const_buffer (std::string const & data) :
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (data.begin (), data.end ())),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
m_data (std::make_shared<std::vector<uint8_t>> (data.begin (), data.end ())),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
{
|
||||
}
|
||||
|
||||
nano::shared_const_buffer::shared_const_buffer (std::shared_ptr<std::vector<uint8_t>> const & data) :
|
||||
m_data (data),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
m_data (data),
|
||||
m_buffer (boost::asio::buffer (*m_data))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ private:
|
|||
static_assert (boost::asio::is_const_buffer_sequence<shared_const_buffer>::value, "Not ConstBufferSequence compliant");
|
||||
|
||||
template <typename AsyncWriteStream, typename WriteHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE (WriteHandler, void(boost::system::error_code, std::size_t))
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE (WriteHandler, void (boost::system::error_code, std::size_t))
|
||||
async_write (AsyncWriteStream & s, nano::shared_const_buffer const & buffer, WriteHandler && handler)
|
||||
{
|
||||
return boost::asio::async_write (s, buffer, std::move (handler));
|
||||
|
@ -41,7 +41,7 @@ async_write (AsyncWriteStream & s, nano::shared_const_buffer const & buffer, Wri
|
|||
* @warning The buffers must be captured in the handler to ensure their lifetimes are properly extended.
|
||||
*/
|
||||
template <typename AsyncWriteStream, typename BufferType, typename WriteHandler>
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE (WriteHandler, void(boost::system::error_code, std::size_t))
|
||||
BOOST_ASIO_INITFN_RESULT_TYPE (WriteHandler, void (boost::system::error_code, std::size_t))
|
||||
unsafe_async_write (AsyncWriteStream & s, BufferType && buffer, WriteHandler && handler)
|
||||
{
|
||||
return boost::asio::async_write (s, buffer, std::move (handler));
|
||||
|
|
|
@ -221,9 +221,9 @@ void nano::send_block::block_work_set (uint64_t work_a)
|
|||
}
|
||||
|
||||
nano::send_hashables::send_hashables (nano::block_hash const & previous_a, nano::account const & destination_a, nano::amount const & balance_a) :
|
||||
previous (previous_a),
|
||||
destination (destination_a),
|
||||
balance (balance_a)
|
||||
previous (previous_a),
|
||||
destination (destination_a),
|
||||
balance (balance_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -364,14 +364,14 @@ bool nano::send_block::deserialize_json (boost::property_tree::ptree const & tre
|
|||
}
|
||||
|
||||
nano::send_block::send_block (nano::block_hash const & previous_a, nano::account const & destination_a, nano::amount const & balance_a, nano::raw_key const & prv_a, nano::public_key const & pub_a, uint64_t work_a) :
|
||||
hashables (previous_a, destination_a, balance_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
hashables (previous_a, destination_a, balance_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::send_block::send_block (bool & error_a, nano::stream & stream_a) :
|
||||
hashables (error_a, stream_a)
|
||||
hashables (error_a, stream_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -388,7 +388,7 @@ hashables (error_a, stream_a)
|
|||
}
|
||||
|
||||
nano::send_block::send_block (bool & error_a, boost::property_tree::ptree const & tree_a) :
|
||||
hashables (error_a, tree_a)
|
||||
hashables (error_a, tree_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -474,9 +474,9 @@ void nano::send_block::signature_set (nano::signature const & signature_a)
|
|||
}
|
||||
|
||||
nano::open_hashables::open_hashables (nano::block_hash const & source_a, nano::account const & representative_a, nano::account const & account_a) :
|
||||
source (source_a),
|
||||
representative (representative_a),
|
||||
account (account_a)
|
||||
source (source_a),
|
||||
representative (representative_a),
|
||||
account (account_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -525,22 +525,22 @@ void nano::open_hashables::hash (blake2b_state & hash_a) const
|
|||
}
|
||||
|
||||
nano::open_block::open_block (nano::block_hash const & source_a, nano::account const & representative_a, nano::account const & account_a, nano::raw_key const & prv_a, nano::public_key const & pub_a, uint64_t work_a) :
|
||||
hashables (source_a, representative_a, account_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
hashables (source_a, representative_a, account_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
{
|
||||
debug_assert (!representative_a.is_zero ());
|
||||
}
|
||||
|
||||
nano::open_block::open_block (nano::block_hash const & source_a, nano::account const & representative_a, nano::account const & account_a, std::nullptr_t) :
|
||||
hashables (source_a, representative_a, account_a),
|
||||
work (0)
|
||||
hashables (source_a, representative_a, account_a),
|
||||
work (0)
|
||||
{
|
||||
signature.clear ();
|
||||
}
|
||||
|
||||
nano::open_block::open_block (bool & error_a, nano::stream & stream_a) :
|
||||
hashables (error_a, stream_a)
|
||||
hashables (error_a, stream_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -557,7 +557,7 @@ hashables (error_a, stream_a)
|
|||
}
|
||||
|
||||
nano::open_block::open_block (bool & error_a, boost::property_tree::ptree const & tree_a) :
|
||||
hashables (error_a, tree_a)
|
||||
hashables (error_a, tree_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -745,8 +745,8 @@ void nano::open_block::signature_set (nano::signature const & signature_a)
|
|||
}
|
||||
|
||||
nano::change_hashables::change_hashables (nano::block_hash const & previous_a, nano::account const & representative_a) :
|
||||
previous (previous_a),
|
||||
representative (representative_a)
|
||||
previous (previous_a),
|
||||
representative (representative_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -788,14 +788,14 @@ void nano::change_hashables::hash (blake2b_state & hash_a) const
|
|||
}
|
||||
|
||||
nano::change_block::change_block (nano::block_hash const & previous_a, nano::account const & representative_a, nano::raw_key const & prv_a, nano::public_key const & pub_a, uint64_t work_a) :
|
||||
hashables (previous_a, representative_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
hashables (previous_a, representative_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::change_block::change_block (bool & error_a, nano::stream & stream_a) :
|
||||
hashables (error_a, stream_a)
|
||||
hashables (error_a, stream_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -812,7 +812,7 @@ hashables (error_a, stream_a)
|
|||
}
|
||||
|
||||
nano::change_block::change_block (bool & error_a, boost::property_tree::ptree const & tree_a) :
|
||||
hashables (error_a, tree_a)
|
||||
hashables (error_a, tree_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -994,11 +994,11 @@ void nano::change_block::signature_set (nano::signature const & signature_a)
|
|||
}
|
||||
|
||||
nano::state_hashables::state_hashables (nano::account const & account_a, nano::block_hash const & previous_a, nano::account const & representative_a, nano::amount const & balance_a, nano::link const & link_a) :
|
||||
account (account_a),
|
||||
previous (previous_a),
|
||||
representative (representative_a),
|
||||
balance (balance_a),
|
||||
link (link_a)
|
||||
account (account_a),
|
||||
previous (previous_a),
|
||||
representative (representative_a),
|
||||
balance (balance_a),
|
||||
link (link_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1061,14 +1061,14 @@ void nano::state_hashables::hash (blake2b_state & hash_a) const
|
|||
}
|
||||
|
||||
nano::state_block::state_block (nano::account const & account_a, nano::block_hash const & previous_a, nano::account const & representative_a, nano::amount const & balance_a, nano::link const & link_a, nano::raw_key const & prv_a, nano::public_key const & pub_a, uint64_t work_a) :
|
||||
hashables (account_a, previous_a, representative_a, balance_a, link_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
hashables (account_a, previous_a, representative_a, balance_a, link_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::state_block::state_block (bool & error_a, nano::stream & stream_a) :
|
||||
hashables (error_a, stream_a)
|
||||
hashables (error_a, stream_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -1086,7 +1086,7 @@ hashables (error_a, stream_a)
|
|||
}
|
||||
|
||||
nano::state_block::state_block (bool & error_a, boost::property_tree::ptree const & tree_a) :
|
||||
hashables (error_a, tree_a)
|
||||
hashables (error_a, tree_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -1506,14 +1506,14 @@ bool nano::receive_block::deserialize_json (boost::property_tree::ptree const &
|
|||
}
|
||||
|
||||
nano::receive_block::receive_block (nano::block_hash const & previous_a, nano::block_hash const & source_a, nano::raw_key const & prv_a, nano::public_key const & pub_a, uint64_t work_a) :
|
||||
hashables (previous_a, source_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
hashables (previous_a, source_a),
|
||||
signature (nano::sign_message (prv_a, pub_a, hash ())),
|
||||
work (work_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::receive_block::receive_block (bool & error_a, nano::stream & stream_a) :
|
||||
hashables (error_a, stream_a)
|
||||
hashables (error_a, stream_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -1530,7 +1530,7 @@ hashables (error_a, stream_a)
|
|||
}
|
||||
|
||||
nano::receive_block::receive_block (bool & error_a, boost::property_tree::ptree const & tree_a) :
|
||||
hashables (error_a, tree_a)
|
||||
hashables (error_a, tree_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -1620,8 +1620,8 @@ nano::block_type nano::receive_block::type () const
|
|||
}
|
||||
|
||||
nano::receive_hashables::receive_hashables (nano::block_hash const & previous_a, nano::block_hash const & source_a) :
|
||||
previous (previous_a),
|
||||
source (source_a)
|
||||
previous (previous_a),
|
||||
source (source_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1663,7 +1663,7 @@ void nano::receive_hashables::hash (blake2b_state & hash_a) const
|
|||
}
|
||||
|
||||
nano::block_details::block_details (nano::epoch const epoch_a, bool const is_send_a, bool const is_receive_a, bool const is_epoch_a) :
|
||||
epoch (epoch_a), is_send (is_send_a), is_receive (is_receive_a), is_epoch (is_epoch_a)
|
||||
epoch (epoch_a), is_send (is_send_a), is_receive (is_receive_a), is_epoch (is_epoch_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1735,24 +1735,24 @@ std::string nano::state_subtype (nano::block_details const details_a)
|
|||
}
|
||||
|
||||
nano::block_sideband::block_sideband (nano::account const & account_a, nano::block_hash const & successor_a, nano::amount const & balance_a, uint64_t const height_a, uint64_t const timestamp_a, nano::block_details const & details_a, nano::epoch const source_epoch_a) :
|
||||
successor (successor_a),
|
||||
account (account_a),
|
||||
balance (balance_a),
|
||||
height (height_a),
|
||||
timestamp (timestamp_a),
|
||||
details (details_a),
|
||||
source_epoch (source_epoch_a)
|
||||
successor (successor_a),
|
||||
account (account_a),
|
||||
balance (balance_a),
|
||||
height (height_a),
|
||||
timestamp (timestamp_a),
|
||||
details (details_a),
|
||||
source_epoch (source_epoch_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::block_sideband::block_sideband (nano::account const & account_a, nano::block_hash const & successor_a, nano::amount const & balance_a, uint64_t const height_a, uint64_t const timestamp_a, nano::epoch const epoch_a, bool const is_send, bool const is_receive, bool const is_epoch, nano::epoch const source_epoch_a) :
|
||||
successor (successor_a),
|
||||
account (account_a),
|
||||
balance (balance_a),
|
||||
height (height_a),
|
||||
timestamp (timestamp_a),
|
||||
details (epoch_a, is_send, is_receive, is_epoch),
|
||||
source_epoch (source_epoch_a)
|
||||
successor (successor_a),
|
||||
account (account_a),
|
||||
balance (balance_a),
|
||||
height (height_a),
|
||||
timestamp (timestamp_a),
|
||||
details (epoch_a, is_send, is_receive, is_epoch),
|
||||
source_epoch (source_epoch_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -92,9 +92,9 @@ struct work_thresholds
|
|||
uint64_t const entry;
|
||||
|
||||
constexpr work_thresholds (uint64_t epoch_1_a, uint64_t epoch_2_a, uint64_t epoch_2_receive_a) :
|
||||
epoch_1 (epoch_1_a), epoch_2 (epoch_2_a), epoch_2_receive (epoch_2_receive_a),
|
||||
base (std::max ({ epoch_1, epoch_2, epoch_2_receive })),
|
||||
entry (std::min ({ epoch_1, epoch_2, epoch_2_receive }))
|
||||
epoch_1 (epoch_1_a), epoch_2 (epoch_2_a), epoch_2_receive (epoch_2_receive_a),
|
||||
base (std::max ({ epoch_1, epoch_2, epoch_2_receive })),
|
||||
entry (std::min ({ epoch_1, epoch_2, epoch_2_receive }))
|
||||
{
|
||||
}
|
||||
work_thresholds () = delete;
|
||||
|
@ -108,13 +108,13 @@ class network_constants
|
|||
{
|
||||
public:
|
||||
network_constants () :
|
||||
network_constants (network_constants::active_network)
|
||||
network_constants (network_constants::active_network)
|
||||
{
|
||||
}
|
||||
|
||||
network_constants (nano_networks network_a) :
|
||||
current_network (network_a),
|
||||
publish_thresholds (is_live_network () ? publish_full : is_beta_network () ? publish_beta : is_test_network () ? publish_test : publish_dev)
|
||||
current_network (network_a),
|
||||
publish_thresholds (is_live_network () ? publish_full : is_beta_network () ? publish_beta : is_test_network () ? publish_test : publish_dev)
|
||||
{
|
||||
// A representative is classified as principal based on its weight and this factor
|
||||
principal_weight_factor = 1000; // 0.1%
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace nano
|
|||
/** Type trait to determine if T is compatible with boost's lexical_cast */
|
||||
template <class T>
|
||||
struct is_lexical_castable : std::integral_constant<bool,
|
||||
(std::is_default_constructible<T>::value && (boost::has_right_shift<std::basic_istream<wchar_t>, T>::value || boost::has_right_shift<std::basic_istream<char>, T>::value))>
|
||||
(std::is_default_constructible<T>::value && (boost::has_right_shift<std::basic_istream<wchar_t>, T>::value || boost::has_right_shift<std::basic_istream<char>, T>::value))>
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -42,7 +42,7 @@ class configbase : public nano::error_aware<>
|
|||
public:
|
||||
configbase () = default;
|
||||
configbase (std::shared_ptr<nano::error> const & error_a) :
|
||||
error (error_a)
|
||||
error (error_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ nano::link const & nano::epochs::link (nano::epoch epoch_a) const
|
|||
|
||||
bool nano::epochs::is_epoch_link (nano::link const & link_a) const
|
||||
{
|
||||
return std::any_of (epochs_m.begin (), epochs_m.end (), [&link_a](auto const & item_a) { return item_a.second.link == link_a; });
|
||||
return std::any_of (epochs_m.begin (), epochs_m.end (), [&link_a] (auto const & item_a) { return item_a.second.link == link_a; });
|
||||
}
|
||||
|
||||
nano::public_key const & nano::epochs::signer (nano::epoch epoch_a) const
|
||||
|
@ -18,7 +18,7 @@ nano::public_key const & nano::epochs::signer (nano::epoch epoch_a) const
|
|||
|
||||
nano::epoch nano::epochs::epoch (nano::link const & link_a) const
|
||||
{
|
||||
auto existing (std::find_if (epochs_m.begin (), epochs_m.end (), [&link_a](auto const & item_a) { return item_a.second.link == link_a; }));
|
||||
auto existing (std::find_if (epochs_m.begin (), epochs_m.end (), [&link_a] (auto const & item_a) { return item_a.second.link == link_a; }));
|
||||
debug_assert (existing != epochs_m.end ());
|
||||
return existing->first;
|
||||
}
|
||||
|
|
|
@ -209,7 +209,7 @@ namespace std
|
|||
{
|
||||
template <>
|
||||
struct is_error_code_enum<boost::system::errc::errc_t>
|
||||
: public std::true_type
|
||||
: public std::true_type
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -262,7 +262,7 @@ public:
|
|||
{
|
||||
// Convert variadic arguments to std::error_code
|
||||
auto codes = { std::error_code (err)... };
|
||||
if (std::any_of (codes.begin (), codes.end (), [this, &codes](auto & code_a) { return code == code_a; }))
|
||||
if (std::any_of (codes.begin (), codes.end (), [this, &codes] (auto & code_a) { return code == code_a; }))
|
||||
{
|
||||
code.clear ();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <nano/lib/utility.hpp>
|
||||
|
||||
nano::ipc::socket_base::socket_base (boost::asio::io_context & io_ctx_a) :
|
||||
io_timer (io_ctx_a)
|
||||
io_timer (io_ctx_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ void nano::ipc::socket_base::timer_start (std::chrono::seconds timeout_a)
|
|||
if (timeout_a < std::chrono::seconds::max ())
|
||||
{
|
||||
io_timer.expires_from_now (boost::posix_time::seconds (static_cast<long> (timeout_a.count ())));
|
||||
io_timer.async_wait ([this](const boost::system::error_code & ec) {
|
||||
io_timer.async_wait ([this] (const boost::system::error_code & ec) {
|
||||
if (!ec)
|
||||
{
|
||||
this->timer_expired ();
|
||||
|
@ -33,7 +33,7 @@ void nano::ipc::socket_base::timer_cancel ()
|
|||
}
|
||||
|
||||
nano::ipc::dsock_file_remover::dsock_file_remover (std::string const & file_a) :
|
||||
filename (file_a)
|
||||
filename (file_a)
|
||||
{
|
||||
std::remove (filename.c_str ());
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ namespace
|
|||
class channel
|
||||
{
|
||||
public:
|
||||
virtual void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
virtual void async_write (nano::shared_const_buffer const & buffer_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
virtual void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
virtual void async_write (nano::shared_const_buffer const & buffer_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
|
||||
/**
|
||||
* Read a length-prefixed message asynchronously using the given timeout. This is suitable for full duplex scenarios where it may
|
||||
|
@ -30,7 +30,7 @@ public:
|
|||
* @param timeout_a How long to await message data. In some scenarios, such as waiting for data on subscriptions, specifying std::chrono::seconds::max() makes sense.
|
||||
* @param callback_a If called without errors, the payload buffer is successfully populated
|
||||
*/
|
||||
virtual void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
virtual void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) = 0;
|
||||
};
|
||||
|
||||
/* Boost v1.70 introduced breaking changes; the conditional compilation allows 1.6x to be supported as well. */
|
||||
|
@ -46,15 +46,15 @@ class socket_client : public nano::ipc::socket_base, public channel, public std:
|
|||
{
|
||||
public:
|
||||
socket_client (boost::asio::io_context & io_ctx_a, ENDPOINT_TYPE endpoint_a) :
|
||||
socket_base (io_ctx_a), endpoint (endpoint_a), socket (io_ctx_a), resolver (io_ctx_a), strand (io_ctx_a.get_executor ())
|
||||
socket_base (io_ctx_a), endpoint (endpoint_a), socket (io_ctx_a), resolver (io_ctx_a), strand (io_ctx_a.get_executor ())
|
||||
{
|
||||
}
|
||||
|
||||
void async_resolve (std::string const & host_a, uint16_t port_a, std::function<void(boost::system::error_code const &, boost::asio::ip::tcp::endpoint)> callback_a)
|
||||
void async_resolve (std::string const & host_a, uint16_t port_a, std::function<void (boost::system::error_code const &, boost::asio::ip::tcp::endpoint)> callback_a)
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
this_l->timer_start (io_timeout);
|
||||
resolver.async_resolve (boost::asio::ip::tcp::resolver::query (host_a, std::to_string (port_a)), [this_l, callback_a](boost::system::error_code const & ec, boost::asio::ip::tcp::resolver::iterator endpoint_iterator_a) {
|
||||
resolver.async_resolve (boost::asio::ip::tcp::resolver::query (host_a, std::to_string (port_a)), [this_l, callback_a] (boost::system::error_code const & ec, boost::asio::ip::tcp::resolver::iterator endpoint_iterator_a) {
|
||||
this_l->timer_cancel ();
|
||||
boost::asio::ip::tcp::resolver::iterator end;
|
||||
if (!ec && endpoint_iterator_a != end)
|
||||
|
@ -69,31 +69,31 @@ public:
|
|||
});
|
||||
}
|
||||
|
||||
void async_connect (std::function<void(boost::system::error_code const &)> callback_a)
|
||||
void async_connect (std::function<void (boost::system::error_code const &)> callback_a)
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
this_l->timer_start (io_timeout);
|
||||
socket.async_connect (endpoint, boost::asio::bind_executor (strand, [this_l, callback_a](boost::system::error_code const & ec) {
|
||||
socket.async_connect (endpoint, boost::asio::bind_executor (strand, [this_l, callback_a] (boost::system::error_code const & ec) {
|
||||
this_l->timer_cancel ();
|
||||
callback_a (ec);
|
||||
}));
|
||||
}
|
||||
|
||||
void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) override
|
||||
void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) override
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
this_l->timer_start (io_timeout);
|
||||
buffer_a->resize (size_a);
|
||||
boost::asio::async_read (socket, boost::asio::buffer (buffer_a->data (), size_a), boost::asio::bind_executor (this_l->strand, [this_l, buffer_a, callback_a](boost::system::error_code const & ec, size_t size_a) {
|
||||
boost::asio::async_read (socket, boost::asio::buffer (buffer_a->data (), size_a), boost::asio::bind_executor (this_l->strand, [this_l, buffer_a, callback_a] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->timer_cancel ();
|
||||
callback_a (ec, size_a);
|
||||
}));
|
||||
}
|
||||
|
||||
void async_write (nano::shared_const_buffer const & buffer_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) override
|
||||
void async_write (nano::shared_const_buffer const & buffer_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) override
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [buffer_a, callback_a, this_l]() {
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [buffer_a, callback_a, this_l] () {
|
||||
bool write_in_progress = !this_l->send_queue.empty ();
|
||||
auto queue_size = this_l->send_queue.size ();
|
||||
if (queue_size < this_l->queue_size_max)
|
||||
|
@ -114,7 +114,7 @@ public:
|
|||
this_l->timer_start (io_timeout);
|
||||
nano::async_write (socket, msg.buffer,
|
||||
boost::asio::bind_executor (strand,
|
||||
[msg, this_l](boost::system::error_code ec, std::size_t size_a) {
|
||||
[msg, this_l] (boost::system::error_code ec, std::size_t size_a) {
|
||||
this_l->timer_cancel ();
|
||||
|
||||
if (msg.callback)
|
||||
|
@ -130,13 +130,13 @@ public:
|
|||
}));
|
||||
}
|
||||
|
||||
void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) override
|
||||
void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) override
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
this_l->timer_start (timeout_a);
|
||||
buffer_a->resize (4);
|
||||
// Read 32 bit big-endian length
|
||||
boost::asio::async_read (socket, boost::asio::buffer (buffer_a->data (), 4), boost::asio::bind_executor (this_l->strand, [this_l, timeout_a, buffer_a, callback_a](boost::system::error_code const & ec, size_t size_a) {
|
||||
boost::asio::async_read (socket, boost::asio::buffer (buffer_a->data (), 4), boost::asio::bind_executor (this_l->strand, [this_l, timeout_a, buffer_a, callback_a] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->timer_cancel ();
|
||||
if (!ec)
|
||||
{
|
||||
|
@ -144,7 +144,7 @@ public:
|
|||
buffer_a->resize (payload_size_l);
|
||||
// Read payload
|
||||
this_l->timer_start (timeout_a);
|
||||
this_l->async_read (buffer_a, payload_size_l, [this_l, buffer_a, callback_a](boost::system::error_code const & ec_a, size_t size_a) {
|
||||
this_l->async_read (buffer_a, payload_size_l, [this_l, buffer_a, callback_a] (boost::system::error_code const & ec_a, size_t size_a) {
|
||||
this_l->timer_cancel ();
|
||||
callback_a (ec_a, size_a);
|
||||
});
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
void close () override
|
||||
{
|
||||
auto this_l (this->shared_from_this ());
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [this_l]() {
|
||||
boost::asio::post (strand, boost::asio::bind_executor (strand, [this_l] () {
|
||||
this_l->socket.shutdown (boost::asio::ip::tcp::socket::shutdown_both);
|
||||
this_l->socket.close ();
|
||||
}));
|
||||
|
@ -171,12 +171,12 @@ private:
|
|||
class queue_item
|
||||
{
|
||||
public:
|
||||
queue_item (nano::shared_const_buffer const & buffer_a, std::function<void(boost::system::error_code const &, size_t)> callback_a) :
|
||||
buffer (buffer_a), callback (callback_a)
|
||||
queue_item (nano::shared_const_buffer const & buffer_a, std::function<void (boost::system::error_code const &, size_t)> callback_a) :
|
||||
buffer (buffer_a), callback (callback_a)
|
||||
{
|
||||
}
|
||||
nano::shared_const_buffer buffer;
|
||||
std::function<void(boost::system::error_code const &, size_t)> callback;
|
||||
std::function<void (boost::system::error_code const &, size_t)> callback;
|
||||
};
|
||||
size_t const queue_size_max = 64 * 1024;
|
||||
/** The send queue is protected by always being accessed through the strand */
|
||||
|
@ -197,18 +197,18 @@ class client_impl : public nano::ipc::ipc_client_impl
|
|||
{
|
||||
public:
|
||||
explicit client_impl (boost::asio::io_context & io_ctx_a) :
|
||||
io_ctx (io_ctx_a)
|
||||
io_ctx (io_ctx_a)
|
||||
{
|
||||
}
|
||||
|
||||
void connect (std::string const & host_a, uint16_t port_a, std::function<void(nano::error)> callback_a)
|
||||
void connect (std::string const & host_a, uint16_t port_a, std::function<void (nano::error)> callback_a)
|
||||
{
|
||||
tcp_client = std::make_shared<socket_client<socket_type, boost::asio::ip::tcp::endpoint>> (io_ctx, boost::asio::ip::tcp::endpoint (boost::asio::ip::tcp::v6 (), port_a));
|
||||
|
||||
tcp_client->async_resolve (host_a, port_a, [this, callback_a](boost::system::error_code const & ec_resolve_a, boost::asio::ip::tcp::endpoint endpoint_a) {
|
||||
tcp_client->async_resolve (host_a, port_a, [this, callback_a] (boost::system::error_code const & ec_resolve_a, boost::asio::ip::tcp::endpoint endpoint_a) {
|
||||
if (!ec_resolve_a)
|
||||
{
|
||||
this->tcp_client->async_connect ([callback_a](const boost::system::error_code & ec_connect_a) {
|
||||
this->tcp_client->async_connect ([callback_a] (const boost::system::error_code & ec_connect_a) {
|
||||
callback_a (nano::error (ec_connect_a));
|
||||
});
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ private:
|
|||
}
|
||||
|
||||
nano::ipc::ipc_client::ipc_client (boost::asio::io_context & io_ctx_a) :
|
||||
io_ctx (io_ctx_a)
|
||||
io_ctx (io_ctx_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ nano::error nano::ipc::ipc_client::connect (std::string const & path_a)
|
|||
return boost::polymorphic_downcast<client_impl *> (impl.get ())->connect (path_a);
|
||||
}
|
||||
|
||||
void nano::ipc::ipc_client::async_connect (std::string const & host_a, uint16_t port_a, std::function<void(nano::error)> callback_a)
|
||||
void nano::ipc::ipc_client::async_connect (std::string const & host_a, uint16_t port_a, std::function<void (nano::error)> callback_a)
|
||||
{
|
||||
impl = std::make_unique<client_impl> (io_ctx);
|
||||
auto client (boost::polymorphic_downcast<client_impl *> (impl.get ()));
|
||||
|
@ -269,33 +269,33 @@ void nano::ipc::ipc_client::async_connect (std::string const & host_a, uint16_t
|
|||
nano::error nano::ipc::ipc_client::connect (std::string const & host, uint16_t port)
|
||||
{
|
||||
std::promise<nano::error> result_l;
|
||||
async_connect (host, port, [&result_l](nano::error err_a) {
|
||||
async_connect (host, port, [&result_l] (nano::error err_a) {
|
||||
result_l.set_value (err_a);
|
||||
});
|
||||
return result_l.get_future ().get ();
|
||||
}
|
||||
|
||||
void nano::ipc::ipc_client::async_write (nano::shared_const_buffer const & buffer_a, std::function<void(nano::error, size_t)> callback_a)
|
||||
void nano::ipc::ipc_client::async_write (nano::shared_const_buffer const & buffer_a, std::function<void (nano::error, size_t)> callback_a)
|
||||
{
|
||||
auto client (boost::polymorphic_downcast<client_impl *> (impl.get ()));
|
||||
client->get_channel ().async_write (buffer_a, [callback_a](const boost::system::error_code & ec_a, size_t bytes_written_a) {
|
||||
client->get_channel ().async_write (buffer_a, [callback_a] (const boost::system::error_code & ec_a, size_t bytes_written_a) {
|
||||
callback_a (nano::error (ec_a), bytes_written_a);
|
||||
});
|
||||
}
|
||||
|
||||
void nano::ipc::ipc_client::async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void(nano::error, size_t)> callback_a)
|
||||
void nano::ipc::ipc_client::async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void (nano::error, size_t)> callback_a)
|
||||
{
|
||||
auto client (boost::polymorphic_downcast<client_impl *> (impl.get ()));
|
||||
client->get_channel ().async_read (buffer_a, size_a, [callback_a, buffer_a](const boost::system::error_code & ec_a, size_t bytes_read_a) {
|
||||
client->get_channel ().async_read (buffer_a, size_a, [callback_a, buffer_a] (const boost::system::error_code & ec_a, size_t bytes_read_a) {
|
||||
callback_a (nano::error (ec_a), bytes_read_a);
|
||||
});
|
||||
}
|
||||
|
||||
/** Read a length-prefixed message asynchronously. Received length must be a big endian 32-bit unsigned integer. */
|
||||
void nano::ipc::ipc_client::async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void(nano::error, size_t)> callback_a)
|
||||
void nano::ipc::ipc_client::async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void (nano::error, size_t)> callback_a)
|
||||
{
|
||||
auto client (boost::polymorphic_downcast<client_impl *> (impl.get ()));
|
||||
client->get_channel ().async_read_message (buffer_a, timeout_a, [callback_a, buffer_a](const boost::system::error_code & ec_a, size_t bytes_read_a) {
|
||||
client->get_channel ().async_read_message (buffer_a, timeout_a, [callback_a, buffer_a] (const boost::system::error_code & ec_a, size_t bytes_read_a) {
|
||||
callback_a (nano::error (ec_a), bytes_read_a);
|
||||
});
|
||||
}
|
||||
|
@ -342,12 +342,12 @@ std::string nano::ipc::request (nano::ipc::payload_encoding encoding_a, nano::ip
|
|||
auto res (std::make_shared<std::vector<uint8_t>> ());
|
||||
|
||||
std::promise<std::string> result_l;
|
||||
ipc_client.async_write (req, [&ipc_client, &res, &result_l](nano::error err_a, size_t size_a) {
|
||||
ipc_client.async_write (req, [&ipc_client, &res, &result_l] (nano::error err_a, size_t size_a) {
|
||||
// Read length
|
||||
ipc_client.async_read (res, sizeof (uint32_t), [&ipc_client, &res, &result_l](nano::error err_read_a, size_t size_read_a) {
|
||||
ipc_client.async_read (res, sizeof (uint32_t), [&ipc_client, &res, &result_l] (nano::error err_read_a, size_t size_read_a) {
|
||||
uint32_t payload_size_l = boost::endian::big_to_native (*reinterpret_cast<uint32_t *> (res->data ()));
|
||||
// Read json payload
|
||||
ipc_client.async_read (res, payload_size_l, [&res, &result_l](nano::error err_read_a, size_t size_read_a) {
|
||||
ipc_client.async_read (res, payload_size_l, [&res, &result_l] (nano::error err_read_a, size_t size_read_a) {
|
||||
result_l.set_value (std::string (res->begin (), res->end ()));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -38,13 +38,13 @@ namespace ipc
|
|||
nano::error connect (std::string const & host, uint16_t port);
|
||||
|
||||
/** Connect to a tcp socket asynchronously */
|
||||
void async_connect (std::string const & host, uint16_t port, std::function<void(nano::error)> callback);
|
||||
void async_connect (std::string const & host, uint16_t port, std::function<void (nano::error)> callback);
|
||||
|
||||
/** Write buffer asynchronously */
|
||||
void async_write (nano::shared_const_buffer const & buffer_a, std::function<void(nano::error, size_t)> callback_a);
|
||||
void async_write (nano::shared_const_buffer const & buffer_a, std::function<void (nano::error, size_t)> callback_a);
|
||||
|
||||
/** Read \p size_a bytes asynchronously */
|
||||
void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void(nano::error, size_t)> callback_a);
|
||||
void async_read (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, size_t size_a, std::function<void (nano::error, size_t)> callback_a);
|
||||
|
||||
/**
|
||||
* Read a length-prefixed message asynchronously using the given timeout. This is suitable for full duplex scenarios where it may
|
||||
|
@ -54,7 +54,7 @@ namespace ipc
|
|||
* @param timeout_a How long to await message data. In some scenarios, such as waiting for data on subscriptions, specifying std::chrono::seconds::max() makes sense.
|
||||
* @param callback_a If called without errors, the payload buffer is successfully populated
|
||||
*/
|
||||
void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void(nano::error, size_t)> callback_a);
|
||||
void async_read_message (std::shared_ptr<std::vector<uint8_t>> const & buffer_a, std::chrono::seconds timeout_a, std::function<void (nano::error, size_t)> callback_a);
|
||||
|
||||
private:
|
||||
boost::asio::io_context & io_ctx;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace nano
|
||||
{
|
||||
inline void json_error_response (std::function<void(std::string const &)> response_a, std::string const & message_a)
|
||||
inline void json_error_response (std::function<void (std::string const &)> response_a, std::string const & message_a)
|
||||
{
|
||||
boost::property_tree::ptree response_l;
|
||||
response_l.put ("error", message_a);
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
#include <cstddef>
|
||||
|
||||
nano::jsonconfig::jsonconfig () :
|
||||
tree (tree_default)
|
||||
tree (tree_default)
|
||||
{
|
||||
error = std::make_shared<nano::error> ();
|
||||
}
|
||||
|
||||
nano::jsonconfig::jsonconfig (boost::property_tree::ptree & tree_a, std::shared_ptr<nano::error> const & error_a) :
|
||||
nano::configbase (error_a), tree (tree_a)
|
||||
nano::configbase (error_a), tree (tree_a)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
|
@ -192,7 +192,7 @@ nano::jsonconfig & nano::jsonconfig::get_config (bool optional, std::string key,
|
|||
|
||||
nano::jsonconfig & nano::jsonconfig::get_config (bool optional, std::string key, bool & target, bool default_value)
|
||||
{
|
||||
auto bool_conv = [this, &target, &key, optional](std::string val) {
|
||||
auto bool_conv = [this, &target, &key, optional] (std::string val) {
|
||||
if (val == "true")
|
||||
{
|
||||
target = true;
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
|
||||
/** Iterate array entries */
|
||||
template <typename T>
|
||||
jsonconfig & array_entries (std::function<void(T)> callback)
|
||||
jsonconfig & array_entries (std::function<void (T)> callback)
|
||||
{
|
||||
for (auto & entry : tree)
|
||||
{
|
||||
|
|
|
@ -19,7 +19,7 @@ void output (const char * str, std::chrono::milliseconds time, Mutex & mutex)
|
|||
// Guard standard out to keep the output from being interleaved
|
||||
std::lock_guard guard (cout_mutex);
|
||||
std::cout << (boost::format ("%1% Mutex %2% %3% for %4%ms\n%5%") % std::addressof (mutex) % mutex.get_name () % str % time.count () % stacktrace).str ()
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
template <typename Mutex>
|
||||
|
@ -59,7 +59,7 @@ void output_if_blocked_long_enough (nano::timer<std::chrono::milliseconds> & tim
|
|||
#endif
|
||||
|
||||
lock_guard<nano::mutex>::lock_guard (nano::mutex & mutex) :
|
||||
mut (mutex)
|
||||
mut (mutex)
|
||||
{
|
||||
timer.start ();
|
||||
|
||||
|
@ -77,14 +77,14 @@ lock_guard<nano::mutex>::~lock_guard () noexcept
|
|||
|
||||
template <typename Mutex, typename U>
|
||||
unique_lock<Mutex, U>::unique_lock (Mutex & mutex) :
|
||||
mut (std::addressof (mutex))
|
||||
mut (std::addressof (mutex))
|
||||
{
|
||||
lock_impl ();
|
||||
}
|
||||
|
||||
template <typename Mutex, typename U>
|
||||
unique_lock<Mutex, U>::unique_lock (Mutex & mutex, std::defer_lock_t) noexcept :
|
||||
mut (std::addressof (mutex))
|
||||
mut (std::addressof (mutex))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ public:
|
|||
mutex () = default;
|
||||
mutex (const char * name_a)
|
||||
#if USING_NANO_TIMED_LOCKS
|
||||
:
|
||||
name (name_a)
|
||||
:
|
||||
name (name_a)
|
||||
#endif
|
||||
{
|
||||
#if USING_NANO_TIMED_LOCKS
|
||||
|
@ -120,7 +120,7 @@ class lock_guard final
|
|||
{
|
||||
public:
|
||||
explicit lock_guard (Mutex & mutex_a) :
|
||||
guard (mutex_a)
|
||||
guard (mutex_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -266,14 +266,14 @@ public:
|
|||
|
||||
template <typename... Args>
|
||||
locked (Args &&... args) :
|
||||
obj (std::forward<Args> (args)...)
|
||||
obj (std::forward<Args> (args)...)
|
||||
{
|
||||
}
|
||||
|
||||
struct scoped_lock final
|
||||
{
|
||||
scoped_lock (locked * owner_a) :
|
||||
owner (owner_a)
|
||||
owner (owner_a)
|
||||
{
|
||||
owner->mutex.lock ();
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public:
|
|||
* @param min_log_delta_a The minimum time between successive output
|
||||
*/
|
||||
explicit logger_mt (std::chrono::milliseconds const & min_log_delta_a) :
|
||||
min_log_delta (min_log_delta_a)
|
||||
min_log_delta (min_log_delta_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ void nano::set_use_memory_pools (bool use_memory_pools_a)
|
|||
#endif
|
||||
}
|
||||
|
||||
nano::cleanup_guard::cleanup_guard (std::vector<std::function<void()>> const & cleanup_funcs_a) :
|
||||
cleanup_funcs (cleanup_funcs_a)
|
||||
nano::cleanup_guard::cleanup_guard (std::vector<std::function<void ()>> const & cleanup_funcs_a) :
|
||||
cleanup_funcs (cleanup_funcs_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ bool purge_shared_ptr_singleton_pool_memory ()
|
|||
class cleanup_guard final
|
||||
{
|
||||
public:
|
||||
cleanup_guard (std::vector<std::function<void()>> const & cleanup_funcs_a);
|
||||
cleanup_guard (std::vector<std::function<void ()>> const & cleanup_funcs_a);
|
||||
~cleanup_guard ();
|
||||
|
||||
private:
|
||||
std::vector<std::function<void()>> cleanup_funcs;
|
||||
std::vector<std::function<void ()>> cleanup_funcs;
|
||||
};
|
||||
|
||||
template <typename T, typename... Args>
|
||||
|
|
|
@ -782,7 +782,7 @@ std::string nano::uint128_union::to_string_dec () const
|
|||
}
|
||||
|
||||
nano::hash_or_account::hash_or_account (uint64_t value_a) :
|
||||
raw (value_a)
|
||||
raw (value_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ public:
|
|||
optional_ptr () = default;
|
||||
|
||||
optional_ptr (T const & value) :
|
||||
ptr (new T{ value })
|
||||
ptr (new T{ value })
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -57,9 +57,9 @@ class rpc_handler_interface
|
|||
public:
|
||||
virtual ~rpc_handler_interface () = default;
|
||||
/** Process RPC 1.0 request. */
|
||||
virtual void process_request (std::string const & action, std::string const & body, std::function<void(std::string const &)> response) = 0;
|
||||
virtual void process_request (std::string const & action, std::string const & body, std::function<void (std::string const &)> response) = 0;
|
||||
/** Process RPC 2.0 request. This is called via the IPC API */
|
||||
virtual void process_request_v2 (rpc_handler_request_params const & params_a, std::string const & body, std::function<void(std::shared_ptr<std::string> const &)> response) = 0;
|
||||
virtual void process_request_v2 (rpc_handler_request_params const & params_a, std::string const & body, std::function<void (std::shared_ptr<std::string> const &)> response) = 0;
|
||||
virtual void stop () = 0;
|
||||
virtual void rpc_instance (nano::rpc & rpc) = 0;
|
||||
};
|
||||
|
|
|
@ -55,14 +55,14 @@ nano::error nano::rpc_secure_config::deserialize_toml (nano::tomlconfig & toml)
|
|||
}
|
||||
|
||||
nano::rpc_config::rpc_config () :
|
||||
address (boost::asio::ip::address_v6::loopback ().to_string ())
|
||||
address (boost::asio::ip::address_v6::loopback ().to_string ())
|
||||
{
|
||||
}
|
||||
|
||||
nano::rpc_config::rpc_config (uint16_t port_a, bool enable_control_a) :
|
||||
address (boost::asio::ip::address_v6::loopback ().to_string ()),
|
||||
port (port_a),
|
||||
enable_control (enable_control_a)
|
||||
address (boost::asio::ip::address_v6::loopback ().to_string ()),
|
||||
port (port_a),
|
||||
enable_control (enable_control_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ nano::error nano::rpc_config::deserialize_toml (nano::tomlconfig & toml)
|
|||
}
|
||||
|
||||
nano::rpc_process_config::rpc_process_config () :
|
||||
ipc_address (boost::asio::ip::address_v6::loopback ().to_string ())
|
||||
ipc_address (boost::asio::ip::address_v6::loopback ().to_string ())
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -200,8 +200,8 @@ nano::error read_rpc_config_toml (boost::filesystem::path const & data_path_a, n
|
|||
if (boost::filesystem::exists (toml_config_path))
|
||||
{
|
||||
error = "Both json and toml rpc configuration files exists. "
|
||||
"Either remove the config.json file and restart, or remove "
|
||||
"the config-rpc.toml file to start migration on next launch.";
|
||||
"Either remove the config.json file and restart, or remove "
|
||||
"the config-rpc.toml file to start migration on next launch.";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -175,7 +175,7 @@ public:
|
|||
std::string filename;
|
||||
|
||||
explicit file_writer (std::string const & filename) :
|
||||
filename (filename)
|
||||
filename (filename)
|
||||
{
|
||||
log.open (filename.c_str (), std::ofstream::out);
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ std::vector<nano::stat_histogram::bin> nano::stat_histogram::get_bins () const
|
|||
}
|
||||
|
||||
nano::stat::stat (nano::stat_config config) :
|
||||
config (config)
|
||||
config (config)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ public:
|
|||
{
|
||||
public:
|
||||
bin (uint64_t start_inclusive_a, uint64_t end_exclusive_a) :
|
||||
start_inclusive (start_inclusive_a), end_exclusive (end_exclusive_a)
|
||||
start_inclusive (start_inclusive_a), end_exclusive (end_exclusive_a)
|
||||
{
|
||||
}
|
||||
uint64_t start_inclusive;
|
||||
|
@ -120,7 +120,7 @@ class stat_entry final
|
|||
{
|
||||
public:
|
||||
stat_entry (size_t capacity, size_t interval) :
|
||||
samples (capacity), sample_interval (interval)
|
||||
samples (capacity), sample_interval (interval)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -516,12 +516,12 @@ public:
|
|||
* To avoid recursion, the observer callback must only use the received data point snapshop, not query the stat object.
|
||||
* @param observer The observer receives a snapshot of the current samples.
|
||||
*/
|
||||
void observe_sample (stat::type type, stat::detail detail, stat::dir dir, std::function<void(boost::circular_buffer<stat_datapoint> &)> observer)
|
||||
void observe_sample (stat::type type, stat::detail detail, stat::dir dir, std::function<void (boost::circular_buffer<stat_datapoint> &)> observer)
|
||||
{
|
||||
get_entry (key_of (type, detail, dir))->sample_observers.add (observer);
|
||||
}
|
||||
|
||||
void observe_sample (stat::type type, stat::dir dir, std::function<void(boost::circular_buffer<stat_datapoint> &)> observer)
|
||||
void observe_sample (stat::type type, stat::dir dir, std::function<void (boost::circular_buffer<stat_datapoint> &)> observer)
|
||||
{
|
||||
observe_sample (type, stat::detail::all, dir, observer);
|
||||
}
|
||||
|
@ -531,7 +531,7 @@ public:
|
|||
* To avoid recursion, the observer callback must only use the received counts, not query the stat object.
|
||||
* @param observer The observer receives the old and the new count.
|
||||
*/
|
||||
void observe_count (stat::type type, stat::detail detail, stat::dir dir, std::function<void(uint64_t, uint64_t)> observer)
|
||||
void observe_count (stat::type type, stat::detail detail, stat::dir dir, std::function<void (uint64_t, uint64_t)> observer)
|
||||
{
|
||||
get_entry (key_of (type, detail, dir))->count_observers.add (observer);
|
||||
}
|
||||
|
|
|
@ -120,14 +120,14 @@ void nano::thread_attributes::set (boost::thread::attributes & attrs)
|
|||
}
|
||||
|
||||
nano::thread_runner::thread_runner (boost::asio::io_context & io_ctx_a, unsigned service_threads_a) :
|
||||
io_guard (boost::asio::make_work_guard (io_ctx_a))
|
||||
io_guard (boost::asio::make_work_guard (io_ctx_a))
|
||||
{
|
||||
boost::thread::attributes attrs;
|
||||
nano::thread_attributes::set (attrs);
|
||||
auto count = (is_sanitizer_build && nano::network_constants{}.is_dev_network ()) ? 1 : service_threads_a; // This is a workaround to a bad interaction between TSAN, multiple coroutines, and multiple threads servicing io_context. Only use 1 thread if sanitizers are attached
|
||||
for (auto i (0u); i < count; ++i)
|
||||
{
|
||||
threads.emplace_back (attrs, [&io_ctx_a]() {
|
||||
threads.emplace_back (attrs, [&io_ctx_a] () {
|
||||
nano::thread_role::set (nano::thread_role::name::io);
|
||||
try
|
||||
{
|
||||
|
@ -197,8 +197,8 @@ void nano::thread_runner::stop_event_processing ()
|
|||
}
|
||||
|
||||
nano::thread_pool::thread_pool (unsigned num_threads, nano::thread_role::name thread_name) :
|
||||
num_threads (num_threads),
|
||||
thread_pool_m (std::make_unique<boost::asio::thread_pool> (num_threads))
|
||||
num_threads (num_threads),
|
||||
thread_pool_m (std::make_unique<boost::asio::thread_pool> (num_threads))
|
||||
{
|
||||
set_thread_names (num_threads, thread_name);
|
||||
}
|
||||
|
@ -226,26 +226,26 @@ void nano::thread_pool::stop ()
|
|||
}
|
||||
}
|
||||
|
||||
void nano::thread_pool::push_task (std::function<void()> task)
|
||||
void nano::thread_pool::push_task (std::function<void ()> task)
|
||||
{
|
||||
++num_tasks;
|
||||
nano::lock_guard<nano::mutex> guard (mutex);
|
||||
if (!stopped)
|
||||
{
|
||||
boost::asio::post (*thread_pool_m, [this, task]() {
|
||||
boost::asio::post (*thread_pool_m, [this, task] () {
|
||||
task ();
|
||||
--num_tasks;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void nano::thread_pool::add_timed_task (std::chrono::steady_clock::time_point const & expiry_time, std::function<void()> task)
|
||||
void nano::thread_pool::add_timed_task (std::chrono::steady_clock::time_point const & expiry_time, std::function<void ()> task)
|
||||
{
|
||||
nano::lock_guard<nano::mutex> guard (mutex);
|
||||
if (!stopped && thread_pool_m)
|
||||
{
|
||||
auto timer = std::make_shared<boost::asio::steady_timer> (thread_pool_m->get_executor (), expiry_time);
|
||||
timer->async_wait ([this, task, timer](const boost::system::error_code & ec) {
|
||||
timer->async_wait ([this, task, timer] (const boost::system::error_code & ec) {
|
||||
if (!ec)
|
||||
{
|
||||
push_task (task);
|
||||
|
@ -270,13 +270,13 @@ void nano::thread_pool::set_thread_names (unsigned num_threads, nano::thread_rol
|
|||
std::vector<std::promise<void>> promises (num_threads);
|
||||
std::vector<std::future<void>> futures;
|
||||
futures.reserve (num_threads);
|
||||
std::transform (promises.begin (), promises.end (), std::back_inserter (futures), [](auto & promise) {
|
||||
std::transform (promises.begin (), promises.end (), std::back_inserter (futures), [] (auto & promise) {
|
||||
return promise.get_future ();
|
||||
});
|
||||
|
||||
for (auto i = 0u; i < num_threads; ++i)
|
||||
{
|
||||
boost::asio::post (*thread_pool_m, [& promise = promises[i], thread_name]() {
|
||||
boost::asio::post (*thread_pool_m, [&promise = promises[i], thread_name] () {
|
||||
nano::thread_role::set (thread_name);
|
||||
promise.set_value ();
|
||||
});
|
||||
|
@ -292,6 +292,6 @@ void nano::thread_pool::set_thread_names (unsigned num_threads, nano::thread_rol
|
|||
std::unique_ptr<nano::container_info_component> nano::collect_container_info (thread_pool & thread_pool, std::string const & name)
|
||||
{
|
||||
auto composite = std::make_unique<container_info_composite> (name);
|
||||
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "count", thread_pool.num_queued_tasks (), sizeof (std::function<void()>) }));
|
||||
composite->add_component (std::make_unique<container_info_leaf> (container_info{ "count", thread_pool.num_queued_tasks (), sizeof (std::function<void ()>) }));
|
||||
return composite;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ class relaxed_atomic_integral
|
|||
public:
|
||||
relaxed_atomic_integral () noexcept = default;
|
||||
constexpr relaxed_atomic_integral (T desired) noexcept :
|
||||
atomic (desired)
|
||||
atomic (desired)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -169,10 +169,10 @@ public:
|
|||
~thread_pool ();
|
||||
|
||||
/** This will run when there is an available thread for execution */
|
||||
void push_task (std::function<void()>);
|
||||
void push_task (std::function<void ()>);
|
||||
|
||||
/** Run a task at a certain point in time */
|
||||
void add_timed_task (std::chrono::steady_clock::time_point const & expiry_time, std::function<void()> task);
|
||||
void add_timed_task (std::chrono::steady_clock::time_point const & expiry_time, std::function<void ()> task);
|
||||
|
||||
/** Stops any further pushed tasks from executing */
|
||||
void stop ();
|
||||
|
|
|
@ -45,7 +45,7 @@ std::string typed_unit ()
|
|||
|
||||
template <typename UNIT, typename CLOCK>
|
||||
nano::timer<UNIT, CLOCK>::timer (nano::timer_state state_a, std::string const & description_a) :
|
||||
desc (description_a)
|
||||
desc (description_a)
|
||||
{
|
||||
if (state_a == nano::timer_state::started)
|
||||
{
|
||||
|
@ -55,14 +55,14 @@ desc (description_a)
|
|||
|
||||
template <typename UNIT, typename CLOCK>
|
||||
nano::timer<UNIT, CLOCK>::timer (std::string const & description_a) :
|
||||
desc (description_a)
|
||||
desc (description_a)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename UNIT, typename CLOCK>
|
||||
nano::timer<UNIT, CLOCK>::timer (std::string const & description_a, nano::timer<UNIT, CLOCK> * parent_a) :
|
||||
parent (parent_a),
|
||||
desc (description_a)
|
||||
parent (parent_a),
|
||||
desc (description_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
#include <boost/filesystem/convenience.hpp>
|
||||
|
||||
nano::tomlconfig::tomlconfig () :
|
||||
tree (cpptoml::make_table ())
|
||||
tree (cpptoml::make_table ())
|
||||
{
|
||||
error = std::make_shared<nano::error> ();
|
||||
}
|
||||
|
||||
nano::tomlconfig::tomlconfig (std::shared_ptr<cpptoml::table> const & tree_a, std::shared_ptr<nano::error> const & error_a) :
|
||||
nano::configbase (error_a), tree (tree_a)
|
||||
nano::configbase (error_a), tree (tree_a)
|
||||
{
|
||||
if (!error)
|
||||
{
|
||||
|
@ -250,7 +250,7 @@ nano::tomlconfig & nano::tomlconfig::get_config (bool optional, std::string cons
|
|||
|
||||
nano::tomlconfig & nano::tomlconfig::get_config (bool optional, std::string const & key, bool & target, bool default_value)
|
||||
{
|
||||
auto bool_conv = [this, &target, &key, optional](std::string val) {
|
||||
auto bool_conv = [this, &target, &key, optional] (std::string val) {
|
||||
if (val == "true")
|
||||
{
|
||||
target = true;
|
||||
|
@ -317,7 +317,7 @@ void nano::tomlconfig::erase_defaults (std::shared_ptr<cpptoml::table> const & b
|
|||
if (arr_other.size () == arr_base.size ())
|
||||
{
|
||||
bool equal = std::equal (arr_other.begin (), arr_other.end (), arr_base.begin (),
|
||||
[](auto const & item1, auto const & item2) -> bool {
|
||||
[] (auto const & item1, auto const & item2) -> bool {
|
||||
return (item1->template as<std::string> ()->get () == item2->template as<std::string> ()->get ());
|
||||
});
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
* @param key Array element key. Qualified (dotted) keys are not supported for arrays so this must be called on the correct tomlconfig node.
|
||||
*/
|
||||
template <typename T>
|
||||
tomlconfig & array_entries_required (std::string const & key, std::function<void(T)> callback)
|
||||
tomlconfig & array_entries_required (std::string const & key, std::function<void (T)> callback)
|
||||
{
|
||||
if (tree->contains_qualified (key))
|
||||
{
|
||||
|
|
|
@ -49,7 +49,7 @@ std::size_t nano::get_filedescriptor_limit ()
|
|||
}
|
||||
|
||||
nano::container_info_composite::container_info_composite (std::string const & name) :
|
||||
name (name)
|
||||
name (name)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ const std::string & nano::container_info_composite::get_name () const
|
|||
}
|
||||
|
||||
nano::container_info_leaf::container_info_leaf (const container_info & info) :
|
||||
info (info)
|
||||
info (info)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -131,8 +131,8 @@ void nano::move_all_files_to_dir (boost::filesystem::path const & from, boost::f
|
|||
void assert_internal (const char * check_expr, const char * func, const char * file, unsigned int line, bool is_release_assert, std::string_view error_msg)
|
||||
{
|
||||
std::cerr << "Assertion (" << check_expr << ") failed\n"
|
||||
<< func << "\n"
|
||||
<< file << ":" << line << "\n";
|
||||
<< func << "\n"
|
||||
<< file << ":" << line << "\n";
|
||||
if (!error_msg.empty ())
|
||||
{
|
||||
std::cerr << "Error: " << error_msg << "\n";
|
||||
|
|
|
@ -146,7 +146,7 @@ template <typename... T>
|
|||
class observer_set final
|
||||
{
|
||||
public:
|
||||
void add (std::function<void(T...)> const & observer_a)
|
||||
void add (std::function<void (T...)> const & observer_a)
|
||||
{
|
||||
nano::lock_guard<nano::mutex> lock (mutex);
|
||||
observers.push_back (observer_a);
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
}
|
||||
}
|
||||
nano::mutex mutex{ mutex_identifier (mutexes::observer_set) };
|
||||
std::vector<std::function<void(T...)>> observers;
|
||||
std::vector<std::function<void (T...)>> observers;
|
||||
};
|
||||
|
||||
template <typename... T>
|
||||
|
|
|
@ -199,10 +199,10 @@ double nano::denormalized_multiplier (double const multiplier_a, uint64_t const
|
|||
}
|
||||
|
||||
nano::work_pool::work_pool (unsigned max_threads_a, std::chrono::nanoseconds pow_rate_limiter_a, std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> opencl_a) :
|
||||
ticket (0),
|
||||
done (false),
|
||||
pow_rate_limiter (pow_rate_limiter_a),
|
||||
opencl (opencl_a)
|
||||
ticket (0),
|
||||
done (false),
|
||||
pow_rate_limiter (pow_rate_limiter_a),
|
||||
opencl (opencl_a)
|
||||
{
|
||||
static_assert (ATOMIC_INT_LOCK_FREE == 2, "Atomic int needed");
|
||||
boost::thread::attributes attrs;
|
||||
|
@ -215,7 +215,7 @@ opencl (opencl_a)
|
|||
}
|
||||
for (auto i (0u); i < count; ++i)
|
||||
{
|
||||
threads.emplace_back (attrs, [this, i]() {
|
||||
threads.emplace_back (attrs, [this, i] () {
|
||||
nano::thread_role::set (nano::thread_role::name::work);
|
||||
nano::work_thread_reprioritize ();
|
||||
loop (i);
|
||||
|
@ -331,7 +331,7 @@ void nano::work_pool::cancel (nano::root const & root_a)
|
|||
++ticket;
|
||||
}
|
||||
}
|
||||
pending.remove_if ([&root_a](decltype (pending)::value_type const & item_a) {
|
||||
pending.remove_if ([&root_a] (decltype (pending)::value_type const & item_a) {
|
||||
bool result{ false };
|
||||
if (item_a.item == root_a)
|
||||
{
|
||||
|
@ -356,7 +356,7 @@ void nano::work_pool::stop ()
|
|||
producer_condition.notify_all ();
|
||||
}
|
||||
|
||||
void nano::work_pool::generate (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::function<void(boost::optional<uint64_t> const &)> callback_a)
|
||||
void nano::work_pool::generate (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::function<void (boost::optional<uint64_t> const &)> callback_a)
|
||||
{
|
||||
debug_assert (!root_a.is_zero ());
|
||||
if (!threads.empty ())
|
||||
|
@ -394,7 +394,7 @@ boost::optional<uint64_t> nano::work_pool::generate (nano::work_version const ve
|
|||
{
|
||||
std::promise<boost::optional<uint64_t>> work;
|
||||
std::future<boost::optional<uint64_t>> future = work.get_future ();
|
||||
generate (version_a, root_a, difficulty_a, [&work](boost::optional<uint64_t> work_a) {
|
||||
generate (version_a, root_a, difficulty_a, [&work] (boost::optional<uint64_t> work_a) {
|
||||
work.set_value (work_a);
|
||||
});
|
||||
result = future.get ().value ();
|
||||
|
|
|
@ -47,14 +47,14 @@ class opencl_work;
|
|||
class work_item final
|
||||
{
|
||||
public:
|
||||
work_item (nano::work_version const version_a, nano::root const & item_a, uint64_t difficulty_a, std::function<void(boost::optional<uint64_t> const &)> const & callback_a) :
|
||||
version (version_a), item (item_a), difficulty (difficulty_a), callback (callback_a)
|
||||
work_item (nano::work_version const version_a, nano::root const & item_a, uint64_t difficulty_a, std::function<void (boost::optional<uint64_t> const &)> const & callback_a) :
|
||||
version (version_a), item (item_a), difficulty (difficulty_a), callback (callback_a)
|
||||
{
|
||||
}
|
||||
nano::work_version const version;
|
||||
nano::root const item;
|
||||
uint64_t const difficulty;
|
||||
std::function<void(boost::optional<uint64_t> const &)> const callback;
|
||||
std::function<void (boost::optional<uint64_t> const &)> const callback;
|
||||
};
|
||||
class work_pool final
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
void loop (uint64_t);
|
||||
void stop ();
|
||||
void cancel (nano::root const &);
|
||||
void generate (nano::work_version const, nano::root const &, uint64_t, std::function<void(boost::optional<uint64_t> const &)>);
|
||||
void generate (nano::work_version const, nano::root const &, uint64_t, std::function<void (boost::optional<uint64_t> const &)>);
|
||||
boost::optional<uint64_t> generate (nano::work_version const, nano::root const &, uint64_t);
|
||||
// For tests only
|
||||
boost::optional<uint64_t> generate (nano::root const &);
|
||||
|
|
|
@ -163,7 +163,7 @@ boost::property_tree::ptree rpc_request (boost::property_tree::ptree const & req
|
|||
debug_assert (results.size () == 1);
|
||||
|
||||
std::promise<boost::optional<boost::property_tree::ptree>> promise;
|
||||
boost::asio::spawn (ioc, [&ioc, &results, request, &promise](boost::asio::yield_context yield) {
|
||||
boost::asio::spawn (ioc, [&ioc, &results, request, &promise] (boost::asio::yield_context yield) {
|
||||
socket_type socket (ioc);
|
||||
boost::beast::flat_buffer buffer;
|
||||
http::request<http::string_body> req;
|
||||
|
@ -377,7 +377,7 @@ int main (int argc, char * const * argv)
|
|||
boost::asio::io_context ioc;
|
||||
|
||||
debug_assert (!nano::signal_handler_impl);
|
||||
nano::signal_handler_impl = [&ioc]() {
|
||||
nano::signal_handler_impl = [&ioc] () {
|
||||
ioc.stop ();
|
||||
};
|
||||
|
||||
|
@ -387,7 +387,7 @@ int main (int argc, char * const * argv)
|
|||
tcp::resolver resolver{ ioc };
|
||||
auto const primary_node_results = resolver.resolve ("::1", std::to_string (rpc_port_start));
|
||||
|
||||
std::thread t ([send_count, &ioc, &primary_node_results, &resolver, &node_count, &destination_count]() {
|
||||
std::thread t ([send_count, &ioc, &primary_node_results, &resolver, &node_count, &destination_count] () {
|
||||
for (int i = 0; i < node_count; ++i)
|
||||
{
|
||||
keepalive_rpc (ioc, primary_node_results, peering_port_start + i);
|
||||
|
@ -436,7 +436,7 @@ int main (int argc, char * const * argv)
|
|||
}
|
||||
|
||||
// Send from genesis account to different accounts and receive the funds
|
||||
boost::asio::spawn (ioc, [&ioc, &primary_node_results, &wallet, destination_account, &send_calls_remaining](boost::asio::yield_context yield) {
|
||||
boost::asio::spawn (ioc, [&ioc, &primary_node_results, &wallet, destination_account, &send_calls_remaining] (boost::asio::yield_context yield) {
|
||||
send_receive (ioc, wallet, nano::genesis_account.to_account (), destination_account->as_string, send_calls_remaining, primary_node_results, yield);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -51,10 +51,10 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
|
|||
nano::logger_mt logger{ config.node.logging.min_time_between_log_output };
|
||||
boost::asio::io_context io_ctx;
|
||||
auto opencl (nano::opencl_work::create (config.opencl_enable, config.opencl, logger));
|
||||
nano::work_pool opencl_work (config.node.work_threads, config.node.pow_sleep_interval, opencl ? [&opencl](nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> & ticket_a) {
|
||||
nano::work_pool opencl_work (config.node.work_threads, config.node.pow_sleep_interval, opencl ? [&opencl] (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> & ticket_a) {
|
||||
return opencl->generate_work (version_a, root_a, difficulty_a, ticket_a);
|
||||
}
|
||||
: std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> (nullptr));
|
||||
: std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> (nullptr));
|
||||
try
|
||||
{
|
||||
// This avoid a blank prompt during any node initialization delays
|
||||
|
@ -76,9 +76,9 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
|
|||
{
|
||||
auto network_label = node->network_params.network.get_current_network_as_string ();
|
||||
std::cout << "Network: " << network_label << ", version: " << NANO_VERSION_STRING << "\n"
|
||||
<< "Path: " << node->application_path.string () << "\n"
|
||||
<< "Build Info: " << BUILD_INFO << "\n"
|
||||
<< "Database backend: " << node->store.vendor_get () << std::endl;
|
||||
<< "Path: " << node->application_path.string () << "\n"
|
||||
<< "Build Info: " << BUILD_INFO << "\n"
|
||||
<< "Database backend: " << node->store.vendor_get () << std::endl;
|
||||
auto voting (node->wallets.reps ().voting);
|
||||
if (voting > 1)
|
||||
{
|
||||
|
@ -114,9 +114,9 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
|
|||
std::cout << error.get_message () << std::endl;
|
||||
std::exit (1);
|
||||
}
|
||||
rpc_handler = std::make_unique<nano::inprocess_rpc_handler> (*node, ipc_server, config.rpc, [&ipc_server, &workers = node->workers, &io_ctx]() {
|
||||
rpc_handler = std::make_unique<nano::inprocess_rpc_handler> (*node, ipc_server, config.rpc, [&ipc_server, &workers = node->workers, &io_ctx] () {
|
||||
ipc_server.stop ();
|
||||
workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (3), [&io_ctx]() {
|
||||
workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (3), [&io_ctx] () {
|
||||
io_ctx.stop ();
|
||||
});
|
||||
});
|
||||
|
@ -137,7 +137,7 @@ void nano_daemon::daemon::run (boost::filesystem::path const & data_path, nano::
|
|||
}
|
||||
|
||||
debug_assert (!nano::signal_handler_impl);
|
||||
nano::signal_handler_impl = [&io_ctx]() {
|
||||
nano::signal_handler_impl = [&io_ctx] () {
|
||||
io_ctx.stop ();
|
||||
sig_int_or_term = 1;
|
||||
};
|
||||
|
|
|
@ -172,8 +172,8 @@ int main (int argc, char * const * argv)
|
|||
auto const ledger_unfiltered = node->ledger.cache.rep_weights.get_rep_amounts ();
|
||||
auto const ledger_height = node->ledger.cache.block_count.load ();
|
||||
|
||||
auto get_total = [](decltype (bootstrap_weights.second) const & reps) -> nano::uint128_union {
|
||||
return std::accumulate (reps.begin (), reps.end (), nano::uint128_t{ 0 }, [](auto sum, auto const & rep) { return sum + rep.second; });
|
||||
auto get_total = [] (decltype (bootstrap_weights.second) const & reps) -> nano::uint128_union {
|
||||
return std::accumulate (reps.begin (), reps.end (), nano::uint128_t{ 0 }, [] (auto sum, auto const & rep) { return sum + rep.second; });
|
||||
};
|
||||
|
||||
// Hardcoded weights are filtered to a cummulative weight of 99%, need to do the same for ledger weights
|
||||
|
@ -182,7 +182,7 @@ int main (int argc, char * const * argv)
|
|||
std::vector<std::pair<nano::account, nano::uint128_t>> sorted;
|
||||
sorted.reserve (ledger_unfiltered.size ());
|
||||
std::copy (ledger_unfiltered.begin (), ledger_unfiltered.end (), std::back_inserter (sorted));
|
||||
std::sort (sorted.begin (), sorted.end (), [](auto const & left, auto const & right) { return left.second > right.second; });
|
||||
std::sort (sorted.begin (), sorted.end (), [] (auto const & left, auto const & right) { return left.second > right.second; });
|
||||
auto const total_unfiltered = get_total (ledger_unfiltered);
|
||||
nano::uint128_t sum{ 0 };
|
||||
auto target = (total_unfiltered.number () / 100) * 99;
|
||||
|
@ -210,7 +210,7 @@ int main (int argc, char * const * argv)
|
|||
|
||||
std::vector<mismatched_t> mismatched;
|
||||
mismatched.reserve (hardcoded.size ());
|
||||
std::transform (hardcoded.begin (), hardcoded.end (), std::back_inserter (mismatched), [&ledger](auto const & rep) {
|
||||
std::transform (hardcoded.begin (), hardcoded.end (), std::back_inserter (mismatched), [&ledger] (auto const & rep) {
|
||||
auto ledger_rep (ledger.find (rep.first));
|
||||
nano::uint128_t ledger_weight = (ledger_rep == ledger.end () ? 0 : ledger_rep->second);
|
||||
auto absolute = ledger_weight > rep.second ? ledger_weight - rep.second : rep.second - ledger_weight;
|
||||
|
@ -218,12 +218,12 @@ int main (int argc, char * const * argv)
|
|||
});
|
||||
|
||||
// Sort by descending difference
|
||||
std::sort (mismatched.begin (), mismatched.end (), [](mismatched_t const & left, mismatched_t const & right) { return left.diff > right.diff; });
|
||||
std::sort (mismatched.begin (), mismatched.end (), [] (mismatched_t const & left, mismatched_t const & right) { return left.diff > right.diff; });
|
||||
|
||||
nano::uint128_union const mismatch_total = std::accumulate (mismatched.begin (), mismatched.end (), nano::uint128_t{ 0 }, [](auto sum, mismatched_t const & sample) { return sum + sample.diff.number (); });
|
||||
nano::uint128_union const mismatch_total = std::accumulate (mismatched.begin (), mismatched.end (), nano::uint128_t{ 0 }, [] (auto sum, mismatched_t const & sample) { return sum + sample.diff.number (); });
|
||||
nano::uint128_union const mismatch_mean = mismatch_total.number () / mismatched.size ();
|
||||
|
||||
nano::uint512_union mismatch_variance = std::accumulate (mismatched.begin (), mismatched.end (), nano::uint512_t (0), [M = mismatch_mean.number (), N = mismatched.size ()](nano::uint512_t sum, mismatched_t const & sample) {
|
||||
nano::uint512_union mismatch_variance = std::accumulate (mismatched.begin (), mismatched.end (), nano::uint512_t (0), [M = mismatch_mean.number (), N = mismatched.size ()] (nano::uint512_t sum, mismatched_t const & sample) {
|
||||
auto x = sample.diff.number ();
|
||||
nano::uint512_t const mean_diff = x > M ? x - M : M - x;
|
||||
nano::uint512_t const sqr = mean_diff * mean_diff;
|
||||
|
@ -235,20 +235,20 @@ int main (int argc, char * const * argv)
|
|||
|
||||
auto const outlier_threshold = std::max (nano::Gxrb_ratio, mismatch_mean.number () + 1 * mismatch_stddev.number ());
|
||||
decltype (mismatched) outliers;
|
||||
std::copy_if (mismatched.begin (), mismatched.end (), std::back_inserter (outliers), [outlier_threshold](mismatched_t const & sample) {
|
||||
std::copy_if (mismatched.begin (), mismatched.end (), std::back_inserter (outliers), [outlier_threshold] (mismatched_t const & sample) {
|
||||
return sample.diff > outlier_threshold;
|
||||
});
|
||||
|
||||
auto const newcomer_threshold = std::max (nano::Gxrb_ratio, mismatch_mean.number ());
|
||||
std::vector<std::pair<nano::account, nano::uint128_t>> newcomers;
|
||||
std::copy_if (ledger.begin (), ledger.end (), std::back_inserter (newcomers), [&hardcoded](auto const & rep) {
|
||||
std::copy_if (ledger.begin (), ledger.end (), std::back_inserter (newcomers), [&hardcoded] (auto const & rep) {
|
||||
return !hardcoded.count (rep.first) && rep.second;
|
||||
});
|
||||
|
||||
// Sort by descending weight
|
||||
std::sort (newcomers.begin (), newcomers.end (), [](auto const & left, auto const & right) { return left.second > right.second; });
|
||||
std::sort (newcomers.begin (), newcomers.end (), [] (auto const & left, auto const & right) { return left.second > right.second; });
|
||||
|
||||
auto newcomer_entry = [](auto const & rep) {
|
||||
auto newcomer_entry = [] (auto const & rep) {
|
||||
return boost::str (boost::format ("representative %1% hardcoded --- ledger %2%") % rep.first.to_account () % nano::uint128_union (rep.second).format_balance (nano::Mxrb_ratio, 0, true));
|
||||
};
|
||||
|
||||
|
@ -326,18 +326,18 @@ int main (int argc, char * const * argv)
|
|||
nano::keypair genesis (key.to_string ());
|
||||
nano::work_pool work (std::numeric_limits<unsigned>::max ());
|
||||
std::cout << "Genesis: " << genesis.prv.to_string () << "\n"
|
||||
<< "Public: " << genesis.pub.to_string () << "\n"
|
||||
<< "Account: " << genesis.pub.to_account () << "\n";
|
||||
<< "Public: " << genesis.pub.to_string () << "\n"
|
||||
<< "Account: " << genesis.pub.to_account () << "\n";
|
||||
nano::keypair landing;
|
||||
std::cout << "Landing: " << landing.prv.to_string () << "\n"
|
||||
<< "Public: " << landing.pub.to_string () << "\n"
|
||||
<< "Account: " << landing.pub.to_account () << "\n";
|
||||
<< "Public: " << landing.pub.to_string () << "\n"
|
||||
<< "Account: " << landing.pub.to_account () << "\n";
|
||||
for (auto i (0); i != 32; ++i)
|
||||
{
|
||||
nano::keypair rep;
|
||||
std::cout << "Rep" << i << ": " << rep.prv.to_string () << "\n"
|
||||
<< "Public: " << rep.pub.to_string () << "\n"
|
||||
<< "Account: " << rep.pub.to_account () << "\n";
|
||||
<< "Public: " << rep.pub.to_string () << "\n"
|
||||
<< "Account: " << rep.pub.to_account () << "\n";
|
||||
}
|
||||
nano::network_constants network_constants;
|
||||
nano::uint128_t balance (std::numeric_limits<nano::uint128_t>::max ());
|
||||
|
@ -610,10 +610,10 @@ int main (int argc, char * const * argv)
|
|||
nano::logger_mt logger;
|
||||
nano::opencl_config config (platform, device, threads);
|
||||
auto opencl (nano::opencl_work::create (true, config, logger));
|
||||
nano::work_pool work_pool (0, std::chrono::nanoseconds (0), opencl ? [&opencl](nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> &) {
|
||||
nano::work_pool work_pool (0, std::chrono::nanoseconds (0), opencl ? [&opencl] (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> &) {
|
||||
return opencl->generate_work (version_a, root_a, difficulty_a);
|
||||
}
|
||||
: std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> (nullptr));
|
||||
: std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> (nullptr));
|
||||
nano::change_block block (0, 0, nano::keypair ().prv, 0, 0);
|
||||
std::cerr << boost::str (boost::format ("Starting OpenCL generation profiling. Platform: %1%. Device: %2%. Threads: %3%. Difficulty: %4$#x (%5%x from base difficulty %6$#x)\n") % platform % device % threads % difficulty % nano::to_string (nano::difficulty::to_multiplier (difficulty, network_constants.publish_full.base), 4) % network_constants.publish_full.base);
|
||||
for (uint64_t i (0); true; ++i)
|
||||
|
@ -628,14 +628,14 @@ int main (int argc, char * const * argv)
|
|||
else
|
||||
{
|
||||
std::cout << "Not available device id\n"
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Not available platform id\n"
|
||||
<< std::endl;
|
||||
<< std::endl;
|
||||
result = -1;
|
||||
}
|
||||
}
|
||||
|
@ -655,7 +655,7 @@ int main (int argc, char * const * argv)
|
|||
|
||||
boost::stacktrace::stacktrace st = boost::stacktrace::stacktrace::from_dump (ifs);
|
||||
std::cout << "Latest crash backtrace:\n"
|
||||
<< st << std::endl;
|
||||
<< st << std::endl;
|
||||
}
|
||||
}
|
||||
else if (vm.count ("debug_generate_crash_report"))
|
||||
|
@ -782,7 +782,7 @@ int main (int argc, char * const * argv)
|
|||
// and inform the user that it needs installing
|
||||
std::vector<int> system_codes;
|
||||
|
||||
auto run_addr2line = [&backtrace_addresses, &base_addresses, &system_codes, &crash_report_filename](bool use_relative_addresses) {
|
||||
auto run_addr2line = [&backtrace_addresses, &base_addresses, &system_codes, &crash_report_filename] (bool use_relative_addresses) {
|
||||
for (auto backtrace_address : backtrace_addresses)
|
||||
{
|
||||
// Find the closest address to it
|
||||
|
@ -809,7 +809,7 @@ int main (int argc, char * const * argv)
|
|||
{
|
||||
std::ofstream ofs (crash_report_filename, std::ios_base::out | std::ios_base::app);
|
||||
ofs << std::endl
|
||||
<< "Using relative addresses:" << std::endl; // Add an empty line to separate the absolute & relative output
|
||||
<< "Using relative addresses:" << std::endl; // Add an empty line to separate the absolute & relative output
|
||||
}
|
||||
|
||||
// Now run using relative addresses. This will give actual results for other dlls, the results from the nano_node executable.
|
||||
|
@ -912,27 +912,27 @@ int main (int argc, char * const * argv)
|
|||
genesis_balance = genesis_balance - 1000000000;
|
||||
|
||||
auto send = builder.state ()
|
||||
.account (dev_params.ledger.dev_genesis_key.pub)
|
||||
.previous (genesis_latest)
|
||||
.representative (dev_params.ledger.dev_genesis_key.pub)
|
||||
.balance (genesis_balance)
|
||||
.link (keys[i].pub)
|
||||
.sign (dev_params.ledger.dev_genesis_key.prv, dev_params.ledger.dev_genesis_key.pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, genesis_latest, node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
.account (dev_params.ledger.dev_genesis_key.pub)
|
||||
.previous (genesis_latest)
|
||||
.representative (dev_params.ledger.dev_genesis_key.pub)
|
||||
.balance (genesis_balance)
|
||||
.link (keys[i].pub)
|
||||
.sign (dev_params.ledger.dev_genesis_key.prv, dev_params.ledger.dev_genesis_key.pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, genesis_latest, node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
|
||||
genesis_latest = send->hash ();
|
||||
blocks.push_back (std::move (send));
|
||||
|
||||
auto open = builder.state ()
|
||||
.account (keys[i].pub)
|
||||
.previous (0)
|
||||
.representative (keys[i].pub)
|
||||
.balance (balances[i])
|
||||
.link (genesis_latest)
|
||||
.sign (keys[i].prv, keys[i].pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, keys[i].pub, node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
.account (keys[i].pub)
|
||||
.previous (0)
|
||||
.representative (keys[i].pub)
|
||||
.balance (balances[i])
|
||||
.link (genesis_latest)
|
||||
.sign (keys[i].prv, keys[i].pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, keys[i].pub, node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
|
||||
frontiers[i] = open->hash ();
|
||||
blocks.push_back (std::move (open));
|
||||
|
@ -946,14 +946,14 @@ int main (int argc, char * const * argv)
|
|||
--balances[j];
|
||||
|
||||
auto send = builder.state ()
|
||||
.account (keys[j].pub)
|
||||
.previous (frontiers[j].as_block_hash ())
|
||||
.representative (keys[j].pub)
|
||||
.balance (balances[j])
|
||||
.link (keys[other].pub)
|
||||
.sign (keys[j].prv, keys[j].pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, frontiers[j], node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
.account (keys[j].pub)
|
||||
.previous (frontiers[j].as_block_hash ())
|
||||
.representative (keys[j].pub)
|
||||
.balance (balances[j])
|
||||
.link (keys[other].pub)
|
||||
.sign (keys[j].prv, keys[j].pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, frontiers[j], node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
|
||||
frontiers[j] = send->hash ();
|
||||
blocks.push_back (std::move (send));
|
||||
|
@ -961,14 +961,14 @@ int main (int argc, char * const * argv)
|
|||
++balances[other];
|
||||
|
||||
auto receive = builder.state ()
|
||||
.account (keys[other].pub)
|
||||
.previous (frontiers[other].as_block_hash ())
|
||||
.representative (keys[other].pub)
|
||||
.balance (balances[other])
|
||||
.link (frontiers[j].as_block_hash ())
|
||||
.sign (keys[other].prv, keys[other].pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, frontiers[other], node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
.account (keys[other].pub)
|
||||
.previous (frontiers[other].as_block_hash ())
|
||||
.representative (keys[other].pub)
|
||||
.balance (balances[other])
|
||||
.link (frontiers[j].as_block_hash ())
|
||||
.sign (keys[other].prv, keys[other].pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, frontiers[other], node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
|
||||
frontiers[other] = receive->hash ();
|
||||
blocks.push_back (std::move (receive));
|
||||
|
@ -1027,27 +1027,27 @@ int main (int argc, char * const * argv)
|
|||
genesis_balance = genesis_balance - balance;
|
||||
|
||||
auto send = builder.state ()
|
||||
.account (dev_params.ledger.dev_genesis_key.pub)
|
||||
.previous (genesis_latest)
|
||||
.representative (dev_params.ledger.dev_genesis_key.pub)
|
||||
.balance (genesis_balance)
|
||||
.link (keys[i].pub)
|
||||
.sign (dev_params.ledger.dev_genesis_key.prv, dev_params.ledger.dev_genesis_key.pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, genesis_latest, node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
.account (dev_params.ledger.dev_genesis_key.pub)
|
||||
.previous (genesis_latest)
|
||||
.representative (dev_params.ledger.dev_genesis_key.pub)
|
||||
.balance (genesis_balance)
|
||||
.link (keys[i].pub)
|
||||
.sign (dev_params.ledger.dev_genesis_key.prv, dev_params.ledger.dev_genesis_key.pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, genesis_latest, node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
|
||||
genesis_latest = send->hash ();
|
||||
node->ledger.process (transaction, *send);
|
||||
|
||||
auto open = builder.state ()
|
||||
.account (keys[i].pub)
|
||||
.previous (0)
|
||||
.representative (keys[i].pub)
|
||||
.balance (balance)
|
||||
.link (genesis_latest)
|
||||
.sign (keys[i].prv, keys[i].pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, keys[i].pub, node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
.account (keys[i].pub)
|
||||
.previous (0)
|
||||
.representative (keys[i].pub)
|
||||
.balance (balance)
|
||||
.link (genesis_latest)
|
||||
.sign (keys[i].prv, keys[i].pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, keys[i].pub, node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
|
||||
node->ledger.process (transaction, *open);
|
||||
}
|
||||
|
@ -1059,14 +1059,14 @@ int main (int argc, char * const * argv)
|
|||
nano::keypair destination;
|
||||
|
||||
auto send = builder.state ()
|
||||
.account (dev_params.ledger.dev_genesis_key.pub)
|
||||
.previous (genesis_latest)
|
||||
.representative (dev_params.ledger.dev_genesis_key.pub)
|
||||
.balance (genesis_balance)
|
||||
.link (destination.pub)
|
||||
.sign (dev_params.ledger.dev_genesis_key.prv, dev_params.ledger.dev_genesis_key.pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, genesis_latest, node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
.account (dev_params.ledger.dev_genesis_key.pub)
|
||||
.previous (genesis_latest)
|
||||
.representative (dev_params.ledger.dev_genesis_key.pub)
|
||||
.balance (genesis_balance)
|
||||
.link (destination.pub)
|
||||
.sign (dev_params.ledger.dev_genesis_key.prv, dev_params.ledger.dev_genesis_key.pub)
|
||||
.work (*node->work.generate (nano::work_version::work_1, genesis_latest, node->network_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
|
||||
genesis_latest = send->hash ();
|
||||
blocks.push_back (std::move (send));
|
||||
|
@ -1166,26 +1166,26 @@ int main (int argc, char * const * argv)
|
|||
genesis_balance = genesis_balance - 1;
|
||||
|
||||
auto send = builder.state ()
|
||||
.account (dev_params.ledger.dev_genesis_key.pub)
|
||||
.previous (genesis_latest)
|
||||
.representative (dev_params.ledger.dev_genesis_key.pub)
|
||||
.balance (genesis_balance)
|
||||
.link (key.pub)
|
||||
.sign (dev_params.ledger.dev_genesis_key.prv, dev_params.ledger.dev_genesis_key.pub)
|
||||
.work (*work.generate (nano::work_version::work_1, genesis_latest, dev_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
.account (dev_params.ledger.dev_genesis_key.pub)
|
||||
.previous (genesis_latest)
|
||||
.representative (dev_params.ledger.dev_genesis_key.pub)
|
||||
.balance (genesis_balance)
|
||||
.link (key.pub)
|
||||
.sign (dev_params.ledger.dev_genesis_key.prv, dev_params.ledger.dev_genesis_key.pub)
|
||||
.work (*work.generate (nano::work_version::work_1, genesis_latest, dev_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
|
||||
genesis_latest = send->hash ();
|
||||
|
||||
auto open = builder.state ()
|
||||
.account (key.pub)
|
||||
.previous (0)
|
||||
.representative (key.pub)
|
||||
.balance (1)
|
||||
.link (genesis_latest)
|
||||
.sign (key.prv, key.pub)
|
||||
.work (*work.generate (nano::work_version::work_1, key.pub, dev_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
.account (key.pub)
|
||||
.previous (0)
|
||||
.representative (key.pub)
|
||||
.balance (1)
|
||||
.link (genesis_latest)
|
||||
.sign (key.prv, key.pub)
|
||||
.work (*work.generate (nano::work_version::work_1, key.pub, dev_params.network.publish_thresholds.epoch_1))
|
||||
.build ();
|
||||
|
||||
blocks.push_back (std::move (send));
|
||||
blocks.push_back (std::move (open));
|
||||
|
@ -1232,7 +1232,7 @@ int main (int argc, char * const * argv)
|
|||
if (error)
|
||||
{
|
||||
std::cerr << "\n"
|
||||
<< error.get_message () << std::endl;
|
||||
<< error.get_message () << std::endl;
|
||||
std::exit (1);
|
||||
}
|
||||
else
|
||||
|
@ -1321,7 +1321,7 @@ int main (int argc, char * const * argv)
|
|||
command_l << rpc_input_l;
|
||||
}
|
||||
|
||||
auto response_handler_l ([](std::string const & response_a) {
|
||||
auto response_handler_l ([] (std::string const & response_a) {
|
||||
std::cout << response_a;
|
||||
// Terminate as soon as we have the result, even if background threads (like work generation) are running.
|
||||
std::exit (0);
|
||||
|
@ -1367,7 +1367,7 @@ int main (int argc, char * const * argv)
|
|||
std::atomic<uint64_t> block_count (0);
|
||||
std::atomic<uint64_t> errors (0);
|
||||
|
||||
auto print_error_message = [&silent, &errors](std::string const & error_message_a) {
|
||||
auto print_error_message = [&silent, &errors] (std::string const & error_message_a) {
|
||||
if (!silent)
|
||||
{
|
||||
static nano::mutex cerr_mutex;
|
||||
|
@ -1377,10 +1377,10 @@ int main (int argc, char * const * argv)
|
|||
++errors;
|
||||
};
|
||||
|
||||
auto start_threads = [node, &threads_count, &threads, &mutex, &condition, &finished](const auto & function_a, auto & deque_a) {
|
||||
auto start_threads = [node, &threads_count, &threads, &mutex, &condition, &finished] (const auto & function_a, auto & deque_a) {
|
||||
for (auto i (0U); i < threads_count; ++i)
|
||||
{
|
||||
threads.emplace_back ([&function_a, node, &mutex, &condition, &finished, &deque_a]() {
|
||||
threads.emplace_back ([&function_a, node, &mutex, &condition, &finished, &deque_a] () {
|
||||
auto transaction (node->store.tx_begin_read ());
|
||||
nano::unique_lock<nano::mutex> lock (mutex);
|
||||
while (!deque_a.empty () || !finished)
|
||||
|
@ -1402,7 +1402,7 @@ int main (int argc, char * const * argv)
|
|||
}
|
||||
};
|
||||
|
||||
auto check_account = [&print_error_message, &silent, &count, &block_count](std::shared_ptr<nano::node> const & node, nano::read_transaction const & transaction, nano::account const & account, nano::account_info const & info) {
|
||||
auto check_account = [&print_error_message, &silent, &count, &block_count] (std::shared_ptr<nano::node> const & node, nano::read_transaction const & transaction, nano::account const & account, nano::account_info const & info) {
|
||||
++count;
|
||||
if (!silent && (count % 20000) == 0)
|
||||
{
|
||||
|
@ -1676,7 +1676,7 @@ int main (int argc, char * const * argv)
|
|||
finished = false;
|
||||
std::deque<std::pair<nano::pending_key, nano::pending_info>> pending;
|
||||
|
||||
auto check_pending = [&print_error_message, &silent, &count](std::shared_ptr<nano::node> const & node, nano::read_transaction const & transaction, nano::pending_key const & key, nano::pending_info const & info) {
|
||||
auto check_pending = [&print_error_message, &silent, &count] (std::shared_ptr<nano::node> const & node, nano::read_transaction const & transaction, nano::pending_key const & key, nano::pending_info const & info) {
|
||||
++count;
|
||||
if (!silent && (count % 500000) == 0)
|
||||
{
|
||||
|
@ -1912,7 +1912,7 @@ int main (int argc, char * const * argv)
|
|||
nano::locked<std::vector<boost::unordered_set<nano::account>>> opened_account_versions_shared (epoch_count);
|
||||
using opened_account_versions_t = decltype (opened_account_versions_shared)::value_type;
|
||||
node->store.accounts_for_each_par (
|
||||
[&opened_account_versions_shared, epoch_count](nano::read_transaction const & /*unused*/, nano::store_iterator<nano::account, nano::account_info> i, nano::store_iterator<nano::account, nano::account_info> n) {
|
||||
[&opened_account_versions_shared, epoch_count] (nano::read_transaction const & /*unused*/, nano::store_iterator<nano::account, nano::account_info> i, nano::store_iterator<nano::account, nano::account_info> n) {
|
||||
// First cache locally
|
||||
opened_account_versions_t opened_account_versions_l (epoch_count);
|
||||
for (; i != n; ++i)
|
||||
|
@ -1949,7 +1949,7 @@ int main (int argc, char * const * argv)
|
|||
nano::locked<boost::unordered_map<nano::account, std::underlying_type_t<nano::epoch>>> unopened_highest_pending_shared;
|
||||
using unopened_highest_pending_t = decltype (unopened_highest_pending_shared)::value_type;
|
||||
node->store.pending_for_each_par (
|
||||
[&unopened_highest_pending_shared, &opened_accounts](nano::read_transaction const & /*unused*/, nano::store_iterator<nano::pending_key, nano::pending_info> i, nano::store_iterator<nano::pending_key, nano::pending_info> n) {
|
||||
[&unopened_highest_pending_shared, &opened_accounts] (nano::read_transaction const & /*unused*/, nano::store_iterator<nano::pending_key, nano::pending_info> i, nano::store_iterator<nano::pending_key, nano::pending_info> n) {
|
||||
// First cache locally
|
||||
unopened_highest_pending_t unopened_highest_pending_l;
|
||||
for (; i != n; ++i)
|
||||
|
@ -1975,7 +1975,7 @@ int main (int argc, char * const * argv)
|
|||
}
|
||||
});
|
||||
|
||||
auto output_account_version_number = [](auto version, auto num_accounts) {
|
||||
auto output_account_version_number = [] (auto version, auto num_accounts) {
|
||||
std::cout << "Account version " << version << " num accounts: " << num_accounts << "\n";
|
||||
};
|
||||
|
||||
|
@ -2021,7 +2021,7 @@ int main (int argc, char * const * argv)
|
|||
else if (vm.count ("version"))
|
||||
{
|
||||
std::cout << "Version " << NANO_VERSION_STRING << "\n"
|
||||
<< "Build Info " << BUILD_INFO << std::endl;
|
||||
<< "Build Info " << BUILD_INFO << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2041,7 +2041,7 @@ std::istream & operator>> (std::istream & in, uint64_from_hex & out_val)
|
|||
}
|
||||
|
||||
address_library_pair::address_library_pair (uint64_t address, std::string library) :
|
||||
address (address), library (library)
|
||||
address (address), library (library)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ void run (boost::filesystem::path const & data_path, std::vector<std::string> co
|
|||
rpc->start ();
|
||||
|
||||
debug_assert (!nano::signal_handler_impl);
|
||||
nano::signal_handler_impl = [&io_ctx]() {
|
||||
nano::signal_handler_impl = [&io_ctx] () {
|
||||
io_ctx.stop ();
|
||||
sig_int_or_term = 1;
|
||||
};
|
||||
|
@ -136,7 +136,7 @@ int main (int argc, char * const * argv)
|
|||
else if (vm.count ("version"))
|
||||
{
|
||||
std::cout << "Version " << NANO_VERSION_STRING << "\n"
|
||||
<< "Build Info " << BUILD_INFO << std::endl;
|
||||
<< "Build Info " << BUILD_INFO << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -107,10 +107,10 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
|||
std::shared_ptr<nano_qt::wallet> gui;
|
||||
nano::set_application_icon (application);
|
||||
auto opencl (nano::opencl_work::create (config.opencl_enable, config.opencl, logger));
|
||||
nano::work_pool work (config.node.work_threads, config.node.pow_sleep_interval, opencl ? [&opencl](nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> &) {
|
||||
nano::work_pool work (config.node.work_threads, config.node.pow_sleep_interval, opencl ? [&opencl] (nano::work_version const version_a, nano::root const & root_a, uint64_t difficulty_a, std::atomic<int> &) {
|
||||
return opencl->generate_work (version_a, root_a, difficulty_a);
|
||||
}
|
||||
: std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> (nullptr));
|
||||
: std::function<boost::optional<uint64_t> (nano::work_version const, nano::root const &, uint64_t, std::atomic<int> &)> (nullptr));
|
||||
node = std::make_shared<nano::node> (io_ctx, data_path, config.node, work, flags);
|
||||
if (!node->init_error ())
|
||||
{
|
||||
|
@ -189,7 +189,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
|||
rpc_process = std::make_unique<boost::process::child> (config.rpc.child_process.rpc_path, "--daemon", "--data_path", data_path, "--network", network);
|
||||
}
|
||||
}
|
||||
QObject::connect (&application, &QApplication::aboutToQuit, [&]() {
|
||||
QObject::connect (&application, &QApplication::aboutToQuit, [&] () {
|
||||
ipc.stop ();
|
||||
node->stop ();
|
||||
if (rpc)
|
||||
|
@ -209,7 +209,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv, boost
|
|||
#endif
|
||||
runner.stop_event_processing ();
|
||||
});
|
||||
application.postEvent (&processor, new nano_qt::eventloop_event ([&]() {
|
||||
application.postEvent (&processor, new nano_qt::eventloop_event ([&] () {
|
||||
gui = std::make_shared<nano_qt::wallet> (application, processor, *node, wallet, wallet_config.account);
|
||||
splash->close ();
|
||||
gui->start ();
|
||||
|
|
|
@ -19,18 +19,18 @@ size_t constexpr nano::active_transactions::max_active_elections_frontier_insert
|
|||
constexpr std::chrono::minutes nano::active_transactions::expired_optimistic_election_info_cutoff;
|
||||
|
||||
nano::active_transactions::active_transactions (nano::node & node_a, nano::confirmation_height_processor & confirmation_height_processor_a) :
|
||||
confirmation_height_processor (confirmation_height_processor_a),
|
||||
node (node_a),
|
||||
multipliers_cb (20, 1.),
|
||||
trended_active_multiplier (1.0),
|
||||
generator (node_a.config, node_a.ledger, node_a.wallets, node_a.vote_processor, node_a.history, node_a.network, node_a.stats),
|
||||
check_all_elections_period (node_a.network_params.network.is_dev_network () ? 10ms : 5s),
|
||||
election_time_to_live (node_a.network_params.network.is_dev_network () ? 0s : 2s),
|
||||
prioritized_cutoff (std::max<size_t> (1, node_a.config.active_elections_size / 10)),
|
||||
thread ([this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::request_loop);
|
||||
request_loop ();
|
||||
})
|
||||
confirmation_height_processor (confirmation_height_processor_a),
|
||||
node (node_a),
|
||||
multipliers_cb (20, 1.),
|
||||
trended_active_multiplier (1.0),
|
||||
generator (node_a.config, node_a.ledger, node_a.wallets, node_a.vote_processor, node_a.history, node_a.network, node_a.stats),
|
||||
check_all_elections_period (node_a.network_params.network.is_dev_network () ? 10ms : 5s),
|
||||
election_time_to_live (node_a.network_params.network.is_dev_network () ? 0s : 2s),
|
||||
prioritized_cutoff (std::max<size_t> (1, node_a.config.active_elections_size / 10)),
|
||||
thread ([this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::request_loop);
|
||||
request_loop ();
|
||||
})
|
||||
{
|
||||
// Register a callback which will get called after a block is cemented
|
||||
confirmation_height_processor.add_cemented_observer ([this] (std::shared_ptr<nano::block> const & callback_block_a) {
|
||||
|
@ -1542,13 +1542,13 @@ size_t nano::active_transactions::election_winner_details_size ()
|
|||
}
|
||||
|
||||
nano::cementable_account::cementable_account (nano::account const & account_a, size_t blocks_uncemented_a) :
|
||||
account (account_a), blocks_uncemented (blocks_uncemented_a)
|
||||
account (account_a), blocks_uncemented (blocks_uncemented_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::expired_optimistic_election_info::expired_optimistic_election_info (std::chrono::steady_clock::time_point expired_time_a, nano::account account_a) :
|
||||
expired_time (expired_time_a),
|
||||
account (account_a)
|
||||
expired_time (expired_time_a),
|
||||
account (account_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -68,9 +68,9 @@ class inactive_cache_information final
|
|||
public:
|
||||
inactive_cache_information () = default;
|
||||
inactive_cache_information (std::chrono::steady_clock::time_point arrival, nano::block_hash hash, nano::account initial_rep_a, uint64_t initial_timestamp_a, nano::inactive_cache_status status) :
|
||||
arrival (arrival),
|
||||
hash (hash),
|
||||
status (status)
|
||||
arrival (arrival),
|
||||
hash (hash),
|
||||
status (status)
|
||||
{
|
||||
voters.reserve (8);
|
||||
voters.emplace_back (initial_rep_a, initial_timestamp_a);
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
std::chrono::milliseconds constexpr nano::block_processor::confirmation_request_delay;
|
||||
|
||||
nano::block_post_events::block_post_events (std::function<nano::read_transaction ()> && get_transaction_a) :
|
||||
get_transaction (std::move (get_transaction_a))
|
||||
get_transaction (std::move (get_transaction_a))
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -26,15 +26,15 @@ nano::block_post_events::~block_post_events ()
|
|||
}
|
||||
|
||||
nano::block_processor::block_processor (nano::node & node_a, nano::write_database_queue & write_database_queue_a) :
|
||||
next_log (std::chrono::steady_clock::now ()),
|
||||
node (node_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
state_block_signature_verification (node.checker, node.ledger.network_params.ledger.epochs, node.config, node.logger, node.flags.block_processor_verification_size)
|
||||
next_log (std::chrono::steady_clock::now ()),
|
||||
node (node_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
state_block_signature_verification (node.checker, node.ledger.network_params.ledger.epochs, node.config, node.logger, node.flags.block_processor_verification_size)
|
||||
{
|
||||
state_block_signature_verification.blocks_verified_callback = [this](std::deque<std::pair<nano::unchecked_info, bool>> & items, std::vector<int> const & verifications, std::vector<nano::block_hash> const & hashes, std::vector<nano::signature> const & blocks_signatures) {
|
||||
state_block_signature_verification.blocks_verified_callback = [this] (std::deque<std::pair<nano::unchecked_info, bool>> & items, std::vector<int> const & verifications, std::vector<nano::block_hash> const & hashes, std::vector<nano::signature> const & blocks_signatures) {
|
||||
this->process_verified_state_blocks (items, verifications, hashes, blocks_signatures);
|
||||
};
|
||||
state_block_signature_verification.transition_inactive_callback = [this]() {
|
||||
state_block_signature_verification.transition_inactive_callback = [this] () {
|
||||
if (this->flushing)
|
||||
{
|
||||
{
|
||||
|
@ -242,7 +242,7 @@ void nano::block_processor::process_verified_state_blocks (std::deque<std::pair<
|
|||
void nano::block_processor::process_batch (nano::unique_lock<nano::mutex> & lock_a)
|
||||
{
|
||||
auto scoped_write_guard = write_database_queue.wait (nano::writer::process_batch);
|
||||
block_post_events post_events ([& store = node.store] { return store.tx_begin_read (); });
|
||||
block_post_events post_events ([&store = node.store] { return store.tx_begin_read (); });
|
||||
auto transaction (node.store.tx_begin_write ({ tables::accounts, tables::blocks, tables::frontiers, tables::pending, tables::unchecked }));
|
||||
nano::timer<std::chrono::milliseconds> timer_l;
|
||||
lock_a.lock ();
|
||||
|
@ -386,7 +386,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
}
|
||||
if ((info_a.modified > nano::seconds_since_epoch () - 300 && node.block_arrival.recent (hash)) || forced_a)
|
||||
{
|
||||
events_a.events.emplace_back ([this, hash, block = info_a.block, result, watch_work_a, origin_a](nano::transaction const & post_event_transaction_a) { process_live (post_event_transaction_a, hash, block, result, watch_work_a, origin_a); });
|
||||
events_a.events.emplace_back ([this, hash, block = info_a.block, result, watch_work_a, origin_a] (nano::transaction const & post_event_transaction_a) { process_live (post_event_transaction_a, hash, block, result, watch_work_a, origin_a); });
|
||||
}
|
||||
queue_unchecked (transaction_a, hash);
|
||||
/* For send blocks check epoch open unchecked (gap pending).
|
||||
|
@ -415,7 +415,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
nano::unchecked_key unchecked_key (block->previous (), hash);
|
||||
node.store.unchecked_put (transaction_a, unchecked_key, info_a);
|
||||
|
||||
events_a.events.emplace_back ([this, hash](nano::transaction const & /* unused */) { this->node.gap_cache.add (hash); });
|
||||
events_a.events.emplace_back ([this, hash] (nano::transaction const & /* unused */) { this->node.gap_cache.add (hash); });
|
||||
|
||||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::gap_previous);
|
||||
break;
|
||||
|
@ -435,7 +435,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
nano::unchecked_key unchecked_key (node.ledger.block_source (transaction_a, *(block)), hash);
|
||||
node.store.unchecked_put (transaction_a, unchecked_key, info_a);
|
||||
|
||||
events_a.events.emplace_back ([this, hash](nano::transaction const & /* unused */) { this->node.gap_cache.add (hash); });
|
||||
events_a.events.emplace_back ([this, hash] (nano::transaction const & /* unused */) { this->node.gap_cache.add (hash); });
|
||||
|
||||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::gap_source);
|
||||
break;
|
||||
|
@ -464,7 +464,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
{
|
||||
node.logger.try_log (boost::str (boost::format ("Old for: %1%") % hash.to_string ()));
|
||||
}
|
||||
events_a.events.emplace_back ([this, block = info_a.block, origin_a](nano::transaction const & post_event_transaction_a) { process_old (post_event_transaction_a, block, origin_a); });
|
||||
events_a.events.emplace_back ([this, block = info_a.block, origin_a] (nano::transaction const & post_event_transaction_a) { process_old (post_event_transaction_a, block, origin_a); });
|
||||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::old);
|
||||
break;
|
||||
}
|
||||
|
@ -474,7 +474,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
{
|
||||
node.logger.try_log (boost::str (boost::format ("Bad signature for: %1%") % hash.to_string ()));
|
||||
}
|
||||
events_a.events.emplace_back ([this, hash, info_a](nano::transaction const & /* unused */) { requeue_invalid (hash, info_a); });
|
||||
events_a.events.emplace_back ([this, hash, info_a] (nano::transaction const & /* unused */) { requeue_invalid (hash, info_a); });
|
||||
break;
|
||||
}
|
||||
case nano::process_result::negative_spend:
|
||||
|
@ -496,7 +496,7 @@ nano::process_return nano::block_processor::process_one (nano::write_transaction
|
|||
case nano::process_result::fork:
|
||||
{
|
||||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::fork);
|
||||
events_a.events.emplace_back ([this, block](nano::transaction const &) { this->node.active.publish (block); });
|
||||
events_a.events.emplace_back ([this, block] (nano::transaction const &) { this->node.active.publish (block); });
|
||||
if (node.config.logging.ledger_logging ())
|
||||
{
|
||||
node.logger.try_log (boost::str (boost::format ("Fork for: %1% root: %2%") % hash.to_string () % block->root ().to_string ()));
|
||||
|
|
|
@ -33,7 +33,7 @@ class block_post_events final
|
|||
public:
|
||||
explicit block_post_events (std::function<nano::read_transaction ()> &&);
|
||||
~block_post_events ();
|
||||
std::deque<std::function<void(nano::read_transaction const &)>> events;
|
||||
std::deque<std::function<void (nano::read_transaction const &)>> events;
|
||||
|
||||
private:
|
||||
std::function<nano::read_transaction ()> get_transaction;
|
||||
|
|
|
@ -10,16 +10,16 @@
|
|||
#include <algorithm>
|
||||
|
||||
nano::bootstrap_initiator::bootstrap_initiator (nano::node & node_a) :
|
||||
node (node_a)
|
||||
node (node_a)
|
||||
{
|
||||
connections = std::make_shared<nano::bootstrap_connections> (node);
|
||||
bootstrap_initiator_threads.push_back (boost::thread ([this]() {
|
||||
bootstrap_initiator_threads.push_back (boost::thread ([this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::bootstrap_connections);
|
||||
connections->run ();
|
||||
}));
|
||||
for (size_t i = 0; i < node.config.bootstrap_initiator_threads; ++i)
|
||||
{
|
||||
bootstrap_initiator_threads.push_back (boost::thread ([this]() {
|
||||
bootstrap_initiator_threads.push_back (boost::thread ([this] () {
|
||||
nano::thread_role::set (nano::thread_role::name::bootstrap_initiator);
|
||||
run_bootstrap ();
|
||||
}));
|
||||
|
@ -157,7 +157,7 @@ void nano::bootstrap_initiator::lazy_requeue (nano::block_hash const & hash_a, n
|
|||
}
|
||||
}
|
||||
|
||||
void nano::bootstrap_initiator::add_observer (std::function<void(bool)> const & observer_a)
|
||||
void nano::bootstrap_initiator::add_observer (std::function<void (bool)> const & observer_a)
|
||||
{
|
||||
nano::lock_guard<nano::mutex> lock (observers_mutex);
|
||||
observers.push_back (observer_a);
|
||||
|
@ -327,7 +327,7 @@ void nano::pulls_cache::add (nano::pull_info const & pull_a)
|
|||
else
|
||||
{
|
||||
// Update existing pull
|
||||
cache.get<account_head_tag> ().modify (existing, [pull_a](nano::cached_pulls & cache_a) {
|
||||
cache.get<account_head_tag> ().modify (existing, [pull_a] (nano::cached_pulls & cache_a) {
|
||||
cache_a.time = std::chrono::steady_clock::now ();
|
||||
cache_a.new_head = pull_a.head;
|
||||
});
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
void run_bootstrap ();
|
||||
void lazy_requeue (nano::block_hash const &, nano::block_hash const &, bool);
|
||||
void notify_listeners (bool);
|
||||
void add_observer (std::function<void(bool)> const &);
|
||||
void add_observer (std::function<void (bool)> const &);
|
||||
bool in_progress ();
|
||||
std::shared_ptr<nano::bootstrap_connections> connections;
|
||||
std::shared_ptr<nano::bootstrap_attempt> new_attempt ();
|
||||
|
@ -110,7 +110,7 @@ private:
|
|||
nano::mutex mutex;
|
||||
nano::condition_variable condition;
|
||||
nano::mutex observers_mutex;
|
||||
std::vector<std::function<void(bool)>> observers;
|
||||
std::vector<std::function<void (bool)>> observers;
|
||||
std::vector<boost::thread> bootstrap_initiator_threads;
|
||||
|
||||
friend std::unique_ptr<container_info_component> collect_container_info (bootstrap_initiator & bootstrap_initiator, std::string const & name);
|
||||
|
|
|
@ -16,10 +16,10 @@ constexpr unsigned nano::bootstrap_limits::requeued_pulls_limit;
|
|||
constexpr unsigned nano::bootstrap_limits::requeued_pulls_limit_dev;
|
||||
|
||||
nano::bootstrap_attempt::bootstrap_attempt (std::shared_ptr<nano::node> const & node_a, nano::bootstrap_mode mode_a, uint64_t incremental_id_a, std::string id_a) :
|
||||
node (node_a),
|
||||
incremental_id (incremental_id_a),
|
||||
id (id_a),
|
||||
mode (mode_a)
|
||||
node (node_a),
|
||||
incremental_id (incremental_id_a),
|
||||
id (id_a),
|
||||
mode (mode_a)
|
||||
{
|
||||
if (id.empty ())
|
||||
{
|
||||
|
|
|
@ -8,23 +8,23 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
nano::pull_info::pull_info (nano::hash_or_account const & account_or_head_a, nano::block_hash const & head_a, nano::block_hash const & end_a, uint64_t bootstrap_id_a, count_t count_a, unsigned retry_limit_a) :
|
||||
account_or_head (account_or_head_a),
|
||||
head (head_a),
|
||||
head_original (head_a),
|
||||
end (end_a),
|
||||
count (count_a),
|
||||
retry_limit (retry_limit_a),
|
||||
bootstrap_id (bootstrap_id_a)
|
||||
account_or_head (account_or_head_a),
|
||||
head (head_a),
|
||||
head_original (head_a),
|
||||
end (end_a),
|
||||
count (count_a),
|
||||
retry_limit (retry_limit_a),
|
||||
bootstrap_id (bootstrap_id_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::bulk_pull_client::bulk_pull_client (std::shared_ptr<nano::bootstrap_client> const & connection_a, std::shared_ptr<nano::bootstrap_attempt> const & attempt_a, nano::pull_info const & pull_a) :
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
known_account (0),
|
||||
pull (pull_a),
|
||||
pull_blocks (0),
|
||||
unexpected_count (0)
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
known_account (0),
|
||||
pull (pull_a),
|
||||
pull_blocks (0),
|
||||
unexpected_count (0)
|
||||
{
|
||||
attempt->condition.notify_all ();
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ void nano::bulk_pull_client::request ()
|
|||
}
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send (
|
||||
req, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
req, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->throttled_receive_block ();
|
||||
|
@ -110,7 +110,7 @@ void nano::bulk_pull_client::throttled_receive_block ()
|
|||
else
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
connection->node->workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_l]() {
|
||||
connection->node->workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_l] () {
|
||||
if (!this_l->connection->pending_stop && !this_l->attempt->stopped)
|
||||
{
|
||||
this_l->throttled_receive_block ();
|
||||
|
@ -122,7 +122,7 @@ void nano::bulk_pull_client::throttled_receive_block ()
|
|||
void nano::bulk_pull_client::receive_block ()
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
connection->socket->async_read (connection->receive_buffer, 1, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (connection->receive_buffer, 1, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->received_type ();
|
||||
|
@ -149,35 +149,35 @@ void nano::bulk_pull_client::received_type ()
|
|||
{
|
||||
case nano::block_type::send:
|
||||
{
|
||||
socket_l->async_read (connection->receive_buffer, nano::send_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_l->async_read (connection->receive_buffer, nano::send_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::block_type::receive:
|
||||
{
|
||||
socket_l->async_read (connection->receive_buffer, nano::receive_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_l->async_read (connection->receive_buffer, nano::receive_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::block_type::open:
|
||||
{
|
||||
socket_l->async_read (connection->receive_buffer, nano::open_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_l->async_read (connection->receive_buffer, nano::open_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::block_type::change:
|
||||
{
|
||||
socket_l->async_read (connection->receive_buffer, nano::change_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_l->async_read (connection->receive_buffer, nano::change_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::block_type::state:
|
||||
{
|
||||
socket_l->async_read (connection->receive_buffer, nano::state_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket_l->async_read (connection->receive_buffer, nano::state_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
@ -285,10 +285,10 @@ void nano::bulk_pull_client::received_block (boost::system::error_code const & e
|
|||
}
|
||||
|
||||
nano::bulk_pull_account_client::bulk_pull_account_client (std::shared_ptr<nano::bootstrap_client> const & connection_a, std::shared_ptr<nano::bootstrap_attempt> const & attempt_a, nano::account const & account_a) :
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
account (account_a),
|
||||
pull_blocks (0)
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
account (account_a),
|
||||
pull_blocks (0)
|
||||
{
|
||||
attempt->condition.notify_all ();
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ void nano::bulk_pull_account_client::request ()
|
|||
}
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send (
|
||||
req, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
req, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->receive_pending ();
|
||||
|
@ -336,7 +336,7 @@ void nano::bulk_pull_account_client::receive_pending ()
|
|||
{
|
||||
auto this_l (shared_from_this ());
|
||||
size_t size_l (sizeof (nano::uint256_union) + sizeof (nano::uint128_union));
|
||||
connection->socket->async_read (connection->receive_buffer, size_l, [this_l, size_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (connection->receive_buffer, size_l, [this_l, size_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
// An issue with asio is that sometimes, instead of reporting a bad file descriptor during disconnect,
|
||||
// we simply get a size of 0.
|
||||
if (size_a == size_l)
|
||||
|
@ -494,7 +494,7 @@ void nano::bulk_pull_server::send_next ()
|
|||
{
|
||||
connection->node->logger.try_log (boost::str (boost::format ("Sending block: %1%") % block->hash ().to_string ()));
|
||||
}
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->sent_action (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ void nano::bulk_pull_server::send_finished ()
|
|||
{
|
||||
connection->node->logger.try_log ("Bulk sending finished");
|
||||
}
|
||||
connection->socket->async_write (send_buffer, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (send_buffer, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->no_block_sent (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
@ -620,8 +620,8 @@ void nano::bulk_pull_server::no_block_sent (boost::system::error_code const & ec
|
|||
}
|
||||
|
||||
nano::bulk_pull_server::bulk_pull_server (std::shared_ptr<nano::bootstrap_server> const & connection_a, std::unique_ptr<nano::bulk_pull> request_a) :
|
||||
connection (connection_a),
|
||||
request (std::move (request_a))
|
||||
connection (connection_a),
|
||||
request (std::move (request_a))
|
||||
{
|
||||
set_current_end ();
|
||||
}
|
||||
|
@ -700,7 +700,7 @@ void nano::bulk_pull_account_server::send_frontier ()
|
|||
|
||||
// Send the buffer to the requestor
|
||||
auto this_l (shared_from_this ());
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->sent_action (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
@ -756,7 +756,7 @@ void nano::bulk_pull_account_server::send_next_block ()
|
|||
}
|
||||
|
||||
auto this_l (shared_from_this ());
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->sent_action (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
@ -903,7 +903,7 @@ void nano::bulk_pull_account_server::send_finished ()
|
|||
connection->node->logger.try_log ("Bulk sending for an account finished");
|
||||
}
|
||||
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->complete (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
@ -940,9 +940,9 @@ void nano::bulk_pull_account_server::complete (boost::system::error_code const &
|
|||
}
|
||||
|
||||
nano::bulk_pull_account_server::bulk_pull_account_server (std::shared_ptr<nano::bootstrap_server> const & connection_a, std::unique_ptr<nano::bulk_pull_account> request_a) :
|
||||
connection (connection_a),
|
||||
request (std::move (request_a)),
|
||||
current_key (0, 0)
|
||||
connection (connection_a),
|
||||
request (std::move (request_a)),
|
||||
current_key (0, 0)
|
||||
{
|
||||
/*
|
||||
* Setup the streaming response for the first call to "send_frontier" and "send_next_block"
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
nano::bulk_push_client::bulk_push_client (std::shared_ptr<nano::bootstrap_client> const & connection_a, std::shared_ptr<nano::bootstrap_attempt> const & attempt_a) :
|
||||
connection (connection_a),
|
||||
attempt (attempt_a)
|
||||
connection (connection_a),
|
||||
attempt (attempt_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ void nano::bulk_push_client::start ()
|
|||
nano::bulk_push message;
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send (
|
||||
message, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
message, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->push ();
|
||||
|
@ -77,7 +77,7 @@ void nano::bulk_push_client::send_finished ()
|
|||
{
|
||||
nano::shared_const_buffer buffer (static_cast<uint8_t> (nano::block_type::not_a_block));
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send_buffer (buffer, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->channel->send_buffer (buffer, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
try
|
||||
{
|
||||
this_l->promise.set_value (false);
|
||||
|
@ -96,7 +96,7 @@ void nano::bulk_push_client::push_block (nano::block const & block_a)
|
|||
nano::serialize_block (stream, block_a);
|
||||
}
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send_buffer (nano::shared_const_buffer (std::move (buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->channel->send_buffer (nano::shared_const_buffer (std::move (buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->push ();
|
||||
|
@ -112,8 +112,8 @@ void nano::bulk_push_client::push_block (nano::block const & block_a)
|
|||
}
|
||||
|
||||
nano::bulk_push_server::bulk_push_server (std::shared_ptr<nano::bootstrap_server> const & connection_a) :
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
connection (connection_a)
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
connection (connection_a)
|
||||
{
|
||||
receive_buffer->resize (256);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ void nano::bulk_push_server::throttled_receive ()
|
|||
else
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
connection->node->workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_l]() {
|
||||
connection->node->workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_l] () {
|
||||
if (!this_l->connection->stopped)
|
||||
{
|
||||
this_l->throttled_receive ();
|
||||
|
@ -148,7 +148,7 @@ void nano::bulk_push_server::receive ()
|
|||
else
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
connection->socket->async_read (receive_buffer, 1, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, 1, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->received_type ();
|
||||
|
@ -173,7 +173,7 @@ void nano::bulk_push_server::received_type ()
|
|||
case nano::block_type::send:
|
||||
{
|
||||
connection->node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::send, nano::stat::dir::in);
|
||||
connection->socket->async_read (receive_buffer, nano::send_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, nano::send_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
@ -181,7 +181,7 @@ void nano::bulk_push_server::received_type ()
|
|||
case nano::block_type::receive:
|
||||
{
|
||||
connection->node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::receive, nano::stat::dir::in);
|
||||
connection->socket->async_read (receive_buffer, nano::receive_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, nano::receive_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
@ -189,7 +189,7 @@ void nano::bulk_push_server::received_type ()
|
|||
case nano::block_type::open:
|
||||
{
|
||||
connection->node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::open, nano::stat::dir::in);
|
||||
connection->socket->async_read (receive_buffer, nano::open_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, nano::open_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
@ -197,7 +197,7 @@ void nano::bulk_push_server::received_type ()
|
|||
case nano::block_type::change:
|
||||
{
|
||||
connection->node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::change, nano::stat::dir::in);
|
||||
connection->socket->async_read (receive_buffer, nano::change_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, nano::change_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
@ -205,7 +205,7 @@ void nano::bulk_push_server::received_type ()
|
|||
case nano::block_type::state:
|
||||
{
|
||||
connection->node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::state_block, nano::stat::dir::in);
|
||||
connection->socket->async_read (receive_buffer, nano::state_block::size, [this_l, type](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (receive_buffer, nano::state_block::size, [this_l, type] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->received_block (ec, size_a, type);
|
||||
});
|
||||
break;
|
||||
|
|
|
@ -14,12 +14,12 @@ constexpr unsigned nano::bootstrap_limits::bootstrap_max_new_connections;
|
|||
constexpr unsigned nano::bootstrap_limits::requeued_pulls_processed_blocks_factor;
|
||||
|
||||
nano::bootstrap_client::bootstrap_client (std::shared_ptr<nano::node> const & node_a, std::shared_ptr<nano::bootstrap_connections> const & connections_a, std::shared_ptr<nano::transport::channel_tcp> const & channel_a, std::shared_ptr<nano::socket> const & socket_a) :
|
||||
node (node_a),
|
||||
connections (connections_a),
|
||||
channel (channel_a),
|
||||
socket (socket_a),
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
start_time_m (std::chrono::steady_clock::now ())
|
||||
node (node_a),
|
||||
connections (connections_a),
|
||||
channel (channel_a),
|
||||
socket (socket_a),
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
start_time_m (std::chrono::steady_clock::now ())
|
||||
{
|
||||
++connections->connections_count;
|
||||
receive_buffer->resize (256);
|
||||
|
@ -60,14 +60,14 @@ void nano::bootstrap_client::stop (bool force)
|
|||
}
|
||||
|
||||
nano::bootstrap_connections::bootstrap_connections (nano::node & node_a) :
|
||||
node (node_a)
|
||||
node (node_a)
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<nano::bootstrap_client> nano::bootstrap_connections::connection (std::shared_ptr<nano::bootstrap_attempt> const & attempt_a, bool use_front_connection)
|
||||
{
|
||||
nano::unique_lock<nano::mutex> lock (mutex);
|
||||
condition.wait (lock, [& stopped = stopped, &idle = idle, &new_connections_empty = new_connections_empty] { return stopped || !idle.empty () || new_connections_empty; });
|
||||
condition.wait (lock, [&stopped = stopped, &idle = idle, &new_connections_empty = new_connections_empty] { return stopped || !idle.empty () || new_connections_empty; });
|
||||
std::shared_ptr<nano::bootstrap_client> result;
|
||||
if (!stopped && !idle.empty ())
|
||||
{
|
||||
|
@ -147,7 +147,7 @@ void nano::bootstrap_connections::connect_client (nano::tcp_endpoint const & end
|
|||
auto socket (std::make_shared<nano::socket> (node));
|
||||
auto this_l (shared_from_this ());
|
||||
socket->async_connect (endpoint_a,
|
||||
[this_l, socket, endpoint_a, push_front](boost::system::error_code const & ec) {
|
||||
[this_l, socket, endpoint_a, push_front] (boost::system::error_code const & ec) {
|
||||
if (!ec)
|
||||
{
|
||||
if (this_l->node.config.logging.bulk_pull_logging ())
|
||||
|
@ -304,7 +304,7 @@ void nano::bootstrap_connections::populate_connections (bool repeat)
|
|||
if (!stopped && repeat)
|
||||
{
|
||||
std::weak_ptr<nano::bootstrap_connections> this_w (shared_from_this ());
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_w]() {
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + std::chrono::seconds (1), [this_w] () {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
this_l->populate_connections ();
|
||||
|
@ -358,7 +358,7 @@ void nano::bootstrap_connections::request_pull (nano::unique_lock<nano::mutex> &
|
|||
{
|
||||
// The bulk_pull_client destructor attempt to requeue_pull which can cause a deadlock if this is the last reference
|
||||
// Dispatch request in an external thread in case it needs to be destroyed
|
||||
node.background ([connection_l, attempt_l, pull]() {
|
||||
node.background ([connection_l, attempt_l, pull] () {
|
||||
auto client (std::make_shared<nano::bulk_pull_client> (connection_l, attempt_l, pull));
|
||||
client->request ();
|
||||
});
|
||||
|
|
|
@ -24,7 +24,7 @@ void nano::frontier_req_client::run (nano::account const & start_account_a, uint
|
|||
next (); // Load accounts from disk
|
||||
auto this_l (shared_from_this ());
|
||||
connection->channel->send (
|
||||
request, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
request, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->receive_frontier ();
|
||||
|
@ -41,17 +41,17 @@ void nano::frontier_req_client::run (nano::account const & start_account_a, uint
|
|||
}
|
||||
|
||||
nano::frontier_req_client::frontier_req_client (std::shared_ptr<nano::bootstrap_client> const & connection_a, std::shared_ptr<nano::bootstrap_attempt> const & attempt_a) :
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
count (0),
|
||||
bulk_push_cost (0)
|
||||
connection (connection_a),
|
||||
attempt (attempt_a),
|
||||
count (0),
|
||||
bulk_push_cost (0)
|
||||
{
|
||||
}
|
||||
|
||||
void nano::frontier_req_client::receive_frontier ()
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
connection->socket->async_read (connection->receive_buffer, nano::frontier_req_client::size_frontier, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_read (connection->receive_buffer, nano::frontier_req_client::size_frontier, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
// An issue with asio is that sometimes, instead of reporting a bad file descriptor during disconnect,
|
||||
// we simply get a size of 0.
|
||||
if (size_a == nano::frontier_req_client::size_frontier)
|
||||
|
@ -234,11 +234,11 @@ void nano::frontier_req_client::next ()
|
|||
}
|
||||
|
||||
nano::frontier_req_server::frontier_req_server (std::shared_ptr<nano::bootstrap_server> const & connection_a, std::unique_ptr<nano::frontier_req> request_a) :
|
||||
connection (connection_a),
|
||||
current (request_a->start.number () - 1),
|
||||
frontier (0),
|
||||
request (std::move (request_a)),
|
||||
count (0)
|
||||
connection (connection_a),
|
||||
current (request_a->start.number () - 1),
|
||||
frontier (0),
|
||||
request (std::move (request_a)),
|
||||
count (0)
|
||||
{
|
||||
next ();
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ void nano::frontier_req_server::send_next ()
|
|||
connection->node->logger.try_log (boost::str (boost::format ("Sending frontier for %1% %2%") % current.to_account () % frontier.to_string ()));
|
||||
}
|
||||
next ();
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->sent_action (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
@ -285,7 +285,7 @@ void nano::frontier_req_server::send_finished ()
|
|||
{
|
||||
connection->node->logger.try_log ("Frontier sending finished");
|
||||
}
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (nano::shared_const_buffer (std::move (send_buffer)), [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->no_block_sent (ec, size_a);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ constexpr double nano::bootstrap_limits::lazy_batch_pull_count_resize_ratio;
|
|||
constexpr size_t nano::bootstrap_limits::lazy_blocks_restart_limit;
|
||||
|
||||
nano::bootstrap_attempt_lazy::bootstrap_attempt_lazy (std::shared_ptr<nano::node> const & node_a, uint64_t incremental_id_a, std::string const & id_a) :
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::lazy, incremental_id_a, id_a)
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::lazy, incremental_id_a, id_a)
|
||||
{
|
||||
node->bootstrap_initiator.notify_listeners (true);
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ void nano::bootstrap_attempt_lazy::run ()
|
|||
auto this_l (shared_from_this ());
|
||||
while (still_pulling () && !lazy_has_expired ())
|
||||
{
|
||||
condition.wait (lock, [& stopped = stopped, &pulling = pulling, &lazy_pulls = lazy_pulls, this_l] { return stopped || pulling == 0 || (pulling < nano::bootstrap_limits::bootstrap_connection_scale_target_blocks && !lazy_pulls.empty ()) || this_l->lazy_has_expired (); });
|
||||
condition.wait (lock, [&stopped = stopped, &pulling = pulling, &lazy_pulls = lazy_pulls, this_l] { return stopped || pulling == 0 || (pulling < nano::bootstrap_limits::bootstrap_connection_scale_target_blocks && !lazy_pulls.empty ()) || this_l->lazy_has_expired (); });
|
||||
++iterations;
|
||||
// Flushing lazy pulls
|
||||
lazy_pull_flush (lock);
|
||||
|
@ -462,7 +462,7 @@ void nano::bootstrap_attempt_lazy::get_information (boost::property_tree::ptree
|
|||
}
|
||||
|
||||
nano::bootstrap_attempt_wallet::bootstrap_attempt_wallet (std::shared_ptr<nano::node> const & node_a, uint64_t incremental_id_a, std::string id_a) :
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::wallet_lazy, incremental_id_a, id_a)
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::wallet_lazy, incremental_id_a, id_a)
|
||||
{
|
||||
node->bootstrap_initiator.notify_listeners (true);
|
||||
}
|
||||
|
@ -485,7 +485,7 @@ void nano::bootstrap_attempt_wallet::request_pending (nano::unique_lock<nano::mu
|
|||
auto this_l (shared_from_this ());
|
||||
// The bulk_pull_account_client destructor attempt to requeue_pull which can cause a deadlock if this is the last reference
|
||||
// Dispatch request in an external thread in case it needs to be destroyed
|
||||
node->background ([connection_l, this_l, account]() {
|
||||
node->background ([connection_l, this_l, account] () {
|
||||
auto client (std::make_shared<nano::bulk_pull_account_client> (connection_l, this_l, account));
|
||||
client->request ();
|
||||
});
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
nano::bootstrap_attempt_legacy::bootstrap_attempt_legacy (std::shared_ptr<nano::node> const & node_a, uint64_t const incremental_id_a, std::string const & id_a, uint32_t const frontiers_age_a, nano::account const & start_account_a) :
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::legacy, incremental_id_a, id_a),
|
||||
frontiers_age (frontiers_age_a),
|
||||
start_account (start_account_a)
|
||||
nano::bootstrap_attempt (node_a, nano::bootstrap_mode::legacy, incremental_id_a, id_a),
|
||||
frontiers_age (frontiers_age_a),
|
||||
start_account (start_account_a)
|
||||
{
|
||||
node->bootstrap_initiator.notify_listeners (true);
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
#include <boost/variant/get.hpp>
|
||||
|
||||
nano::bootstrap_listener::bootstrap_listener (uint16_t port_a, nano::node & node_a) :
|
||||
node (node_a),
|
||||
port (port_a)
|
||||
node (node_a),
|
||||
port (port_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ void nano::bootstrap_listener::start ()
|
|||
throw std::runtime_error (ec.message ());
|
||||
}
|
||||
debug_assert (node.network.endpoint ().port () == listening_socket->listening_port ());
|
||||
listening_socket->on_connection ([this](std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
listening_socket->on_connection ([this] (std::shared_ptr<nano::socket> const & new_connection, boost::system::error_code const & ec_a) {
|
||||
bool keep_accepting = true;
|
||||
if (ec_a)
|
||||
{
|
||||
|
@ -104,9 +104,9 @@ std::unique_ptr<nano::container_info_component> nano::collect_container_info (bo
|
|||
}
|
||||
|
||||
nano::bootstrap_server::bootstrap_server (std::shared_ptr<nano::socket> const & socket_a, std::shared_ptr<nano::node> const & node_a) :
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
socket (socket_a),
|
||||
node (node_a)
|
||||
receive_buffer (std::make_shared<std::vector<uint8_t>> ()),
|
||||
socket (socket_a),
|
||||
node (node_a)
|
||||
{
|
||||
receive_buffer->resize (1024);
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ void nano::bootstrap_server::receive ()
|
|||
// Increase timeout to receive TCP header (idle server socket)
|
||||
socket->set_timeout (node->network_params.node.idle_timeout);
|
||||
auto this_l (shared_from_this ());
|
||||
socket->async_read (receive_buffer, 8, [this_l](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, 8, [this_l] (boost::system::error_code const & ec, size_t size_a) {
|
||||
// Set remote_endpoint
|
||||
if (this_l->remote_endpoint.port () == 0)
|
||||
{
|
||||
|
@ -182,7 +182,7 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
|
|||
case nano::message_type::bulk_pull:
|
||||
{
|
||||
node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::bulk_pull, nano::stat::dir::in);
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_bulk_pull_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
|
@ -190,7 +190,7 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
|
|||
case nano::message_type::bulk_pull_account:
|
||||
{
|
||||
node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::bulk_pull_account, nano::stat::dir::in);
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_bulk_pull_account_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
|
@ -198,7 +198,7 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
|
|||
case nano::message_type::frontier_req:
|
||||
{
|
||||
node->stats.inc (nano::stat::type::bootstrap, nano::stat::detail::frontier_req, nano::stat::dir::in);
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_frontier_req_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
|
@ -214,35 +214,35 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
|
|||
}
|
||||
case nano::message_type::keepalive:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_keepalive_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::message_type::publish:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_publish_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::message_type::confirm_ack:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_confirm_ack_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::message_type::confirm_req:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_confirm_req_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
}
|
||||
case nano::message_type::node_id_handshake:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_node_id_handshake_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
|
@ -269,7 +269,7 @@ void nano::bootstrap_server::receive_header_action (boost::system::error_code co
|
|||
}
|
||||
case nano::message_type::telemetry_ack:
|
||||
{
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header](boost::system::error_code const & ec, size_t size_a) {
|
||||
socket->async_read (receive_buffer, header.payload_length_bytes (), [this_l, header] (boost::system::error_code const & ec, size_t size_a) {
|
||||
this_l->receive_telemetry_ack_action (ec, size_a, header);
|
||||
});
|
||||
break;
|
||||
|
@ -567,7 +567,7 @@ void nano::bootstrap_server::finish_request ()
|
|||
else
|
||||
{
|
||||
std::weak_ptr<nano::bootstrap_server> this_w (shared_from_this ());
|
||||
node->workers.add_timed_task (std::chrono::steady_clock::now () + (node->config.tcp_io_timeout * 2) + std::chrono::seconds (1), [this_w]() {
|
||||
node->workers.add_timed_task (std::chrono::steady_clock::now () + (node->config.tcp_io_timeout * 2) + std::chrono::seconds (1), [this_w] () {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
this_l->timeout ();
|
||||
|
@ -579,7 +579,7 @@ void nano::bootstrap_server::finish_request ()
|
|||
void nano::bootstrap_server::finish_request_async ()
|
||||
{
|
||||
std::weak_ptr<nano::bootstrap_server> this_w (shared_from_this ());
|
||||
node->background ([this_w]() {
|
||||
node->background ([this_w] () {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
this_l->finish_request ();
|
||||
|
@ -617,7 +617,7 @@ class request_response_visitor : public nano::message_visitor
|
|||
{
|
||||
public:
|
||||
explicit request_response_visitor (std::shared_ptr<nano::bootstrap_server> const & connection_a) :
|
||||
connection (connection_a)
|
||||
connection (connection_a)
|
||||
{
|
||||
}
|
||||
void keepalive (nano::keepalive const & message_a) override
|
||||
|
@ -677,7 +677,7 @@ public:
|
|||
auto cookie (connection->node->network.syn_cookies.assign (nano::transport::map_tcp_to_endpoint (connection->remote_endpoint)));
|
||||
nano::node_id_handshake response_message (cookie, response);
|
||||
auto shared_const_buffer = response_message.to_shared_const_buffer ();
|
||||
connection->socket->async_write (shared_const_buffer, [connection = std::weak_ptr<nano::bootstrap_server> (connection)](boost::system::error_code const & ec, size_t size_a) {
|
||||
connection->socket->async_write (shared_const_buffer, [connection = std::weak_ptr<nano::bootstrap_server> (connection)] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (auto connection_l = connection.lock ())
|
||||
{
|
||||
if (ec)
|
||||
|
@ -748,7 +748,7 @@ void nano::bootstrap_server::run_next (nano::unique_lock<nano::mutex> & lock_a)
|
|||
if (timeout_check)
|
||||
{
|
||||
std::weak_ptr<nano::bootstrap_server> this_w (shared_from_this ());
|
||||
node->workers.add_timed_task (std::chrono::steady_clock::now () + (node->config.tcp_io_timeout * 2) + std::chrono::seconds (1), [this_w]() {
|
||||
node->workers.add_timed_task (std::chrono::steady_clock::now () + (node->config.tcp_io_timeout * 2) + std::chrono::seconds (1), [this_w] () {
|
||||
if (auto this_l = this_w.lock ())
|
||||
{
|
||||
this_l->timeout ();
|
||||
|
|
|
@ -675,11 +675,11 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map
|
|||
if (valid_type)
|
||||
{
|
||||
std::cout << "# This is an example configuration file for Nano. Visit https://docs.nano.org/running-a-node/configuration/ for more information.\n#\n"
|
||||
<< "# Fields may need to be defined in the context of a [category] above them.\n"
|
||||
<< "# The desired configuration changes should be placed in config-" << type << ".toml in the node data path.\n"
|
||||
<< "# To change a value from its default, uncomment (erasing #) the corresponding field.\n"
|
||||
<< "# It is not recommended to uncomment every field, as the default value for important fields may change in the future. Only change what you need.\n"
|
||||
<< "# Additional information for notable configuration options is available in https://docs.nano.org/running-a-node/configuration/#notable-configuration-options\n";
|
||||
<< "# Fields may need to be defined in the context of a [category] above them.\n"
|
||||
<< "# The desired configuration changes should be placed in config-" << type << ".toml in the node data path.\n"
|
||||
<< "# To change a value from its default, uncomment (erasing #) the corresponding field.\n"
|
||||
<< "# It is not recommended to uncomment every field, as the default value for important fields may change in the future. Only change what you need.\n"
|
||||
<< "# Additional information for notable configuration options is available in https://docs.nano.org/running-a-node/configuration/#notable-configuration-options\n";
|
||||
|
||||
if (vm.count ("use_defaults"))
|
||||
{
|
||||
|
@ -732,8 +732,8 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map
|
|||
{
|
||||
nano::keypair pair;
|
||||
std::cout << "Private: " << pair.prv.to_string () << std::endl
|
||||
<< "Public: " << pair.pub.to_string () << std::endl
|
||||
<< "Account: " << pair.pub.to_account () << std::endl;
|
||||
<< "Public: " << pair.pub.to_string () << std::endl
|
||||
<< "Account: " << pair.pub.to_account () << std::endl;
|
||||
}
|
||||
else if (vm.count ("key_expand"))
|
||||
{
|
||||
|
@ -743,8 +743,8 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map
|
|||
prv.decode_hex (vm["key"].as<std::string> ());
|
||||
nano::public_key pub (nano::pub_key (prv));
|
||||
std::cout << "Private: " << prv.to_string () << std::endl
|
||||
<< "Public: " << pub.to_string () << std::endl
|
||||
<< "Account: " << pub.to_account () << std::endl;
|
||||
<< "Public: " << pub.to_string () << std::endl
|
||||
<< "Account: " << pub.to_account () << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -50,9 +50,9 @@ uint64_t nano::ip_address_hash_raw (boost::asio::ip::address const & ip_a, uint1
|
|||
}
|
||||
|
||||
nano::message_header::message_header (nano::message_type type_a) :
|
||||
version_max (get_protocol_constants ().protocol_version),
|
||||
version_using (get_protocol_constants ().protocol_version),
|
||||
type (type_a)
|
||||
version_max (get_protocol_constants ().protocol_version),
|
||||
version_using (get_protocol_constants ().protocol_version),
|
||||
type (type_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -111,12 +111,12 @@ uint8_t nano::message_header::version_min () const
|
|||
}
|
||||
|
||||
nano::message::message (nano::message_type type_a) :
|
||||
header (type_a)
|
||||
header (type_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::message::message (nano::message_header const & header_a) :
|
||||
header (header_a)
|
||||
header (header_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -336,12 +336,12 @@ std::string nano::message_parser::status_string ()
|
|||
}
|
||||
|
||||
nano::message_parser::message_parser (nano::network_filter & publish_filter_a, nano::block_uniquer & block_uniquer_a, nano::vote_uniquer & vote_uniquer_a, nano::message_visitor & visitor_a, nano::work_pool & pool_a) :
|
||||
publish_filter (publish_filter_a),
|
||||
block_uniquer (block_uniquer_a),
|
||||
vote_uniquer (vote_uniquer_a),
|
||||
visitor (visitor_a),
|
||||
pool (pool_a),
|
||||
status (parse_status::success)
|
||||
publish_filter (publish_filter_a),
|
||||
block_uniquer (block_uniquer_a),
|
||||
vote_uniquer (vote_uniquer_a),
|
||||
visitor (visitor_a),
|
||||
pool (pool_a),
|
||||
status (parse_status::success)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -558,7 +558,7 @@ bool nano::message_parser::at_end (nano::stream & stream_a)
|
|||
}
|
||||
|
||||
nano::keepalive::keepalive () :
|
||||
message (nano::message_type::keepalive)
|
||||
message (nano::message_type::keepalive)
|
||||
{
|
||||
nano::endpoint endpoint (boost::asio::ip::address_v6{}, 0);
|
||||
for (auto i (peers.begin ()), n (peers.end ()); i != n; ++i)
|
||||
|
@ -568,7 +568,7 @@ message (nano::message_type::keepalive)
|
|||
}
|
||||
|
||||
nano::keepalive::keepalive (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -619,8 +619,8 @@ bool nano::keepalive::operator== (nano::keepalive const & other_a) const
|
|||
}
|
||||
|
||||
nano::publish::publish (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a, nano::uint128_t const & digest_a, nano::block_uniquer * uniquer_a) :
|
||||
message (header_a),
|
||||
digest (digest_a)
|
||||
message (header_a),
|
||||
digest (digest_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -629,8 +629,8 @@ digest (digest_a)
|
|||
}
|
||||
|
||||
nano::publish::publish (std::shared_ptr<nano::block> const & block_a) :
|
||||
message (nano::message_type::publish),
|
||||
block (block_a)
|
||||
message (nano::message_type::publish),
|
||||
block (block_a)
|
||||
{
|
||||
header.block_type_set (block->type ());
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ bool nano::publish::operator== (nano::publish const & other_a) const
|
|||
}
|
||||
|
||||
nano::confirm_req::confirm_req (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a, nano::block_uniquer * uniquer_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -670,15 +670,15 @@ message (header_a)
|
|||
}
|
||||
|
||||
nano::confirm_req::confirm_req (std::shared_ptr<nano::block> const & block_a) :
|
||||
message (nano::message_type::confirm_req),
|
||||
block (block_a)
|
||||
message (nano::message_type::confirm_req),
|
||||
block (block_a)
|
||||
{
|
||||
header.block_type_set (block->type ());
|
||||
}
|
||||
|
||||
nano::confirm_req::confirm_req (std::vector<std::pair<nano::block_hash, nano::root>> const & roots_hashes_a) :
|
||||
message (nano::message_type::confirm_req),
|
||||
roots_hashes (roots_hashes_a)
|
||||
message (nano::message_type::confirm_req),
|
||||
roots_hashes (roots_hashes_a)
|
||||
{
|
||||
// not_a_block (1) block type for hashes + roots request
|
||||
header.block_type_set (nano::block_type::not_a_block);
|
||||
|
@ -687,8 +687,8 @@ roots_hashes (roots_hashes_a)
|
|||
}
|
||||
|
||||
nano::confirm_req::confirm_req (nano::block_hash const & hash_a, nano::root const & root_a) :
|
||||
message (nano::message_type::confirm_req),
|
||||
roots_hashes (std::vector<std::pair<nano::block_hash, nano::root>> (1, std::make_pair (hash_a, root_a)))
|
||||
message (nano::message_type::confirm_req),
|
||||
roots_hashes (std::vector<std::pair<nano::block_hash, nano::root>> (1, std::make_pair (hash_a, root_a)))
|
||||
{
|
||||
debug_assert (!roots_hashes.empty ());
|
||||
// not_a_block (1) block type for hashes + roots request
|
||||
|
@ -801,8 +801,8 @@ size_t nano::confirm_req::size (nano::block_type type_a, size_t count)
|
|||
}
|
||||
|
||||
nano::confirm_ack::confirm_ack (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a, nano::vote_uniquer * uniquer_a) :
|
||||
message (header_a),
|
||||
vote (nano::make_shared<nano::vote> (error_a, stream_a, header.block_type ()))
|
||||
message (header_a),
|
||||
vote (nano::make_shared<nano::vote> (error_a, stream_a, header.block_type ()))
|
||||
{
|
||||
if (!error_a && uniquer_a)
|
||||
{
|
||||
|
@ -811,8 +811,8 @@ vote (nano::make_shared<nano::vote> (error_a, stream_a, header.block_type ()))
|
|||
}
|
||||
|
||||
nano::confirm_ack::confirm_ack (std::shared_ptr<nano::vote> const & vote_a) :
|
||||
message (nano::message_type::confirm_ack),
|
||||
vote (vote_a)
|
||||
message (nano::message_type::confirm_ack),
|
||||
vote (vote_a)
|
||||
{
|
||||
debug_assert (!vote_a->blocks.empty ());
|
||||
auto & first_vote_block (vote_a->blocks[0]);
|
||||
|
@ -861,12 +861,12 @@ size_t nano::confirm_ack::size (nano::block_type type_a, size_t count)
|
|||
}
|
||||
|
||||
nano::frontier_req::frontier_req () :
|
||||
message (nano::message_type::frontier_req)
|
||||
message (nano::message_type::frontier_req)
|
||||
{
|
||||
}
|
||||
|
||||
nano::frontier_req::frontier_req (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -911,12 +911,12 @@ bool nano::frontier_req::operator== (nano::frontier_req const & other_a) const
|
|||
}
|
||||
|
||||
nano::bulk_pull::bulk_pull () :
|
||||
message (nano::message_type::bulk_pull)
|
||||
message (nano::message_type::bulk_pull)
|
||||
{
|
||||
}
|
||||
|
||||
nano::bulk_pull::bulk_pull (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -1007,12 +1007,12 @@ void nano::bulk_pull::set_count_present (bool value_a)
|
|||
}
|
||||
|
||||
nano::bulk_pull_account::bulk_pull_account () :
|
||||
message (nano::message_type::bulk_pull_account)
|
||||
message (nano::message_type::bulk_pull_account)
|
||||
{
|
||||
}
|
||||
|
||||
nano::bulk_pull_account::bulk_pull_account (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -1052,12 +1052,12 @@ bool nano::bulk_pull_account::deserialize (nano::stream & stream_a)
|
|||
}
|
||||
|
||||
nano::bulk_push::bulk_push () :
|
||||
message (nano::message_type::bulk_push)
|
||||
message (nano::message_type::bulk_push)
|
||||
{
|
||||
}
|
||||
|
||||
nano::bulk_push::bulk_push (nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1078,12 +1078,12 @@ void nano::bulk_push::visit (nano::message_visitor & visitor_a) const
|
|||
}
|
||||
|
||||
nano::telemetry_req::telemetry_req () :
|
||||
message (nano::message_type::telemetry_req)
|
||||
message (nano::message_type::telemetry_req)
|
||||
{
|
||||
}
|
||||
|
||||
nano::telemetry_req::telemetry_req (nano::message_header const & header_a) :
|
||||
message (header_a)
|
||||
message (header_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -1104,12 +1104,12 @@ void nano::telemetry_req::visit (nano::message_visitor & visitor_a) const
|
|||
}
|
||||
|
||||
nano::telemetry_ack::telemetry_ack () :
|
||||
message (nano::message_type::telemetry_ack)
|
||||
message (nano::message_type::telemetry_ack)
|
||||
{
|
||||
}
|
||||
|
||||
nano::telemetry_ack::telemetry_ack (bool & error_a, nano::stream & stream_a, nano::message_header const & message_header) :
|
||||
message (message_header)
|
||||
message (message_header)
|
||||
{
|
||||
if (!error_a)
|
||||
{
|
||||
|
@ -1118,8 +1118,8 @@ message (message_header)
|
|||
}
|
||||
|
||||
nano::telemetry_ack::telemetry_ack (nano::telemetry_data const & telemetry_data_a) :
|
||||
message (nano::message_type::telemetry_ack),
|
||||
data (telemetry_data_a)
|
||||
message (nano::message_type::telemetry_ack),
|
||||
data (telemetry_data_a)
|
||||
{
|
||||
debug_assert (telemetry_data::size + telemetry_data_a.unknown_data.size () <= message_header::telemetry_size_mask.to_ulong ()); // Maximum size the mask allows
|
||||
header.extensions &= ~message_header::telemetry_size_mask;
|
||||
|
@ -1357,17 +1357,17 @@ bool nano::telemetry_data::validate_signature () const
|
|||
}
|
||||
|
||||
nano::node_id_handshake::node_id_handshake (bool & error_a, nano::stream & stream_a, nano::message_header const & header_a) :
|
||||
message (header_a),
|
||||
query (boost::none),
|
||||
response (boost::none)
|
||||
message (header_a),
|
||||
query (boost::none),
|
||||
response (boost::none)
|
||||
{
|
||||
error_a = deserialize (stream_a);
|
||||
}
|
||||
|
||||
nano::node_id_handshake::node_id_handshake (boost::optional<nano::uint256_union> query, boost::optional<std::pair<nano::account, nano::signature>> response) :
|
||||
message (nano::message_type::node_id_handshake),
|
||||
query (query),
|
||||
response (response)
|
||||
message (nano::message_type::node_id_handshake),
|
||||
query (query),
|
||||
response (response)
|
||||
{
|
||||
if (query)
|
||||
{
|
||||
|
@ -1558,6 +1558,6 @@ std::chrono::seconds nano::telemetry_cache_cutoffs::network_to_time (network_con
|
|||
}
|
||||
|
||||
nano::node_singleton_memory_pool_purge_guard::node_singleton_memory_pool_purge_guard () :
|
||||
cleanup_guard ({ nano::block_memory_pool_purge, nano::purge_shared_ptr_singleton_pool_memory<nano::vote>, nano::purge_shared_ptr_singleton_pool_memory<nano::election>, nano::purge_singleton_inactive_votes_cache_pool_memory })
|
||||
cleanup_guard ({ nano::block_memory_pool_purge, nano::purge_shared_ptr_singleton_pool_memory<nano::vote>, nano::purge_shared_ptr_singleton_pool_memory<nano::election>, nano::purge_singleton_inactive_votes_cache_pool_memory })
|
||||
{
|
||||
}
|
||||
|
|
|
@ -11,16 +11,16 @@
|
|||
#include <numeric>
|
||||
|
||||
nano::confirmation_height_bounded::confirmation_height_bounded (nano::ledger & ledger_a, nano::write_database_queue & write_database_queue_a, std::chrono::milliseconds batch_separate_pending_min_time_a, nano::logging const & logging_a, nano::logger_mt & logger_a, std::atomic<bool> & stopped_a, uint64_t & batch_write_size_a, std::function<void (std::vector<std::shared_ptr<nano::block>> const &)> const & notify_observers_callback_a, std::function<void (nano::block_hash const &)> const & notify_block_already_cemented_observers_callback_a, std::function<uint64_t ()> const & awaiting_processing_size_callback_a) :
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
batch_separate_pending_min_time (batch_separate_pending_min_time_a),
|
||||
logging (logging_a),
|
||||
logger (logger_a),
|
||||
stopped (stopped_a),
|
||||
batch_write_size (batch_write_size_a),
|
||||
notify_observers_callback (notify_observers_callback_a),
|
||||
notify_block_already_cemented_observers_callback (notify_block_already_cemented_observers_callback_a),
|
||||
awaiting_processing_size_callback (awaiting_processing_size_callback_a)
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
batch_separate_pending_min_time (batch_separate_pending_min_time_a),
|
||||
logging (logging_a),
|
||||
logger (logger_a),
|
||||
stopped (stopped_a),
|
||||
batch_write_size (batch_write_size_a),
|
||||
notify_observers_callback (notify_observers_callback_a),
|
||||
notify_block_already_cemented_observers_callback (notify_block_already_cemented_observers_callback_a),
|
||||
awaiting_processing_size_callback (awaiting_processing_size_callback_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -561,34 +561,34 @@ void nano::confirmation_height_bounded::clear_process_vars ()
|
|||
}
|
||||
|
||||
nano::confirmation_height_bounded::receive_chain_details::receive_chain_details (nano::account const & account_a, uint64_t height_a, nano::block_hash const & hash_a, nano::block_hash const & top_level_a, boost::optional<nano::block_hash> next_a, uint64_t bottom_height_a, nano::block_hash const & bottom_most_a) :
|
||||
account (account_a),
|
||||
height (height_a),
|
||||
hash (hash_a),
|
||||
top_level (top_level_a),
|
||||
next (next_a),
|
||||
bottom_height (bottom_height_a),
|
||||
bottom_most (bottom_most_a)
|
||||
account (account_a),
|
||||
height (height_a),
|
||||
hash (hash_a),
|
||||
top_level (top_level_a),
|
||||
next (next_a),
|
||||
bottom_height (bottom_height_a),
|
||||
bottom_most (bottom_most_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::confirmation_height_bounded::write_details::write_details (nano::account const & account_a, uint64_t bottom_height_a, nano::block_hash const & bottom_hash_a, uint64_t top_height_a, nano::block_hash const & top_hash_a) :
|
||||
account (account_a),
|
||||
bottom_height (bottom_height_a),
|
||||
bottom_hash (bottom_hash_a),
|
||||
top_height (top_height_a),
|
||||
top_hash (top_hash_a)
|
||||
account (account_a),
|
||||
bottom_height (bottom_height_a),
|
||||
bottom_hash (bottom_hash_a),
|
||||
top_height (top_height_a),
|
||||
top_hash (top_hash_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::confirmation_height_bounded::receive_source_pair::receive_source_pair (confirmation_height_bounded::receive_chain_details const & receive_details_a, const block_hash & source_a) :
|
||||
receive_details (receive_details_a),
|
||||
source_hash (source_a)
|
||||
receive_details (receive_details_a),
|
||||
source_hash (source_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::confirmation_height_bounded::confirmed_info::confirmed_info (uint64_t confirmed_height_a, nano::block_hash const & iterated_frontier_a) :
|
||||
confirmed_height (confirmed_height_a),
|
||||
iterated_frontier (iterated_frontier_a)
|
||||
confirmed_height (confirmed_height_a),
|
||||
iterated_frontier (iterated_frontier_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -12,18 +12,18 @@
|
|||
#include <numeric>
|
||||
|
||||
nano::confirmation_height_processor::confirmation_height_processor (nano::ledger & ledger_a, nano::write_database_queue & write_database_queue_a, std::chrono::milliseconds batch_separate_pending_min_time_a, nano::logging const & logging_a, nano::logger_mt & logger_a, boost::latch & latch, confirmation_height_mode mode_a) :
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
// clang-format off
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
// clang-format off
|
||||
unbounded_processor (ledger_a, write_database_queue_a, batch_separate_pending_min_time_a, logging_a, logger_a, stopped, batch_write_size, [this](auto & cemented_blocks) { this->notify_observers (cemented_blocks); }, [this](auto const & block_hash_a) { this->notify_observers (block_hash_a); }, [this]() { return this->awaiting_processing_size (); }),
|
||||
bounded_processor (ledger_a, write_database_queue_a, batch_separate_pending_min_time_a, logging_a, logger_a, stopped, batch_write_size, [this](auto & cemented_blocks) { this->notify_observers (cemented_blocks); }, [this](auto const & block_hash_a) { this->notify_observers (block_hash_a); }, [this]() { return this->awaiting_processing_size (); }),
|
||||
// clang-format on
|
||||
thread ([this, &latch, mode_a] () {
|
||||
nano::thread_role::set (nano::thread_role::name::confirmation_height_processing);
|
||||
// Do not start running the processing thread until other threads have finished their operations
|
||||
latch.wait ();
|
||||
this->run (mode_a);
|
||||
})
|
||||
// clang-format on
|
||||
thread ([this, &latch, mode_a] () {
|
||||
nano::thread_role::set (nano::thread_role::name::confirmation_height_processing);
|
||||
// Do not start running the processing thread until other threads have finished their operations
|
||||
latch.wait ();
|
||||
this->run (mode_a);
|
||||
})
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -9,16 +9,16 @@
|
|||
#include <numeric>
|
||||
|
||||
nano::confirmation_height_unbounded::confirmation_height_unbounded (nano::ledger & ledger_a, nano::write_database_queue & write_database_queue_a, std::chrono::milliseconds batch_separate_pending_min_time_a, nano::logging const & logging_a, nano::logger_mt & logger_a, std::atomic<bool> & stopped_a, uint64_t & batch_write_size_a, std::function<void (std::vector<std::shared_ptr<nano::block>> const &)> const & notify_observers_callback_a, std::function<void (nano::block_hash const &)> const & notify_block_already_cemented_observers_callback_a, std::function<uint64_t ()> const & awaiting_processing_size_callback_a) :
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
batch_separate_pending_min_time (batch_separate_pending_min_time_a),
|
||||
logging (logging_a),
|
||||
logger (logger_a),
|
||||
stopped (stopped_a),
|
||||
batch_write_size (batch_write_size_a),
|
||||
notify_observers_callback (notify_observers_callback_a),
|
||||
notify_block_already_cemented_observers_callback (notify_block_already_cemented_observers_callback_a),
|
||||
awaiting_processing_size_callback (awaiting_processing_size_callback_a)
|
||||
ledger (ledger_a),
|
||||
write_database_queue (write_database_queue_a),
|
||||
batch_separate_pending_min_time (batch_separate_pending_min_time_a),
|
||||
logging (logging_a),
|
||||
logger (logger_a),
|
||||
stopped (stopped_a),
|
||||
batch_write_size (batch_write_size_a),
|
||||
notify_observers_callback (notify_observers_callback_a),
|
||||
notify_block_already_cemented_observers_callback (notify_block_already_cemented_observers_callback_a),
|
||||
awaiting_processing_size_callback (awaiting_processing_size_callback_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -485,23 +485,23 @@ uint64_t nano::confirmation_height_unbounded::block_cache_size () const
|
|||
}
|
||||
|
||||
nano::confirmation_height_unbounded::conf_height_details::conf_height_details (nano::account const & account_a, nano::block_hash const & hash_a, uint64_t height_a, uint64_t num_blocks_confirmed_a, std::vector<nano::block_hash> const & block_callback_data_a) :
|
||||
account (account_a),
|
||||
hash (hash_a),
|
||||
height (height_a),
|
||||
num_blocks_confirmed (num_blocks_confirmed_a),
|
||||
block_callback_data (block_callback_data_a)
|
||||
account (account_a),
|
||||
hash (hash_a),
|
||||
height (height_a),
|
||||
num_blocks_confirmed (num_blocks_confirmed_a),
|
||||
block_callback_data (block_callback_data_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::confirmation_height_unbounded::receive_source_pair::receive_source_pair (std::shared_ptr<conf_height_details> const & receive_details_a, const block_hash & source_a) :
|
||||
receive_details (receive_details_a),
|
||||
source_hash (source_a)
|
||||
receive_details (receive_details_a),
|
||||
source_hash (source_a)
|
||||
{
|
||||
}
|
||||
|
||||
nano::confirmation_height_unbounded::confirmed_iterated_pair::confirmed_iterated_pair (uint64_t confirmed_height_a, uint64_t iterated_height_a) :
|
||||
confirmed_height (confirmed_height_a),
|
||||
iterated_height (iterated_height_a)
|
||||
confirmed_height (confirmed_height_a),
|
||||
iterated_height (iterated_height_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
using namespace std::chrono_literals;
|
||||
|
||||
nano::confirmation_solicitor::confirmation_solicitor (nano::network & network_a, nano::node_config const & config_a) :
|
||||
max_block_broadcasts (config_a.network_params.network.is_dev_network () ? 4 : 30),
|
||||
max_election_requests (50),
|
||||
max_election_broadcasts (std::max<size_t> (network_a.fanout () / 2, 1)),
|
||||
network (network_a),
|
||||
config (config_a)
|
||||
max_block_broadcasts (config_a.network_params.network.is_dev_network () ? 4 : 30),
|
||||
max_election_requests (50),
|
||||
max_election_broadcasts (std::max<size_t> (network_a.fanout () / 2, 1)),
|
||||
network (network_a),
|
||||
config (config_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#include <vector>
|
||||
|
||||
nano::daemon_config::daemon_config (boost::filesystem::path const & data_path_a) :
|
||||
data_path (data_path_a)
|
||||
data_path (data_path_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -144,8 +144,8 @@ nano::error nano::read_node_config_toml (boost::filesystem::path const & data_pa
|
|||
if (boost::filesystem::exists (toml_config_path))
|
||||
{
|
||||
error = "Both json and toml node configuration files exists. "
|
||||
"Either remove the config.json file and restart, or remove "
|
||||
"the config-node.toml file to start migration on next launch.";
|
||||
"Either remove the config.json file and restart, or remove "
|
||||
"the config-node.toml file to start migration on next launch.";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -21,13 +21,13 @@ std::shared_ptr<request_type> nano::distributed_work::peer_request::get_prepared
|
|||
}
|
||||
|
||||
nano::distributed_work::distributed_work (nano::node & node_a, nano::work_request const & request_a, std::chrono::seconds const & backoff_a) :
|
||||
node (node_a),
|
||||
node_w (node_a.shared ()),
|
||||
request (request_a),
|
||||
backoff (backoff_a),
|
||||
strand (node_a.io_ctx.get_executor ()),
|
||||
need_resolve (request_a.peers),
|
||||
elapsed (nano::timer_state::started, "distributed work generation timer")
|
||||
node (node_a),
|
||||
node_w (node_a.shared ()),
|
||||
request (request_a),
|
||||
backoff (backoff_a),
|
||||
strand (node_a.io_ctx.get_executor ()),
|
||||
need_resolve (request_a.peers),
|
||||
elapsed (nano::timer_state::started, "distributed work generation timer")
|
||||
{
|
||||
debug_assert (!finished);
|
||||
debug_assert (status == work_generation_status::ongoing);
|
||||
|
@ -82,7 +82,7 @@ void nano::distributed_work::start ()
|
|||
else
|
||||
{
|
||||
auto this_l (shared_from_this ());
|
||||
node.network.resolver.async_resolve (boost::asio::ip::udp::resolver::query (peer.first, std::to_string (peer.second)), [peer, this_l, &extra = resolved_extra](boost::system::error_code const & ec, boost::asio::ip::udp::resolver::iterator i_a) {
|
||||
node.network.resolver.async_resolve (boost::asio::ip::udp::resolver::query (peer.first, std::to_string (peer.second)), [peer, this_l, &extra = resolved_extra] (boost::system::error_code const & ec, boost::asio::ip::udp::resolver::iterator i_a) {
|
||||
if (!ec)
|
||||
{
|
||||
this_l->do_request (nano::tcp_endpoint (i_a->endpoint ().address (), i_a->endpoint ().port ()));
|
||||
|
@ -107,7 +107,7 @@ void nano::distributed_work::start_local ()
|
|||
{
|
||||
auto this_l (shared_from_this ());
|
||||
local_generation_started = true;
|
||||
node.work.generate (request.version, request.root, request.difficulty, [this_l](boost::optional<uint64_t> const & work_a) {
|
||||
node.work.generate (request.version, request.root, request.difficulty, [this_l] (boost::optional<uint64_t> const & work_a) {
|
||||
if (work_a.is_initialized ())
|
||||
{
|
||||
this_l->set_once (*work_a);
|
||||
|
@ -134,7 +134,7 @@ void nano::distributed_work::do_request (nano::tcp_endpoint const & endpoint_a)
|
|||
}
|
||||
connection->socket.async_connect (connection->endpoint,
|
||||
boost::asio::bind_executor (strand,
|
||||
[this_l, connection](boost::system::error_code const & ec) {
|
||||
[this_l, connection] (boost::system::error_code const & ec) {
|
||||
if (!ec && !this_l->stopped)
|
||||
{
|
||||
std::string request_string;
|
||||
|
@ -154,11 +154,11 @@ void nano::distributed_work::do_request (nano::tcp_endpoint const & endpoint_a)
|
|||
auto peer_request (connection->get_prepared_json_request (request_string));
|
||||
boost::beast::http::async_write (connection->socket, *peer_request,
|
||||
boost::asio::bind_executor (this_l->strand,
|
||||
[this_l, connection, peer_request](boost::system::error_code const & ec, size_t size_a) {
|
||||
[this_l, connection, peer_request] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec && !this_l->stopped)
|
||||
{
|
||||
boost::beast::http::async_read (connection->socket, connection->buffer, connection->response,
|
||||
boost::asio::bind_executor (this_l->strand, [this_l, connection](boost::system::error_code const & ec, size_t size_a) {
|
||||
boost::asio::bind_executor (this_l->strand, [this_l, connection] (boost::system::error_code const & ec, size_t size_a) {
|
||||
if (!ec && !this_l->stopped)
|
||||
{
|
||||
if (connection->response.result () == boost::beast::http::status::ok)
|
||||
|
@ -202,7 +202,7 @@ void nano::distributed_work::do_cancel (nano::tcp_endpoint const & endpoint_a)
|
|||
auto cancelling_l (std::make_shared<peer_request> (node.io_ctx, endpoint_a));
|
||||
cancelling_l->socket.async_connect (cancelling_l->endpoint,
|
||||
boost::asio::bind_executor (strand,
|
||||
[this_l, cancelling_l](boost::system::error_code const & ec) {
|
||||
[this_l, cancelling_l] (boost::system::error_code const & ec) {
|
||||
if (!ec)
|
||||
{
|
||||
std::string request_string;
|
||||
|
@ -217,7 +217,7 @@ void nano::distributed_work::do_cancel (nano::tcp_endpoint const & endpoint_a)
|
|||
auto peer_cancel (cancelling_l->get_prepared_json_request (request_string));
|
||||
boost::beast::http::async_write (cancelling_l->socket, *peer_cancel,
|
||||
boost::asio::bind_executor (this_l->strand,
|
||||
[this_l, peer_cancel, cancelling_l](boost::system::error_code const & ec, size_t bytes_transferred) {
|
||||
[this_l, peer_cancel, cancelling_l] (boost::system::error_code const & ec, size_t bytes_transferred) {
|
||||
if (ec && ec != boost::system::errc::operation_canceled)
|
||||
{
|
||||
this_l->node.logger.try_log (boost::str (boost::format ("Unable to send work_cancel to work_peer %1% %2%: %3% (%4%)") % cancelling_l->endpoint.address () % cancelling_l->endpoint.port () % ec.message () % ec.value ()));
|
||||
|
|
|
@ -33,7 +33,7 @@ struct work_request final
|
|||
nano::root root;
|
||||
uint64_t difficulty;
|
||||
boost::optional<nano::account> const account;
|
||||
std::function<void(boost::optional<uint64_t>)> callback;
|
||||
std::function<void (boost::optional<uint64_t>)> callback;
|
||||
std::vector<std::pair<std::string, uint16_t>> const peers;
|
||||
};
|
||||
|
||||
|
@ -55,8 +55,8 @@ class distributed_work final : public std::enable_shared_from_this<nano::distrib
|
|||
{
|
||||
public:
|
||||
peer_request (boost::asio::io_context & io_ctx_a, nano::tcp_endpoint const & endpoint_a) :
|
||||
endpoint (endpoint_a),
|
||||
socket (io_ctx_a)
|
||||
endpoint (endpoint_a),
|
||||
socket (io_ctx_a)
|
||||
{
|
||||
}
|
||||
std::shared_ptr<request_type> get_prepared_json_request (std::string const &) const;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <nano/node/node.hpp>
|
||||
|
||||
nano::distributed_work_factory::distributed_work_factory (nano::node & node_a) :
|
||||
node (node_a)
|
||||
node (node_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ nano::distributed_work_factory::~distributed_work_factory ()
|
|||
stop ();
|
||||
}
|
||||
|
||||
bool nano::distributed_work_factory::make (nano::work_version const version_a, nano::root const & root_a, std::vector<std::pair<std::string, uint16_t>> const & peers_a, uint64_t difficulty_a, std::function<void(boost::optional<uint64_t>)> const & callback_a, boost::optional<nano::account> const & account_a)
|
||||
bool nano::distributed_work_factory::make (nano::work_version const version_a, nano::root const & root_a, std::vector<std::pair<std::string, uint16_t>> const & peers_a, uint64_t difficulty_a, std::function<void (boost::optional<uint64_t>)> const & callback_a, boost::optional<nano::account> const & account_a)
|
||||
{
|
||||
return make (std::chrono::seconds (1), nano::work_request{ version_a, root_a, difficulty_a, account_a, callback_a, peers_a });
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ void nano::distributed_work_factory::cancel (nano::root const & root_a)
|
|||
{
|
||||
nano::lock_guard<nano::mutex> guard_l (mutex);
|
||||
auto root_items_l = items.equal_range (root_a);
|
||||
std::for_each (root_items_l.first, root_items_l.second, [](auto item_l) {
|
||||
std::for_each (root_items_l.first, root_items_l.second, [] (auto item_l) {
|
||||
if (auto distributed_l = item_l.second.lock ())
|
||||
{
|
||||
// Send work_cancel to work peers and stop local work generation
|
||||
|
@ -55,7 +55,7 @@ void nano::distributed_work_factory::cleanup_finished ()
|
|||
{
|
||||
nano::lock_guard<nano::mutex> guard (mutex);
|
||||
// std::erase_if in c++20
|
||||
auto erase_if = [](decltype (items) & container, auto pred) {
|
||||
auto erase_if = [] (decltype (items) & container, auto pred) {
|
||||
for (auto it = container.begin (), end = container.end (); it != end;)
|
||||
{
|
||||
if (pred (*it))
|
||||
|
@ -68,7 +68,7 @@ void nano::distributed_work_factory::cleanup_finished ()
|
|||
}
|
||||
}
|
||||
};
|
||||
erase_if (items, [](decltype (items)::value_type item) { return item.second.expired (); });
|
||||
erase_if (items, [] (decltype (items)::value_type item) { return item.second.expired (); });
|
||||
}
|
||||
|
||||
void nano::distributed_work_factory::stop ()
|
||||
|
|
|
@ -21,7 +21,7 @@ class distributed_work_factory final
|
|||
public:
|
||||
distributed_work_factory (nano::node &);
|
||||
~distributed_work_factory ();
|
||||
bool make (nano::work_version const, nano::root const &, std::vector<std::pair<std::string, uint16_t>> const &, uint64_t, std::function<void(boost::optional<uint64_t>)> const &, boost::optional<nano::account> const & = boost::none);
|
||||
bool make (nano::work_version const, nano::root const &, std::vector<std::pair<std::string, uint16_t>> const &, uint64_t, std::function<void (boost::optional<uint64_t>)> const &, boost::optional<nano::account> const & = boost::none);
|
||||
bool make (std::chrono::seconds const &, nano::work_request const &);
|
||||
void cancel (nano::root const &);
|
||||
void cleanup_finished ();
|
||||
|
|
|
@ -18,16 +18,16 @@ nano::election_vote_result::election_vote_result (bool replay_a, bool processed_
|
|||
processed = processed_a;
|
||||
}
|
||||
|
||||
nano::election::election (nano::node & node_a, std::shared_ptr<nano::block> const & block_a, std::function<void(std::shared_ptr<nano::block> const &)> const & confirmation_action_a, std::function<void(nano::account const &)> const & live_vote_action_a, bool prioritized_a, nano::election_behavior election_behavior_a) :
|
||||
confirmation_action (confirmation_action_a),
|
||||
live_vote_action (live_vote_action_a),
|
||||
prioritized_m (prioritized_a),
|
||||
behavior (election_behavior_a),
|
||||
node (node_a),
|
||||
status ({ block_a, 0, std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ()), std::chrono::duration_values<std::chrono::milliseconds>::zero (), 0, 1, 0, nano::election_status_type::ongoing }),
|
||||
height (block_a->sideband ().height),
|
||||
root (block_a->root ()),
|
||||
qualified_root (block_a->qualified_root ())
|
||||
nano::election::election (nano::node & node_a, std::shared_ptr<nano::block> const & block_a, std::function<void (std::shared_ptr<nano::block> const &)> const & confirmation_action_a, std::function<void (nano::account const &)> const & live_vote_action_a, bool prioritized_a, nano::election_behavior election_behavior_a) :
|
||||
confirmation_action (confirmation_action_a),
|
||||
live_vote_action (live_vote_action_a),
|
||||
prioritized_m (prioritized_a),
|
||||
behavior (election_behavior_a),
|
||||
node (node_a),
|
||||
status ({ block_a, 0, std::chrono::duration_cast<std::chrono::milliseconds> (std::chrono::system_clock::now ().time_since_epoch ()), std::chrono::duration_values<std::chrono::milliseconds>::zero (), 0, 1, 0, nano::election_status_type::ongoing }),
|
||||
height (block_a->sideband ().height),
|
||||
root (block_a->root ()),
|
||||
qualified_root (block_a->qualified_root ())
|
||||
{
|
||||
last_votes.emplace (node.network_params.random.not_an_account, nano::vote_info{ std::chrono::steady_clock::now (), 0, block_a->hash () });
|
||||
last_blocks.emplace (block_a->hash (), block_a);
|
||||
|
@ -52,7 +52,7 @@ void nano::election::confirm_once (nano::unique_lock<nano::mutex> & lock_a, nano
|
|||
lock_a.unlock ();
|
||||
node.active.add_recently_confirmed (status_l.winner->qualified_root (), status_l.winner->hash ());
|
||||
node.process_confirmed (status_l);
|
||||
node.background ([node_l = node.shared (), status_l, confirmation_action_l = confirmation_action]() {
|
||||
node.background ([node_l = node.shared (), status_l, confirmation_action_l = confirmation_action] () {
|
||||
if (confirmation_action_l)
|
||||
{
|
||||
confirmation_action_l (status_l.winner);
|
||||
|
@ -551,7 +551,7 @@ bool nano::election::replace_by_weight (nano::unique_lock<nano::mutex> & lock_a,
|
|||
std::copy (last_tally.begin (), last_tally.end (), std::back_inserter (sorted));
|
||||
lock_a.unlock ();
|
||||
// Sort in ascending order
|
||||
std::sort (sorted.begin (), sorted.end (), [](auto const & left, auto const & right) { return left.second < right.second; });
|
||||
std::sort (sorted.begin (), sorted.end (), [] (auto const & left, auto const & right) { return left.second < right.second; });
|
||||
// Replace if lowest tally is below inactive cache new block weight
|
||||
auto inactive_existing (node.active.find_inactive_votes_cache (hash_a));
|
||||
auto inactive_tally (inactive_existing.status.tally);
|
||||
|
@ -560,7 +560,7 @@ bool nano::election::replace_by_weight (nano::unique_lock<nano::mutex> & lock_a,
|
|||
// If count of tally items is less than 10, remove any block without tally
|
||||
for (auto const & [hash, block] : blocks ())
|
||||
{
|
||||
if (std::find_if (sorted.begin (), sorted.end (), [& hash = hash](auto const & item_a) { return item_a.first == hash; }) == sorted.end () && hash != winner_hash)
|
||||
if (std::find_if (sorted.begin (), sorted.end (), [&hash = hash] (auto const & item_a) { return item_a.first == hash; }) == sorted.end () && hash != winner_hash)
|
||||
{
|
||||
replaced_block = hash;
|
||||
break;
|
||||
|
@ -630,6 +630,6 @@ std::vector<nano::vote_with_weight_info> nano::election::votes_with_weight () co
|
|||
}
|
||||
}
|
||||
result.reserve (sorted_votes.size ());
|
||||
std::transform (sorted_votes.begin (), sorted_votes.end (), std::back_inserter (result), [](auto const & entry) { return entry.second; });
|
||||
std::transform (sorted_votes.begin (), sorted_votes.end (), std::back_inserter (result), [] (auto const & entry) { return entry.second; });
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -62,8 +62,8 @@ class election final : public std::enable_shared_from_this<nano::election>
|
|||
{
|
||||
// Minimum time between broadcasts of the current winner of an election, as a backup to requesting confirmations
|
||||
std::chrono::milliseconds base_latency () const;
|
||||
std::function<void(std::shared_ptr<nano::block> const &)> confirmation_action;
|
||||
std::function<void(nano::account const &)> live_vote_action;
|
||||
std::function<void (std::shared_ptr<nano::block> const &)> confirmation_action;
|
||||
std::function<void (nano::account const &)> live_vote_action;
|
||||
|
||||
private: // State management
|
||||
enum class state_t
|
||||
|
@ -111,7 +111,7 @@ public: // Status
|
|||
nano::election_status status;
|
||||
|
||||
public: // Interface
|
||||
election (nano::node &, std::shared_ptr<nano::block> const &, std::function<void(std::shared_ptr<nano::block> const &)> const &, std::function<void(nano::account const &)> const &, bool, nano::election_behavior);
|
||||
election (nano::node &, std::shared_ptr<nano::block> const &, std::function<void (std::shared_ptr<nano::block> const &)> const &, std::function<void (nano::account const &)> const &, bool, nano::election_behavior);
|
||||
std::shared_ptr<nano::block> find (nano::block_hash const &) const;
|
||||
nano::election_vote_result vote (nano::account const &, uint64_t, nano::block_hash const &);
|
||||
bool publish (std::shared_ptr<nano::block> const & block_a);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include <boost/format.hpp>
|
||||
|
||||
nano::gap_cache::gap_cache (nano::node & node_a) :
|
||||
node (node_a)
|
||||
node (node_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ void nano::gap_cache::add (nano::block_hash const & hash_a, std::chrono::steady_
|
|||
auto existing (blocks.get<tag_hash> ().find (hash_a));
|
||||
if (existing != blocks.get<tag_hash> ().end ())
|
||||
{
|
||||
blocks.get<tag_hash> ().modify (existing, [time_point_a](nano::gap_information & info) {
|
||||
blocks.get<tag_hash> ().modify (existing, [time_point_a] (nano::gap_information & info) {
|
||||
info.arrival = time_point_a;
|
||||
});
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ void nano::gap_cache::vote (std::shared_ptr<nano::vote> const & vote_a)
|
|||
if (existing != gap_blocks_by_hash.end () && !existing->bootstrap_started)
|
||||
{
|
||||
auto is_new (false);
|
||||
gap_blocks_by_hash.modify (existing, [&is_new, &vote_a](nano::gap_information & info) {
|
||||
gap_blocks_by_hash.modify (existing, [&is_new, &vote_a] (nano::gap_information & info) {
|
||||
auto it = std::find (info.voters.begin (), info.voters.end (), vote_a->account);
|
||||
is_new = (it == info.voters.end ());
|
||||
if (is_new)
|
||||
|
@ -58,7 +58,7 @@ void nano::gap_cache::vote (std::shared_ptr<nano::vote> const & vote_a)
|
|||
{
|
||||
if (bootstrap_check (existing->voters, hash))
|
||||
{
|
||||
gap_blocks_by_hash.modify (existing, [](nano::gap_information & info) {
|
||||
gap_blocks_by_hash.modify (existing, [] (nano::gap_information & info) {
|
||||
info.bootstrap_started = true;
|
||||
});
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ bool nano::gap_cache::bootstrap_check (std::vector<nano::account> const & voters
|
|||
void nano::gap_cache::bootstrap_start (nano::block_hash const & hash_a)
|
||||
{
|
||||
auto node_l (node.shared ());
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + node.network_params.bootstrap.gap_cache_bootstrap_start_interval, [node_l, hash_a]() {
|
||||
node.workers.add_timed_task (std::chrono::steady_clock::now () + node.network_params.bootstrap.gap_cache_bootstrap_start_interval, [node_l, hash_a] () {
|
||||
if (!node_l->ledger.block_or_pruned_exists (hash_a))
|
||||
{
|
||||
if (!node_l->bootstrap_initiator.in_progress ())
|
||||
|
|
|
@ -40,9 +40,9 @@ auto get_message (nanoapi::Envelope const & envelope)
|
|||
* Mapping from message type to handler function.
|
||||
* @note This must be updated whenever a new message type is added to the Flatbuffers IDL.
|
||||
*/
|
||||
auto nano::ipc::action_handler::handler_map () -> std::unordered_map<nanoapi::Message, std::function<void(nano::ipc::action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash>
|
||||
auto nano::ipc::action_handler::handler_map () -> std::unordered_map<nanoapi::Message, std::function<void (nano::ipc::action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash>
|
||||
{
|
||||
static std::unordered_map<nanoapi::Message, std::function<void(nano::ipc::action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash> handlers;
|
||||
static std::unordered_map<nanoapi::Message, std::function<void (nano::ipc::action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash> handlers;
|
||||
if (handlers.empty ())
|
||||
{
|
||||
handlers.emplace (nanoapi::Message::Message_IsAlive, &nano::ipc::action_handler::on_is_alive);
|
||||
|
@ -56,10 +56,10 @@ auto nano::ipc::action_handler::handler_map () -> std::unordered_map<nanoapi::Me
|
|||
}
|
||||
|
||||
nano::ipc::action_handler::action_handler (nano::node & node_a, nano::ipc::ipc_server & server_a, std::weak_ptr<nano::ipc::subscriber> const & subscriber_a, std::shared_ptr<flatbuffers::FlatBufferBuilder> const & builder_a) :
|
||||
flatbuffer_producer (builder_a),
|
||||
node (node_a),
|
||||
ipc_server (server_a),
|
||||
subscriber (subscriber_a)
|
||||
flatbuffer_producer (builder_a),
|
||||
node (node_a),
|
||||
ipc_server (server_a),
|
||||
subscriber (subscriber_a)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace ipc
|
|||
void on_topic_service_stop (nanoapi::Envelope const & envelope);
|
||||
|
||||
/** Returns a mapping from api message types to handler functions */
|
||||
static auto handler_map () -> std::unordered_map<nanoapi::Message, std::function<void(action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash>;
|
||||
static auto handler_map () -> std::unordered_map<nanoapi::Message, std::function<void (action_handler *, nanoapi::Envelope const &)>, nano::ipc::enum_hash>;
|
||||
|
||||
private:
|
||||
bool has_access (nanoapi::Envelope const & envelope_a, nano::ipc::access_permission permission_a) const noexcept;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue