Renaming block::link to block::link_field. Usages that converted this number to an account number are replaced with calls to block::destination (). Usages that converted this number to a block_hash are replaced with calls to block::source, and usages that check this number for being an epoch directly access the link field.

This commit is contained in:
Colin LeMahieu 2024-03-08 09:46:25 +00:00
commit 17e502d543
No known key found for this signature in database
GPG key ID: 43708520C8DFB938
17 changed files with 68 additions and 70 deletions

View file

@ -659,7 +659,7 @@ TEST (block_builder, state)
ASSERT_EQ (block->hash ().to_string (), "2D243F8F92CDD0AD94A1D456A6B15F3BE7A6FCBD98D4C5831D06D15C818CD81F");
ASSERT_FALSE (block->source_field ());
ASSERT_FALSE (block->destination_field ());
ASSERT_EQ (block->link ().value ().to_string (), "E16DD58C1EFA8B521545B0A74375AA994D9FC43828A4266D75ECF57F07A7EE86");
ASSERT_EQ (block->link_field ().value ().to_string (), "E16DD58C1EFA8B521545B0A74375AA994D9FC43828A4266D75ECF57F07A7EE86");
}
TEST (block_builder, state_missing_rep)
@ -732,7 +732,7 @@ TEST (block_builder, open)
ASSERT_EQ (block->hash ().to_string (), "991CF190094C00F0B68E2E5F75F6BEE95A2E0BD93CEAA4A6734DB9F19B728948");
ASSERT_EQ (block->source_field ().value ().to_string (), "E89208DD038FBB269987689621D52292AE9C35941A7484756ECCED92A65093BA");
ASSERT_FALSE (block->destination_field ());
ASSERT_FALSE (block->link ());
ASSERT_FALSE (block->link_field ());
}
TEST (block_builder, open_equality)
@ -771,7 +771,7 @@ TEST (block_builder, change)
ASSERT_EQ (block->hash ().to_string (), "13552AC3928E93B5C6C215F61879358E248D4A5246B8B3D1EEC5A566EDCEE077");
ASSERT_FALSE (block->source_field ());
ASSERT_FALSE (block->destination_field ());
ASSERT_FALSE (block->link ());
ASSERT_FALSE (block->link_field ());
}
TEST (block_builder, change_equality)
@ -810,7 +810,7 @@ TEST (block_builder, send)
ASSERT_EQ (block->hash ().to_string (), "4560E7B1F3735D082700CFC2852F5D1F378F7418FD24CEF1AD45AB69316F15CD");
ASSERT_FALSE (block->source_field ());
ASSERT_EQ (block->destination_field ().value ().to_account (), "nano_1gys8r4crpxhp94n4uho5cshaho81na6454qni5gu9n53gksoyy1wcd4udyb");
ASSERT_FALSE (block->link ());
ASSERT_FALSE (block->link_field ());
}
TEST (block_builder, send_equality)
@ -872,5 +872,5 @@ TEST (block_builder, receive)
ASSERT_EQ (block->hash ().to_string (), "6C004BF911D9CF2ED75CF6EC45E795122AD5D093FF5A83EDFBA43EC4A3EDC722");
ASSERT_EQ (block->source_field ().value ().to_string (), "7B2B0A29C1B235FDF9B4DEF2984BB3573BD1A52D28246396FBB3E4C5FE662135");
ASSERT_FALSE (block->destination_field ());
ASSERT_FALSE (block->link ());
ASSERT_FALSE (block->link_field ());
}

View file

@ -1001,7 +1001,7 @@ TEST (wallet, epoch_2_validation)
ASSERT_EQ (nano::epoch::epoch_2, send->sideband ().details.epoch);
ASSERT_EQ (nano::epoch::epoch_0, send->sideband ().source_epoch); // Not used for send state blocks
auto receive = wallet.receive_action (send->hash (), nano::dev::genesis_key.pub, amount, send->link ().value ().as_account (), 1);
auto receive = wallet.receive_action (send->hash (), nano::dev::genesis_key.pub, amount, send->destination (), 1);
ASSERT_NE (nullptr, receive);
if (nano::dev::network_params.work.difficulty (*receive) < node.network_params.work.base)
{
@ -1043,7 +1043,7 @@ TEST (wallet, epoch_2_receive_propagation)
auto amount = node.config.receive_minimum.number ();
auto send1 = wallet.send_action (nano::dev::genesis_key.pub, key.pub, amount, 1);
ASSERT_NE (nullptr, send1);
ASSERT_NE (nullptr, wallet.receive_action (send1->hash (), nano::dev::genesis_key.pub, amount, send1->link ().value ().as_account (), 1));
ASSERT_NE (nullptr, wallet.receive_action (send1->hash (), nano::dev::genesis_key.pub, amount, send1->destination (), 1));
// Upgrade the genesis account to epoch 2
auto epoch2 = system.upgrade_genesis_epoch (node, nano::epoch::epoch_2);
@ -1053,7 +1053,7 @@ TEST (wallet, epoch_2_receive_propagation)
auto send2 = wallet.send_action (nano::dev::genesis_key.pub, key.pub, amount, 1);
ASSERT_NE (nullptr, send2);
auto receive2 = wallet.receive_action (send2->hash (), key.pub, amount, send2->link ().value ().as_account (), 1);
auto receive2 = wallet.receive_action (send2->hash (), key.pub, amount, send2->destination (), 1);
ASSERT_NE (nullptr, receive2);
if (nano::dev::network_params.work.difficulty (*receive2) < node.network_params.work.base)
{
@ -1106,7 +1106,7 @@ TEST (wallet, epoch_2_receive_unopened)
wallet.insert_adhoc (key.prv, false);
auto receive1 = wallet.receive_action (send1->hash (), key.pub, amount, send1->link ().value ().as_account (), 1);
auto receive1 = wallet.receive_action (send1->hash (), key.pub, amount, send1->destination (), 1);
ASSERT_NE (nullptr, receive1);
if (nano::dev::network_params.work.difficulty (*receive1) < node.network_params.work.base)
{
@ -1190,7 +1190,7 @@ TEST (wallet, search_receivable)
auto receive = node.block (receive_hash);
ASSERT_NE (nullptr, receive);
ASSERT_EQ (receive->sideband ().height, 3);
ASSERT_EQ (send->hash (), receive->link ().value ().as_block_hash ());
ASSERT_EQ (send->hash (), receive->source ());
}
TEST (wallet, receive_pruned)
@ -1228,7 +1228,7 @@ TEST (wallet, receive_pruned)
wallet2.insert_adhoc (key.prv, false);
auto open1 = wallet2.receive_action (send1->hash (), key.pub, amount, send1->link ().value ().as_account (), 1);
auto open1 = wallet2.receive_action (send1->hash (), key.pub, amount, send1->destination (), 1);
ASSERT_NE (nullptr, open1);
ASSERT_EQ (amount, node2.ledger.balance (node2.store.tx_begin_read (), open1->hash ()));
ASSERT_TIMELY_EQ (5s, node2.ledger.cache.cemented_count, 4);

View file

@ -254,6 +254,6 @@ TEST (wallets, search_receivable)
auto receive = node.block (receive_hash);
ASSERT_NE (nullptr, receive);
ASSERT_EQ (receive->sideband ().height, 3);
ASSERT_EQ (send->hash (), receive->link ().value ().as_block_hash ());
ASSERT_EQ (send->hash (), receive->source ());
}
}

View file

@ -152,7 +152,7 @@ bool nano::block::is_change () const noexcept
case nano::block_type::change:
return true;
case nano::block_type::state:
if (link ().value ().is_zero ())
if (link_field ().value ().is_zero ())
{
return true;
}
@ -224,7 +224,7 @@ std::optional<nano::account> nano::block::destination_field () const
return std::nullopt;
}
std::optional<nano::link> nano::block::link () const
std::optional<nano::link> nano::block::link_field () const
{
return std::nullopt;
}
@ -272,7 +272,7 @@ nano::account nano::block::destination () const noexcept
return destination_field ().value ();
case nano::block_type::state:
release_assert (sideband ().details.is_send);
return link ().value ().as_account ();
return link_field ().value ().as_account ();
default:
release_assert (false);
}
@ -288,7 +288,7 @@ nano::block_hash nano::block::source () const noexcept
return source_field ().value ();
case nano::block_type::state:
release_assert (sideband ().details.is_receive);
return link ().value ().as_block_hash ();
return link_field ().value ().as_block_hash ();
default:
release_assert (false);
}
@ -1470,7 +1470,7 @@ nano::root const & nano::state_block::root () const
}
}
std::optional<nano::link> nano::state_block::link () const
std::optional<nano::link> nano::state_block::link_field () const
{
return hashables.link;
}

View file

@ -73,7 +73,7 @@ public: // Direct access to the block fields or nullopt if the block type does n
// Destination account for send blocks
virtual std::optional<nano::account> destination_field () const;
// Link field for state blocks
virtual std::optional<nano::link> link () const;
virtual std::optional<nano::link> link_field () const;
// Returns the source block hash for open/receive/state blocks that are receives
nano::block_hash source () const noexcept;
// Source block for open/receive blocks
@ -369,7 +369,7 @@ public:
public: // State block fields
std::optional<nano::account> account_field () const override;
std::optional<nano::amount> balance_field () const override;
std::optional<nano::link> link () const override;
std::optional<nano::link> link_field () const override;
public: // Logging
void operator() (nano::object_stream &) const override;

View file

@ -1501,7 +1501,7 @@ int main (int argc, char * const * argv)
{
if ((state_block.hashables.balance == prev_balance && !error_or_pruned) || (node->ledger.pruning && error_or_pruned && block->sideband ().details.is_epoch))
{
invalid = validate_message (node->ledger.epoch_signer (block->link ().value ()), hash, block->block_signature ());
invalid = validate_message (node->ledger.epoch_signer (block->link_field ().value ()), hash, block->block_signature ());
}
}
}
@ -1534,7 +1534,7 @@ int main (int argc, char * const * argv)
// State change
block_details_error = sideband.details.is_send || sideband.details.is_receive || sideband.details.is_epoch;
}
else if (block->balance () == prev_balance.value () && node->ledger.is_epoch_link (block->link ().value ()))
else if (block->balance () == prev_balance.value () && node->ledger.is_epoch_link (block->link_field ().value ()))
{
// State epoch
block_details_error = !sideband.details.is_epoch || sideband.details.is_send || sideband.details.is_receive;
@ -1543,7 +1543,7 @@ int main (int argc, char * const * argv)
{
// State receive
block_details_error = !sideband.details.is_receive || sideband.details.is_send || sideband.details.is_epoch;
block_details_error |= !node->ledger.block_or_pruned_exists (transaction, block->link ().value ().as_block_hash ());
block_details_error |= !node->ledger.block_or_pruned_exists (transaction, block->source ());
}
}
}
@ -1809,7 +1809,7 @@ int main (int argc, char * const * argv)
std::cout << boost::str (boost::format ("%1% blocks retrieved") % count) << std::endl;
}
node.node->block_processor.add (block);
if (block->type () == nano::block_type::state && block->previous ().is_zero () && source_node->ledger.is_epoch_link (block->link ().value ()))
if (block->type () == nano::block_type::state && block->previous ().is_zero () && source_node->ledger.is_epoch_link (block->link_field ().value ()))
{
// Epoch open blocks can be rejected without processed pending blocks to account, push it later again
epoch_open_blocks.push_back (block);

View file

@ -356,8 +356,8 @@ nano::block_status nano::block_processor::process_one (store::write_transaction
}
case nano::block_status::gap_source:
{
release_assert (block->source_field () || block->link ());
node.unchecked.put (block->source_field ().value_or (block->link ().value_or (0).as_block_hash ()), block);
release_assert (block->source_field () || block->link_field ());
node.unchecked.put (block->source_field ().value_or (block->link_field ().value_or (0).as_block_hash ()), block);
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::gap_source);
break;
}

View file

@ -151,7 +151,7 @@ void nano::bootstrap_ascending::service::inspect (store::transaction const & tx,
case nano::block_status::gap_source:
{
const auto account = block.previous ().is_zero () ? block.account_field ().value () : ledger.account (tx, block.previous ()).value ();
const auto source = block.source_field ().value_or (block.link ().value_or (0).as_block_hash ());
const auto source = block.source_field ().value_or (block.link_field ().value_or (0).as_block_hash ());
// Mark account as blocked because it is missing the source block
accounts.block (account, source);

View file

@ -253,14 +253,13 @@ bool nano::confirmation_height_bounded::iterate (store::read_transaction const &
// Once a receive is cemented, we can cement all blocks above it until the next receive, so store those details for later.
++num_blocks;
auto block = ledger.block (transaction_a, hash);
auto source = block->source_field ().value_or (block->link ().value_or (0).as_block_hash ());
if (!source.is_zero () && !ledger.is_epoch_link (source) && ledger.block_exists (transaction_a, source))
if (block->is_receive () && ledger.block_exists (transaction_a, block->source ()))
{
hit_receive = true;
reached_target = true;
auto const & sideband (block->sideband ());
auto next = !sideband.successor.is_zero () && sideband.successor != top_level_hash_a ? boost::optional<nano::block_hash> (sideband.successor) : boost::none;
receive_source_pairs_a.push_back ({ receive_chain_details{ account_a, sideband.height, hash, top_level_hash_a, next, bottom_height_a, bottom_hash_a }, source });
receive_source_pairs_a.push_back ({ receive_chain_details{ account_a, sideband.height, hash, top_level_hash_a, next, bottom_height_a, bottom_hash_a }, block->source () });
// Store a checkpoint every max_items so that we can always traverse a long number of accounts to genesis
if (receive_source_pairs_a.size () % max_items == 0)
{

View file

@ -212,8 +212,7 @@ void nano::confirmation_height_unbounded::collect_unconfirmed_receive_and_source
if (block)
{
auto source = block->source_field ().value_or (block->link ().value_or (0).as_block_hash ());
if (!source.is_zero () && !ledger.is_epoch_link (source) && ledger.block_exists (transaction_a, source))
if (block->is_receive () && ledger.block_exists (transaction_a, block->source ()))
{
if (!hit_receive && !block_callback_data_a.empty ())
{
@ -228,7 +227,7 @@ void nano::confirmation_height_unbounded::collect_unconfirmed_receive_and_source
hit_receive = true;
auto block_height = confirmation_height_a + num_to_confirm;
receive_source_pairs_a.emplace_back (std::make_shared<conf_height_details> (account_a, hash, block_height, 1, std::vector<nano::block_hash>{ hash }), source);
receive_source_pairs_a.emplace_back (std::make_shared<conf_height_details> (account_a, hash, block_height, 1, std::vector<nano::block_hash>{ hash }), block->source ());
}
else if (is_original_block)
{

View file

@ -11,8 +11,8 @@ std::unique_ptr<nanoapi::BlockStateT> nano::ipc::flatbuffers_builder::from (nano
block->previous = block_a.previous ().to_string ();
block->representative = block_a.representative ().to_account ();
block->balance = block_a.balance ().to_string_dec ();
block->link = block_a.link ().value ().to_string ();
block->link_as_account = block_a.link ().value ().to_account ();
block->link = block_a.link_field ().value ().to_string ();
block->link_as_account = block_a.link_field ().value ().to_account ();
block_a.signature.encode_hex (block->signature);
block->work = nano::to_string_hex (block_a.work);

View file

@ -411,8 +411,8 @@ uint64_t nano::json_handler::difficulty_ledger (nano::block const & block_a)
{
details.epoch = block_previous->sideband ().details.epoch;
}
auto link = block_a.link ();
if (link && !details.is_send)
auto link = block_a.link_field ();
if (link && !link.value ().is_zero () && !details.is_send)
{
auto block_link = node.ledger.block (transaction, link.value ().as_block_hash ());
auto account = block_a.account_field ().value (); // Link is non-zero therefore it's a state block and has an account field;
@ -1224,7 +1224,7 @@ void nano::json_handler::block_confirm ()
if (auto state = dynamic_cast<nano::state_block *> (block_l.get ()))
{
is_state_send = state->is_send ();
is_state_epoch = amount.value () == 0 && node.ledger.is_epoch_link (state->link ().value ());
is_state_epoch = amount.value () == 0 && node.ledger.is_epoch_link (state->link_field ().value ());
}
}
node.observers.blocks.notify (status, {}, account, amount ? amount.value () : 0, is_state_send, is_state_epoch);
@ -2522,7 +2522,7 @@ public:
if (raw && accounts_filter.empty ())
{
tree.put ("subtype", "epoch");
tree.put ("account", handler.node.ledger.epoch_signer (block_a.link ().value ()).to_account ());
tree.put ("account", handler.node.ledger.epoch_signer (block_a.link_field ().value ()).to_account ());
}
}
else
@ -3641,7 +3641,7 @@ void nano::json_handler::republish ()
block = node.ledger.block (transaction, hash);
if (sources != 0) // Republish source chain
{
nano::block_hash source = block->source_field ().value_or (block->link ().value_or (0).as_block_hash ());
nano::block_hash source = block->source_field ().value_or (block->link_field ().value_or (0).as_block_hash ());
auto block_a = node.ledger.block (transaction, source);
std::vector<nano::block_hash> hashes;
while (block_a != nullptr && hashes.size () < sources)
@ -3679,7 +3679,7 @@ void nano::json_handler::republish ()
while (block_d != nullptr && hash != source)
{
hashes.push_back (previous);
source = block_d->source_field ().value_or (block_d->is_send () ? 0 : block_d->link ().value_or (0).as_block_hash ());
source = block_d->source_field ().value_or (block_d->is_send () ? 0 : block_d->link_field ().value_or (0).as_block_hash ());
previous = block_d->previous ();
block_d = node.ledger.block (transaction, previous);
}

View file

@ -266,7 +266,7 @@ nano::node::node (boost::asio::io_context & io_ctx_a, std::filesystem::path cons
}
else if (is_state_epoch_a)
{
debug_assert (amount_a == 0 && node_l->ledger.is_epoch_link (block_a->link ().value ()));
debug_assert (amount_a == 0 && node_l->ledger.is_epoch_link (block_a->link_field ().value ()));
event.add ("subtype", "epoch");
}
else
@ -1252,7 +1252,7 @@ void nano::node::process_confirmed_data (store::transaction const & transaction_
{
is_state_send_a = true;
}
if (amount_a == 0 && network_params.ledger.epochs.is_epoch_link (state->link ().value ()))
if (amount_a == 0 && network_params.ledger.epochs.is_epoch_link (state->link_field ().value ()))
{
is_state_epoch_a = true;
}

View file

@ -1018,7 +1018,7 @@ nano::websocket_server::websocket_server (nano::websocket::config & config_a, na
}
else if (is_state_epoch_a)
{
debug_assert (amount_a == 0 && ledger.is_epoch_link (block_a->link ().value ()));
debug_assert (amount_a == 0 && ledger.is_epoch_link (block_a->link_field ().value ()));
subtype = "epoch";
}
else

View file

@ -21,7 +21,7 @@ TEST (rpc, receivable)
auto const rpc_ctx = add_rpc (system, node);
boost::property_tree::ptree request;
request.put ("action", "receivable");
request.put ("account", block1->link ().value ().to_account ());
request.put ("account", block1->destination ().to_account ());
auto response = wait_response (system, rpc_ctx, request);
auto & blocks_node = response.get_child ("blocks");
ASSERT_EQ (1, blocks_node.size ());
@ -39,7 +39,7 @@ TEST (rpc, receivable_sorting)
auto const rpc_ctx = add_rpc (system, node);
boost::property_tree::ptree request;
request.put ("action", "receivable");
request.put ("account", block1->link ().value ().to_account ());
request.put ("account", block1->destination ().to_account ());
request.put ("sorting", "true"); // Sorting test
auto response = wait_response (system, rpc_ctx, request);
auto & blocks_node = response.get_child ("blocks");
@ -60,7 +60,7 @@ TEST (rpc, receivable_threshold_sufficient)
auto const rpc_ctx = add_rpc (system, node);
boost::property_tree::ptree request;
request.put ("action", "receivable");
request.put ("account", block1->link ().value ().to_account ());
request.put ("account", block1->destination ().to_account ());
request.put ("threshold", "1"); // Threshold test
auto response = wait_response (system, rpc_ctx, request);
auto & blocks_node = response.get_child ("blocks");
@ -91,7 +91,7 @@ TEST (rpc, receivable_threshold_insufficient)
auto const rpc_ctx = add_rpc (system, node);
boost::property_tree::ptree request;
request.put ("action", "receivable");
request.put ("account", block1->link ().value ().to_account ());
request.put ("account", block1->destination ().to_account ());
request.put ("threshold", "2"); // Chains are set up with 1 raw transfers therefore all blocks are less than 2 raw.
auto response = wait_response (system, rpc_ctx, request, 10s);
auto & blocks_node = response.get_child ("blocks");
@ -108,7 +108,7 @@ TEST (rpc, receivable_source_min_version)
auto const rpc_ctx = add_rpc (system, node);
boost::property_tree::ptree request;
request.put ("action", "receivable");
request.put ("account", block1->link ().value ().to_account ());
request.put ("account", block1->destination ().to_account ());
request.put ("source", "true");
request.put ("min_version", "true");
auto response (wait_response (system, rpc_ctx, request));
@ -140,7 +140,7 @@ TEST (rpc, receivable_unconfirmed)
auto const rpc_ctx = add_rpc (system, node);
boost::property_tree::ptree request;
request.put ("action", "receivable");
request.put ("account", block1->link ().value ().to_account ());
request.put ("account", block1->destination ().to_account ());
ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 0));
request.put ("include_only_confirmed", "true");
ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 0));
@ -410,14 +410,14 @@ TEST (rpc, accounts_receivable_blocks)
request.put ("action", "accounts_receivable");
boost::property_tree::ptree entry;
boost::property_tree::ptree peers_l;
entry.put ("", block1->link ().value ().to_account ());
entry.put ("", block1->destination ().to_account ());
peers_l.push_back (std::make_pair ("", entry));
request.add_child ("accounts", peers_l);
auto response = wait_response (system, rpc_ctx, request);
for (auto & blocks : response.get_child ("blocks"))
{
std::string account_text{ blocks.first };
ASSERT_EQ (block1->link ().value ().to_account (), account_text);
ASSERT_EQ (block1->destination ().to_account (), account_text);
nano::block_hash hash1{ blocks.second.begin ()->second.get<std::string> ("") };
ASSERT_EQ (block1->hash (), hash1);
}
@ -436,7 +436,7 @@ TEST (rpc, accounts_receivable_sorting)
request.put ("action", "accounts_receivable");
boost::property_tree::ptree entry;
boost::property_tree::ptree peers_l;
entry.put ("", block1->link ().value ().to_account ());
entry.put ("", block1->destination ().to_account ());
peers_l.push_back (std::make_pair ("", entry));
request.add_child ("accounts", peers_l);
request.put ("sorting", "true"); // Sorting test
@ -444,7 +444,7 @@ TEST (rpc, accounts_receivable_sorting)
for (auto & blocks : response.get_child ("blocks"))
{
std::string account_text{ blocks.first };
ASSERT_EQ (block1->link ().value ().to_account (), account_text);
ASSERT_EQ (block1->destination ().to_account (), account_text);
nano::block_hash hash1{ blocks.second.begin ()->first };
ASSERT_EQ (block1->hash (), hash1);
std::string amount{ blocks.second.begin ()->second.get<std::string> ("") };
@ -465,7 +465,7 @@ TEST (rpc, accounts_receivable_threshold)
request.put ("action", "accounts_receivable");
boost::property_tree::ptree entry;
boost::property_tree::ptree peers_l;
entry.put ("", block1->link ().value ().to_account ());
entry.put ("", block1->destination ().to_account ());
peers_l.push_back (std::make_pair ("", entry));
request.add_child ("accounts", peers_l);
request.put ("threshold", "1"); // Threshold test
@ -474,7 +474,7 @@ TEST (rpc, accounts_receivable_threshold)
for (auto & pending : response.get_child ("blocks"))
{
std::string account_text{ pending.first };
ASSERT_EQ (block1->link ().value ().to_account (), account_text);
ASSERT_EQ (block1->destination ().to_account (), account_text);
for (auto i (pending.second.begin ()), j (pending.second.end ()); i != j; ++i)
{
nano::block_hash hash;
@ -501,7 +501,7 @@ TEST (rpc, accounts_receivable_source)
request.put ("action", "accounts_receivable");
boost::property_tree::ptree entry;
boost::property_tree::ptree peers_l;
entry.put ("", block1->link ().value ().to_account ());
entry.put ("", block1->destination ().to_account ());
peers_l.push_back (std::make_pair ("", entry));
request.add_child ("accounts", peers_l);
request.put ("source", "true");
@ -512,7 +512,7 @@ TEST (rpc, accounts_receivable_source)
for (auto & pending : response.get_child ("blocks"))
{
std::string account_text (pending.first);
ASSERT_EQ (block1->link ().value ().to_account (), account_text);
ASSERT_EQ (block1->destination ().to_account (), account_text);
for (auto i (pending.second.begin ()), j (pending.second.end ()); i != j; ++i)
{
nano::block_hash hash;
@ -540,7 +540,7 @@ TEST (rpc, accounts_receivable_confirmed)
request.put ("action", "accounts_receivable");
boost::property_tree::ptree entry;
boost::property_tree::ptree peers_l;
entry.put ("", block1->link ().value ().to_account ());
entry.put ("", block1->destination ().to_account ());
peers_l.push_back (std::make_pair ("", entry));
request.add_child ("accounts", peers_l);

View file

@ -923,7 +923,7 @@ TEST (rpc, history)
ASSERT_NE (nullptr, change);
auto send (system.wallet (0)->send_action (nano::dev::genesis_key.pub, nano::dev::genesis_key.pub, node0->config.receive_minimum.number ()));
ASSERT_NE (nullptr, send);
auto receive (system.wallet (0)->receive_action (send->hash (), nano::dev::genesis_key.pub, node0->config.receive_minimum.number (), send->link ().value ().as_account ()));
auto receive (system.wallet (0)->receive_action (send->hash (), nano::dev::genesis_key.pub, node0->config.receive_minimum.number (), send->destination ()));
ASSERT_NE (nullptr, receive);
nano::block_builder builder;
auto usend = builder
@ -1007,7 +1007,7 @@ TEST (rpc, account_history)
ASSERT_NE (nullptr, change);
auto send (system.wallet (0)->send_action (nano::dev::genesis_key.pub, nano::dev::genesis_key.pub, node0->config.receive_minimum.number ()));
ASSERT_NE (nullptr, send);
auto receive (system.wallet (0)->receive_action (send->hash (), nano::dev::genesis_key.pub, node0->config.receive_minimum.number (), send->link ().value ().as_account ()));
auto receive (system.wallet (0)->receive_action (send->hash (), nano::dev::genesis_key.pub, node0->config.receive_minimum.number (), send->destination ()));
ASSERT_NE (nullptr, receive);
nano::block_builder builder;
auto usend = builder
@ -1110,7 +1110,7 @@ TEST (rpc, account_history)
auto account2 (system.wallet (0)->deterministic_insert ());
auto send2 (system.wallet (0)->send_action (nano::dev::genesis_key.pub, account2, node0->config.receive_minimum.number ()));
ASSERT_NE (nullptr, send2);
auto receive2 (system.wallet (0)->receive_action (send2->hash (), account2, node0->config.receive_minimum.number (), send2->link ().value ().as_account ()));
auto receive2 (system.wallet (0)->receive_action (send2->hash (), account2, node0->config.receive_minimum.number (), send2->destination ()));
// Test filter for send state blocks
ASSERT_NE (nullptr, receive2);
{
@ -1153,7 +1153,7 @@ TEST (rpc, history_count)
ASSERT_NE (nullptr, change);
auto send (system.wallet (0)->send_action (nano::dev::genesis_key.pub, nano::dev::genesis_key.pub, node->config.receive_minimum.number ()));
ASSERT_NE (nullptr, send);
auto receive (system.wallet (0)->receive_action (send->hash (), nano::dev::genesis_key.pub, node->config.receive_minimum.number (), send->link ().value ().as_account ()));
auto receive (system.wallet (0)->receive_action (send->hash (), nano::dev::genesis_key.pub, node->config.receive_minimum.number (), send->destination ()));
ASSERT_NE (nullptr, receive);
auto const rpc_ctx = add_rpc (system, node);
boost::property_tree::ptree request;
@ -4126,10 +4126,10 @@ TEST (rpc, blocks_info_receive_hash)
auto send4 = system.wallet (0)->send_action (nano::dev::genesis_key.pub, key1.pub, 4);
// do 4 receives, mix up the ordering a little
auto recv1 (system.wallet (0)->receive_action (send1->hash (), key1.pub, node->config.receive_minimum.number (), send1->link ().value ().as_account ()));
auto recv4 (system.wallet (0)->receive_action (send4->hash (), key1.pub, node->config.receive_minimum.number (), send4->link ().value ().as_account ()));
auto recv3 (system.wallet (0)->receive_action (send3->hash (), key1.pub, node->config.receive_minimum.number (), send3->link ().value ().as_account ()));
auto recv2 (system.wallet (0)->receive_action (send2->hash (), key1.pub, node->config.receive_minimum.number (), send2->link ().value ().as_account ()));
auto recv1 (system.wallet (0)->receive_action (send1->hash (), key1.pub, node->config.receive_minimum.number (), send1->destination ()));
auto recv4 (system.wallet (0)->receive_action (send4->hash (), key1.pub, node->config.receive_minimum.number (), send4->destination ()));
auto recv3 (system.wallet (0)->receive_action (send3->hash (), key1.pub, node->config.receive_minimum.number (), send3->destination ()));
auto recv2 (system.wallet (0)->receive_action (send2->hash (), key1.pub, node->config.receive_minimum.number (), send2->destination ()));
// function to check that all 4 receive blocks are cemented
auto all_blocks_cemented = [node, &key1] () -> bool {
@ -4192,7 +4192,7 @@ TEST (rpc, blocks_info_subtype)
system.wallet (0)->insert_adhoc (key.prv);
auto send (system.wallet (0)->send_action (nano::dev::genesis_key.pub, nano::dev::genesis_key.pub, nano::Gxrb_ratio));
ASSERT_NE (nullptr, send);
auto receive (system.wallet (0)->receive_action (send->hash (), key.pub, nano::Gxrb_ratio, send->link ().value ().as_account ()));
auto receive (system.wallet (0)->receive_action (send->hash (), key.pub, nano::Gxrb_ratio, send->destination ()));
ASSERT_NE (nullptr, receive);
auto change (system.wallet (0)->change_action (nano::dev::genesis_key.pub, key.pub));
ASSERT_NE (nullptr, change);
@ -5177,7 +5177,7 @@ TEST (rpc, online_reps)
auto send (system.wallet (0)->send_action (nano::dev::genesis_key.pub, new_rep, node1->config.receive_minimum.number ()));
ASSERT_NE (nullptr, send);
ASSERT_TIMELY (10s, node2->block (send->hash ()));
auto receive (system.wallet (1)->receive_action (send->hash (), new_rep, node1->config.receive_minimum.number (), send->link ().value ().as_account ()));
auto receive (system.wallet (1)->receive_action (send->hash (), new_rep, node1->config.receive_minimum.number (), send->destination ()));
ASSERT_NE (nullptr, receive);
ASSERT_TIMELY (5s, node2->block (receive->hash ()));
auto change (system.wallet (0)->change_action (nano::dev::genesis_key.pub, new_rep));
@ -5666,7 +5666,7 @@ TEST (rpc, DISABLED_wallet_history)
auto send (system.wallet (0)->send_action (nano::dev::genesis_key.pub, nano::dev::genesis_key.pub, node->config.receive_minimum.number ()));
ASSERT_NE (nullptr, send);
auto timestamp2 = nano::seconds_since_epoch ();
auto receive (system.wallet (0)->receive_action (send->hash (), nano::dev::genesis_key.pub, node->config.receive_minimum.number (), send->link ().value ().as_account ()));
auto receive (system.wallet (0)->receive_action (send->hash (), nano::dev::genesis_key.pub, node->config.receive_minimum.number (), send->destination ()));
ASSERT_NE (nullptr, receive);
nano::keypair key;
auto timestamp3 = nano::seconds_since_epoch ();

View file

@ -224,7 +224,7 @@ bool ledger_processor::validate_epoch_block (nano::state_block const & block_a)
if (validate_message (block_a.hashables.account, block_a.hash (), block_a.signature))
{
// Is epoch block signed correctly
if (validate_message (ledger.epoch_signer (block_a.link ().value ()), block_a.hash (), block_a.signature))
if (validate_message (ledger.epoch_signer (block_a.link_field ().value ()), block_a.hash (), block_a.signature))
{
result = nano::block_status::bad_signature;
}