Change block::account to return an std::optional if the block actually contains the field.
Fixes up call sites that checked against the old sentinel value 0. Convert many call sites to using ledger::account(block&) when possible.
This commit is contained in:
parent
76ebe9afa8
commit
122a935306
23 changed files with 49 additions and 68 deletions
|
|
@ -1534,7 +1534,7 @@ TEST (active_transactions, allow_limited_overflow)
|
||||||
// Insert the first part of the blocks into normal election scheduler
|
// Insert the first part of the blocks into normal election scheduler
|
||||||
for (auto const & block : blocks1)
|
for (auto const & block : blocks1)
|
||||||
{
|
{
|
||||||
node.scheduler.priority.activate (block->account (), node.store.tx_begin_read ());
|
node.scheduler.priority.activate (block->account ().value (), node.store.tx_begin_read ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure number of active elections reaches AEC limit and there is no overfill
|
// Ensure number of active elections reaches AEC limit and there is no overfill
|
||||||
|
|
@ -1596,7 +1596,7 @@ TEST (active_transactions, allow_limited_overflow_adapt)
|
||||||
// Insert the first part of the blocks into normal election scheduler
|
// Insert the first part of the blocks into normal election scheduler
|
||||||
for (auto const & block : blocks1)
|
for (auto const & block : blocks1)
|
||||||
{
|
{
|
||||||
node.scheduler.priority.activate (block->account (), node.store.tx_begin_read ());
|
node.scheduler.priority.activate (block->account ().value (), node.store.tx_begin_read ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure number of active elections reaches AEC limit and there is no overfill
|
// Ensure number of active elections reaches AEC limit and there is no overfill
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,7 @@ TEST (backlog, population)
|
||||||
auto all_activated = [&] () {
|
auto all_activated = [&] () {
|
||||||
nano::lock_guard<nano::mutex> lock{ mutex };
|
nano::lock_guard<nano::mutex> lock{ mutex };
|
||||||
return std::all_of (blocks.begin (), blocks.end (), [&] (auto const & item) {
|
return std::all_of (blocks.begin (), blocks.end (), [&] (auto const & item) {
|
||||||
auto account = item->account ();
|
return activated.count (item->account ().value ()) != 0;
|
||||||
debug_assert (!account.is_zero ());
|
|
||||||
return activated.count (account) != 0;
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
ASSERT_TIMELY (5s, all_activated ());
|
ASSERT_TIMELY (5s, all_activated ());
|
||||||
|
|
|
||||||
|
|
@ -4052,7 +4052,7 @@ TEST (ledger, epoch_open_pending)
|
||||||
ASSERT_TIMELY_EQ (10s, 1, node1.unchecked.count ());
|
ASSERT_TIMELY_EQ (10s, 1, node1.unchecked.count ());
|
||||||
ASSERT_FALSE (node1.ledger.block_or_pruned_exists (epoch_open->hash ()));
|
ASSERT_FALSE (node1.ledger.block_or_pruned_exists (epoch_open->hash ()));
|
||||||
// Open block should be inserted into unchecked
|
// Open block should be inserted into unchecked
|
||||||
auto blocks = node1.unchecked.get (nano::hash_or_account (epoch_open->account ()).hash);
|
auto blocks = node1.unchecked.get (nano::hash_or_account (epoch_open->account ().value ()).hash);
|
||||||
ASSERT_EQ (blocks.size (), 1);
|
ASSERT_EQ (blocks.size (), 1);
|
||||||
ASSERT_EQ (blocks[0].block->full_hash (), epoch_open->full_hash ());
|
ASSERT_EQ (blocks[0].block->full_hash (), epoch_open->full_hash ());
|
||||||
// New block to process epoch open
|
// New block to process epoch open
|
||||||
|
|
|
||||||
|
|
@ -185,10 +185,9 @@ nano::link const & nano::block::link () const
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
nano::account const & nano::block::account () const
|
std::optional<nano::account> nano::block::account () const
|
||||||
{
|
{
|
||||||
static nano::account account{};
|
return std::nullopt;
|
||||||
return account;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nano::qualified_root nano::block::qualified_root () const
|
nano::qualified_root nano::block::qualified_root () const
|
||||||
|
|
@ -643,7 +642,7 @@ nano::block_hash const & nano::open_block::previous () const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
nano::account const & nano::open_block::account () const
|
std::optional<nano::account> nano::open_block::account () const
|
||||||
{
|
{
|
||||||
return hashables.account;
|
return hashables.account;
|
||||||
}
|
}
|
||||||
|
|
@ -1213,7 +1212,7 @@ nano::block_hash const & nano::state_block::previous () const
|
||||||
return hashables.previous;
|
return hashables.previous;
|
||||||
}
|
}
|
||||||
|
|
||||||
nano::account const & nano::state_block::account () const
|
std::optional<nano::account> nano::state_block::account () const
|
||||||
{
|
{
|
||||||
return hashables.account;
|
return hashables.account;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ public:
|
||||||
virtual void hash (blake2b_state &) const = 0;
|
virtual void hash (blake2b_state &) const = 0;
|
||||||
virtual uint64_t block_work () const = 0;
|
virtual uint64_t block_work () const = 0;
|
||||||
virtual void block_work_set (uint64_t) = 0;
|
virtual void block_work_set (uint64_t) = 0;
|
||||||
virtual nano::account const & account () const;
|
|
||||||
// Previous block in account's chain, zero for open block
|
// Previous block in account's chain, zero for open block
|
||||||
virtual nano::block_hash const & previous () const = 0;
|
virtual nano::block_hash const & previous () const = 0;
|
||||||
// Source block for open/receive blocks, zero otherwise.
|
// Source block for open/receive blocks, zero otherwise.
|
||||||
|
|
@ -64,6 +63,10 @@ public:
|
||||||
// If there are any changes to the hashables, call this to update the cached hash
|
// If there are any changes to the hashables, call this to update the cached hash
|
||||||
void refresh ();
|
void refresh ();
|
||||||
|
|
||||||
|
public: // Direct access to the block fields or nullopt if the block type does not have the specified field
|
||||||
|
// Account field for open/state blocks
|
||||||
|
virtual std::optional<nano::account> account () const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mutable nano::block_hash cached_hash{ 0 };
|
mutable nano::block_hash cached_hash{ 0 };
|
||||||
/**
|
/**
|
||||||
|
|
@ -210,7 +213,7 @@ public:
|
||||||
uint64_t block_work () const override;
|
uint64_t block_work () const override;
|
||||||
void block_work_set (uint64_t) override;
|
void block_work_set (uint64_t) override;
|
||||||
nano::block_hash const & previous () const override;
|
nano::block_hash const & previous () const override;
|
||||||
nano::account const & account () const override;
|
std::optional<nano::account> account () const override;
|
||||||
nano::block_hash const & source () const override;
|
nano::block_hash const & source () const override;
|
||||||
nano::root const & root () const override;
|
nano::root const & root () const override;
|
||||||
nano::account const & representative () const override;
|
nano::account const & representative () const override;
|
||||||
|
|
@ -325,7 +328,7 @@ public:
|
||||||
uint64_t block_work () const override;
|
uint64_t block_work () const override;
|
||||||
void block_work_set (uint64_t) override;
|
void block_work_set (uint64_t) override;
|
||||||
nano::block_hash const & previous () const override;
|
nano::block_hash const & previous () const override;
|
||||||
nano::account const & account () const override;
|
std::optional<nano::account> account () const override;
|
||||||
nano::root const & root () const override;
|
nano::root const & root () const override;
|
||||||
nano::link const & link () const override;
|
nano::link const & link () const override;
|
||||||
nano::account const & representative () const override;
|
nano::account const & representative () const override;
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ void nano::active_transactions::notify_observers (nano::election_status const &
|
||||||
|
|
||||||
void nano::active_transactions::handle_final_votes_confirmation (std::shared_ptr<nano::block> const & block, nano::store::read_transaction const & transaction, nano::election_status_type status)
|
void nano::active_transactions::handle_final_votes_confirmation (std::shared_ptr<nano::block> const & block, nano::store::read_transaction const & transaction, nano::election_status_type status)
|
||||||
{
|
{
|
||||||
auto const & account = !block->account ().is_zero () ? block->account () : block->sideband ().account;
|
auto account = node.ledger.account (*block);
|
||||||
|
|
||||||
bool is_canary_not_set = !node.ledger.cache.final_votes_confirmation_canary.load ();
|
bool is_canary_not_set = !node.ledger.cache.final_votes_confirmation_canary.load ();
|
||||||
bool is_canary_account = account == node.network_params.ledger.final_votes_canary_account;
|
bool is_canary_account = account == node.network_params.ledger.final_votes_canary_account;
|
||||||
|
|
|
||||||
|
|
@ -362,7 +362,7 @@ nano::block_status nano::block_processor::process_one (store::write_transaction
|
||||||
}
|
}
|
||||||
case nano::block_status::gap_epoch_open_pending:
|
case nano::block_status::gap_epoch_open_pending:
|
||||||
{
|
{
|
||||||
node.unchecked.put (block->account (), block); // Specific unchecked key starting with epoch open block account public key
|
node.unchecked.put (block->account ().value_or (0), block); // Specific unchecked key starting with epoch open block account public key
|
||||||
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::gap_source);
|
node.stats.inc (nano::stat::type::ledger, nano::stat::detail::gap_source);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -188,7 +188,7 @@ void nano::bulk_pull_client::received_block (boost::system::error_code ec, std::
|
||||||
}
|
}
|
||||||
if (pull_blocks == 0 && block_expected)
|
if (pull_blocks == 0 && block_expected)
|
||||||
{
|
{
|
||||||
known_account = block->account ();
|
known_account = block->account ().value_or (0);
|
||||||
}
|
}
|
||||||
if (connection->block_count++ == 0)
|
if (connection->block_count++ == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ void nano::bootstrap_ascending::service::inspect (store::transaction const & tx,
|
||||||
break;
|
break;
|
||||||
case nano::block_status::gap_source:
|
case nano::block_status::gap_source:
|
||||||
{
|
{
|
||||||
const auto account = block.previous ().is_zero () ? block.account () : ledger.account (tx, block.previous ()).value ();
|
const auto account = block.previous ().is_zero () ? block.account ().value () : ledger.account (tx, block.previous ()).value ();
|
||||||
const auto source = block.source ().is_zero () ? block.link ().as_block_hash () : block.source ();
|
const auto source = block.source ().is_zero () ? block.link ().as_block_hash () : block.source ();
|
||||||
|
|
||||||
// Mark account as blocked because it is missing the source block
|
// Mark account as blocked because it is missing the source block
|
||||||
|
|
|
||||||
|
|
@ -1324,7 +1324,7 @@ void reset_confirmation_heights (nano::store::write_transaction const & transact
|
||||||
store.confirmation_height.clear (transaction);
|
store.confirmation_height.clear (transaction);
|
||||||
|
|
||||||
// Then make sure the confirmation height of the genesis account open block is 1
|
// Then make sure the confirmation height of the genesis account open block is 1
|
||||||
store.confirmation_height.put (transaction, constants.genesis->account (), { 1, constants.genesis->hash () });
|
store.confirmation_height.put (transaction, constants.genesis->account ().value (), { 1, constants.genesis->hash () });
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_using_rocksdb (std::filesystem::path const & data_path, boost::program_options::variables_map const & vm, std::error_code & ec)
|
bool is_using_rocksdb (std::filesystem::path const & data_path, boost::program_options::variables_map const & vm, std::error_code & ec)
|
||||||
|
|
|
||||||
|
|
@ -104,11 +104,7 @@ void nano::confirmation_height_bounded::process (std::shared_ptr<nano::block> or
|
||||||
release_assert (block);
|
release_assert (block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nano::account account (block->account ());
|
auto account = ledger.account (*block);
|
||||||
if (account.is_zero ())
|
|
||||||
{
|
|
||||||
account = block->sideband ().account;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Checks if we have encountered this account before but not commited changes yet, if so then update the cached confirmation height
|
// Checks if we have encountered this account before but not commited changes yet, if so then update the cached confirmation height
|
||||||
nano::confirmation_height_info confirmation_height_info;
|
nano::confirmation_height_info confirmation_height_info;
|
||||||
|
|
|
||||||
|
|
@ -79,11 +79,7 @@ void nano::confirmation_height_unbounded::process (std::shared_ptr<nano::block>
|
||||||
}
|
}
|
||||||
release_assert (block);
|
release_assert (block);
|
||||||
|
|
||||||
nano::account account (block->account ());
|
auto account = ledger.account (*block);
|
||||||
if (account.is_zero ())
|
|
||||||
{
|
|
||||||
account = block->sideband ().account;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto block_height = block->sideband ().height;
|
auto block_height = block->sideband ().height;
|
||||||
uint64_t confirmation_height = 0;
|
uint64_t confirmation_height = 0;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
std::unique_ptr<nanoapi::BlockStateT> nano::ipc::flatbuffers_builder::from (nano::state_block const & block_a, nano::amount const & amount_a, bool is_state_send_a, bool is_state_epoch_a)
|
std::unique_ptr<nanoapi::BlockStateT> nano::ipc::flatbuffers_builder::from (nano::state_block const & block_a, nano::amount const & amount_a, bool is_state_send_a, bool is_state_epoch_a)
|
||||||
{
|
{
|
||||||
auto block (std::make_unique<nanoapi::BlockStateT> ());
|
auto block (std::make_unique<nanoapi::BlockStateT> ());
|
||||||
block->account = block_a.account ().to_account ();
|
block->account = block_a.account ().value ().to_account ();
|
||||||
block->hash = block_a.hash ().to_string ();
|
block->hash = block_a.hash ().to_string ();
|
||||||
block->previous = block_a.previous ().to_string ();
|
block->previous = block_a.previous ().to_string ();
|
||||||
block->representative = block_a.representative ().to_account ();
|
block->representative = block_a.representative ().to_account ();
|
||||||
|
|
@ -63,7 +63,7 @@ std::unique_ptr<nanoapi::BlockOpenT> nano::ipc::flatbuffers_builder::from (nano:
|
||||||
auto block (std::make_unique<nanoapi::BlockOpenT> ());
|
auto block (std::make_unique<nanoapi::BlockOpenT> ());
|
||||||
block->hash = block_a.hash ().to_string ();
|
block->hash = block_a.hash ().to_string ();
|
||||||
block->source = block_a.source ().to_string ();
|
block->source = block_a.source ().to_string ();
|
||||||
block->account = block_a.account ().to_account ();
|
block->account = block_a.account ().value ().to_account ();
|
||||||
block->representative = block_a.representative ().to_account ();
|
block->representative = block_a.representative ().to_account ();
|
||||||
block_a.signature.encode_hex (block->signature);
|
block_a.signature.encode_hex (block->signature);
|
||||||
block->work = nano::to_string_hex (block_a.work);
|
block->work = nano::to_string_hex (block_a.work);
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,7 @@ uint64_t nano::json_handler::difficulty_ledger (nano::block const & block_a)
|
||||||
if (!link.is_zero () && !details.is_send)
|
if (!link.is_zero () && !details.is_send)
|
||||||
{
|
{
|
||||||
auto block_link = node.ledger.block (transaction, link.as_block_hash ());
|
auto block_link = node.ledger.block (transaction, link.as_block_hash ());
|
||||||
if (block_link != nullptr && node.store.pending.exists (transaction, nano::pending_key (block_a.account (), link.as_block_hash ())))
|
if (block_link != nullptr && node.store.pending.exists (transaction, nano::pending_key (block_a.account ().value (), link.as_block_hash ())))
|
||||||
{
|
{
|
||||||
details.epoch = std::max (details.epoch, block_link->sideband ().details.epoch);
|
details.epoch = std::max (details.epoch, block_link->sideband ().details.epoch);
|
||||||
details.is_receive = true;
|
details.is_receive = true;
|
||||||
|
|
@ -1131,7 +1131,7 @@ void nano::json_handler::active_difficulty ()
|
||||||
|
|
||||||
void nano::json_handler::available_supply ()
|
void nano::json_handler::available_supply ()
|
||||||
{
|
{
|
||||||
auto genesis_balance (node.balance (node.network_params.ledger.genesis->account ())); // Cold storage genesis
|
auto genesis_balance (node.balance (node.network_params.ledger.genesis->account ().value ())); // Cold storage genesis
|
||||||
auto landing_balance (node.balance (nano::account ("059F68AAB29DE0D3A27443625C7EA9CDDB6517A8B76FE37727EF6A4D76832AD5"))); // Active unavailable account
|
auto landing_balance (node.balance (nano::account ("059F68AAB29DE0D3A27443625C7EA9CDDB6517A8B76FE37727EF6A4D76832AD5"))); // Active unavailable account
|
||||||
auto faucet_balance (node.balance (nano::account ("8E319CE6F3025E5B2DF66DA7AB1467FE48F1679C13DD43BFDB29FA2E9FC40D3B"))); // Faucet account
|
auto faucet_balance (node.balance (nano::account ("8E319CE6F3025E5B2DF66DA7AB1467FE48F1679C13DD43BFDB29FA2E9FC40D3B"))); // Faucet account
|
||||||
auto burned_balance ((node.balance_pending (nano::account{}, false)).second); // Burning 0 account
|
auto burned_balance ((node.balance_pending (nano::account{}, false)).second); // Burning 0 account
|
||||||
|
|
@ -1149,7 +1149,7 @@ void nano::json_handler::block_info ()
|
||||||
auto block = node.ledger.block (transaction, hash);
|
auto block = node.ledger.block (transaction, hash);
|
||||||
if (block != nullptr)
|
if (block != nullptr)
|
||||||
{
|
{
|
||||||
nano::account account (block->account ().is_zero () ? block->sideband ().account : block->account ());
|
auto account = node.ledger.account (*block);
|
||||||
response_l.put ("block_account", account.to_account ());
|
response_l.put ("block_account", account.to_account ());
|
||||||
auto amount = node.ledger.amount (transaction, hash);
|
auto amount = node.ledger.amount (transaction, hash);
|
||||||
if (amount)
|
if (amount)
|
||||||
|
|
@ -1306,7 +1306,7 @@ void nano::json_handler::blocks_info ()
|
||||||
if (block != nullptr)
|
if (block != nullptr)
|
||||||
{
|
{
|
||||||
boost::property_tree::ptree entry;
|
boost::property_tree::ptree entry;
|
||||||
nano::account account (block->account ().is_zero () ? block->sideband ().account : block->account ());
|
auto account = node.ledger.account (*block);
|
||||||
entry.put ("block_account", account.to_account ());
|
entry.put ("block_account", account.to_account ());
|
||||||
auto amount = node.ledger.amount (transaction, hash);
|
auto amount = node.ledger.amount (transaction, hash);
|
||||||
if (amount)
|
if (amount)
|
||||||
|
|
@ -2454,7 +2454,7 @@ public:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tree.put ("account", handler.node.ledger.constants.genesis->account ().to_account ());
|
tree.put ("account", handler.node.ledger.constants.genesis->account ().value ().to_account ());
|
||||||
tree.put ("amount", nano::dev::constants.genesis_amount.convert_to<std::string> ());
|
tree.put ("amount", nano::dev::constants.genesis_amount.convert_to<std::string> ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1226,11 +1226,7 @@ void nano::node::receive_confirmed (store::transaction const & block_transaction
|
||||||
void nano::node::process_confirmed_data (store::transaction const & transaction_a, std::shared_ptr<nano::block> const & block_a, nano::block_hash const & hash_a, nano::account & account_a, nano::uint128_t & amount_a, bool & is_state_send_a, bool & is_state_epoch_a, nano::account & pending_account_a)
|
void nano::node::process_confirmed_data (store::transaction const & transaction_a, std::shared_ptr<nano::block> const & block_a, nano::block_hash const & hash_a, nano::account & account_a, nano::uint128_t & amount_a, bool & is_state_send_a, bool & is_state_epoch_a, nano::account & pending_account_a)
|
||||||
{
|
{
|
||||||
// Faster account calculation
|
// Faster account calculation
|
||||||
account_a = block_a->account ();
|
account_a = ledger.account (*block_a);
|
||||||
if (account_a.is_zero ())
|
|
||||||
{
|
|
||||||
account_a = block_a->sideband ().account;
|
|
||||||
}
|
|
||||||
// Faster amount calculation
|
// Faster amount calculation
|
||||||
auto previous (block_a->previous ());
|
auto previous (block_a->previous ());
|
||||||
auto previous_balance = ledger.balance (transaction_a, previous);
|
auto previous_balance = ledger.balance (transaction_a, previous);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ nano::node_config::node_config (const std::optional<uint16_t> & peering_port_a,
|
||||||
{
|
{
|
||||||
case nano::networks::nano_dev_network:
|
case nano::networks::nano_dev_network:
|
||||||
enable_voting = true;
|
enable_voting = true;
|
||||||
preconfigured_representatives.push_back (network_params.ledger.genesis->account ());
|
preconfigured_representatives.push_back (network_params.ledger.genesis->account ().value ());
|
||||||
break;
|
break;
|
||||||
case nano::networks::nano_beta_network:
|
case nano::networks::nano_beta_network:
|
||||||
{
|
{
|
||||||
|
|
@ -72,7 +72,7 @@ nano::node_config::node_config (const std::optional<uint16_t> & peering_port_a,
|
||||||
break;
|
break;
|
||||||
case nano::networks::nano_test_network:
|
case nano::networks::nano_test_network:
|
||||||
preconfigured_peers.push_back (default_test_peer_network);
|
preconfigured_peers.push_back (default_test_peer_network);
|
||||||
preconfigured_representatives.push_back (network_params.ledger.genesis->account ());
|
preconfigured_representatives.push_back (network_params.ledger.genesis->account ().value ());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
debug_assert (false);
|
debug_assert (false);
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,7 @@ void nano::process_live_dispatcher::process_live (nano::block const & block, sto
|
||||||
// Start collecting quorum on block
|
// Start collecting quorum on block
|
||||||
if (ledger.dependents_confirmed (transaction, block))
|
if (ledger.dependents_confirmed (transaction, block))
|
||||||
{
|
{
|
||||||
auto account = block.account ().is_zero () ? block.sideband ().account : block.account ();
|
scheduler.activate (ledger.account (block), transaction);
|
||||||
scheduler.activate (account, transaction);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (websocket.server && websocket.server->any_subscriber (nano::websocket::topic::new_unconfirmed_block))
|
if (websocket.server && websocket.server->any_subscriber (nano::websocket::topic::new_unconfirmed_block))
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,7 @@ std::pair<std::vector<std::shared_ptr<nano::block>>, std::vector<std::shared_ptr
|
||||||
if (block != nullptr)
|
if (block != nullptr)
|
||||||
{
|
{
|
||||||
nano::confirmation_height_info confirmation_height_info;
|
nano::confirmation_height_info confirmation_height_info;
|
||||||
ledger.store.confirmation_height.get (transaction, block->account ().is_zero () ? block->sideband ().account : block->account (), confirmation_height_info);
|
ledger.store.confirmation_height.get (transaction, ledger.account (*block), confirmation_height_info);
|
||||||
generate_final_vote = (confirmation_height_info.height >= block->sideband ().height);
|
generate_final_vote = (confirmation_height_info.height >= block->sideband ().height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -265,7 +265,7 @@ std::pair<std::vector<std::shared_ptr<nano::block>>, std::vector<std::shared_ptr
|
||||||
if (block != nullptr && generate_vote)
|
if (block != nullptr && generate_vote)
|
||||||
{
|
{
|
||||||
nano::confirmation_height_info confirmation_height_info;
|
nano::confirmation_height_info confirmation_height_info;
|
||||||
ledger.store.confirmation_height.get (transaction, block->account ().is_zero () ? block->sideband ().account : block->account (), confirmation_height_info);
|
ledger.store.confirmation_height.get (transaction, ledger.account (*block), confirmation_height_info);
|
||||||
generate_final_vote = (confirmation_height_info.height >= block->sideband ().height);
|
generate_final_vote = (confirmation_height_info.height >= block->sideband ().height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -566,7 +566,7 @@ public:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
account = ledger.constants.genesis->account ();
|
account = ledger.constants.genesis->account ().value ();
|
||||||
amount = nano::dev::constants.genesis_amount;
|
amount = nano::dev::constants.genesis_amount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3314,7 +3314,7 @@ TEST (rpc, pending_exists)
|
||||||
ASSERT_TRUE (pending_exists ("1"));
|
ASSERT_TRUE (pending_exists ("1"));
|
||||||
|
|
||||||
ASSERT_TRUE (pending_exists ("1"));
|
ASSERT_TRUE (pending_exists ("1"));
|
||||||
reset_confirmation_height (node->store, block1->account ());
|
reset_confirmation_height (node->store, block1->account ().value ());
|
||||||
ASSERT_TRUE (pending_exists ("0"));
|
ASSERT_TRUE (pending_exists ("0"));
|
||||||
request.put ("include_only_confirmed", "false");
|
request.put ("include_only_confirmed", "false");
|
||||||
ASSERT_TRUE (pending_exists ("1"));
|
ASSERT_TRUE (pending_exists ("1"));
|
||||||
|
|
@ -3419,7 +3419,7 @@ TEST (rpc, wallet_receivable)
|
||||||
ASSERT_EQ (sources[block1->hash ()], nano::dev::genesis_key.pub);
|
ASSERT_EQ (sources[block1->hash ()], nano::dev::genesis_key.pub);
|
||||||
|
|
||||||
ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 1));
|
ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 1));
|
||||||
reset_confirmation_height (system.nodes.front ()->store, block1->account ());
|
reset_confirmation_height (system.nodes.front ()->store, block1->account ().value ());
|
||||||
ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 0));
|
ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 0));
|
||||||
request.put ("include_only_confirmed", "false");
|
request.put ("include_only_confirmed", "false");
|
||||||
ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 1));
|
ASSERT_TRUE (check_block_response_count (system, rpc_ctx, request, 1));
|
||||||
|
|
|
||||||
|
|
@ -127,15 +127,15 @@ nano::ledger_constants::ledger_constants (nano::work_thresholds & work, nano::ne
|
||||||
: network_a == nano::networks::nano_test_network ? nano_test_final_votes_canary_height
|
: network_a == nano::networks::nano_test_network ? nano_test_final_votes_canary_height
|
||||||
: nano_live_final_votes_canary_height)
|
: nano_live_final_votes_canary_height)
|
||||||
{
|
{
|
||||||
nano_beta_genesis->sideband_set (nano::block_sideband (nano_beta_genesis->account (), 0, std::numeric_limits<nano::uint128_t>::max (), 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0));
|
nano_beta_genesis->sideband_set (nano::block_sideband (nano_beta_genesis->account ().value (), 0, std::numeric_limits<nano::uint128_t>::max (), 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0));
|
||||||
nano_dev_genesis->sideband_set (nano::block_sideband (nano_dev_genesis->account (), 0, std::numeric_limits<nano::uint128_t>::max (), 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0));
|
nano_dev_genesis->sideband_set (nano::block_sideband (nano_dev_genesis->account ().value (), 0, std::numeric_limits<nano::uint128_t>::max (), 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0));
|
||||||
nano_live_genesis->sideband_set (nano::block_sideband (nano_live_genesis->account (), 0, std::numeric_limits<nano::uint128_t>::max (), 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0));
|
nano_live_genesis->sideband_set (nano::block_sideband (nano_live_genesis->account ().value (), 0, std::numeric_limits<nano::uint128_t>::max (), 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0));
|
||||||
nano_test_genesis->sideband_set (nano::block_sideband (nano_test_genesis->account (), 0, std::numeric_limits<nano::uint128_t>::max (), 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0));
|
nano_test_genesis->sideband_set (nano::block_sideband (nano_test_genesis->account ().value (), 0, std::numeric_limits<nano::uint128_t>::max (), 1, nano::seconds_since_epoch (), nano::epoch::epoch_0, false, false, false, nano::epoch::epoch_0));
|
||||||
|
|
||||||
nano::link epoch_link_v1;
|
nano::link epoch_link_v1;
|
||||||
char const * epoch_message_v1 ("epoch v1 block");
|
char const * epoch_message_v1 ("epoch v1 block");
|
||||||
strncpy ((char *)epoch_link_v1.bytes.data (), epoch_message_v1, epoch_link_v1.bytes.size ());
|
strncpy ((char *)epoch_link_v1.bytes.data (), epoch_message_v1, epoch_link_v1.bytes.size ());
|
||||||
epochs.add (nano::epoch::epoch_1, genesis->account (), epoch_link_v1);
|
epochs.add (nano::epoch::epoch_1, genesis->account ().value (), epoch_link_v1);
|
||||||
|
|
||||||
nano::link epoch_link_v2;
|
nano::link epoch_link_v2;
|
||||||
nano::account nano_live_epoch_v2_signer;
|
nano::account nano_live_epoch_v2_signer;
|
||||||
|
|
|
||||||
|
|
@ -1132,13 +1132,7 @@ bool nano::ledger::rollback (store::write_transaction const & transaction_a, nan
|
||||||
nano::account nano::ledger::account (nano::block const & block)
|
nano::account nano::ledger::account (nano::block const & block)
|
||||||
{
|
{
|
||||||
debug_assert (block.has_sideband ());
|
debug_assert (block.has_sideband ());
|
||||||
nano::account result (block.account ());
|
return block.account ().value_or (block.sideband ().account);
|
||||||
if (result.is_zero ())
|
|
||||||
{
|
|
||||||
result = block.sideband ().account;
|
|
||||||
}
|
|
||||||
debug_assert (!result.is_zero ());
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<nano::account> nano::ledger::account (store::transaction const & transaction, nano::block_hash const & hash) const
|
std::optional<nano::account> nano::ledger::account (store::transaction const & transaction, nano::block_hash const & hash) const
|
||||||
|
|
@ -1431,7 +1425,7 @@ bool nano::ledger::block_confirmed (store::transaction const & transaction_a, na
|
||||||
if (block_l)
|
if (block_l)
|
||||||
{
|
{
|
||||||
nano::confirmation_height_info confirmation_height_info;
|
nano::confirmation_height_info confirmation_height_info;
|
||||||
store.confirmation_height.get (transaction_a, block_l->account ().is_zero () ? block_l->sideband ().account : block_l->account (), confirmation_height_info);
|
store.confirmation_height.get (transaction_a, account (*block_l), confirmation_height_info);
|
||||||
auto confirmed (confirmation_height_info.height >= block_l->sideband ().height);
|
auto confirmed (confirmation_height_info.height >= block_l->sideband ().height);
|
||||||
return confirmed;
|
return confirmed;
|
||||||
}
|
}
|
||||||
|
|
@ -1616,7 +1610,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p
|
||||||
auto random_block (store.block.random (lmdb_transaction));
|
auto random_block (store.block.random (lmdb_transaction));
|
||||||
error |= rocksdb_store->block.get (rocksdb_transaction, random_block->hash ()) == nullptr;
|
error |= rocksdb_store->block.get (rocksdb_transaction, random_block->hash ()) == nullptr;
|
||||||
|
|
||||||
auto account = random_block->account ().is_zero () ? random_block->sideband ().account : random_block->account ();
|
auto account = this->account (*random_block);
|
||||||
nano::account_info account_info;
|
nano::account_info account_info;
|
||||||
error |= rocksdb_store->account.get (rocksdb_transaction, account, account_info);
|
error |= rocksdb_store->account.get (rocksdb_transaction, account, account_info);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,11 @@ void nano::store::component::initialize (store::write_transaction const & transa
|
||||||
auto hash_l (constants.genesis->hash ());
|
auto hash_l (constants.genesis->hash ());
|
||||||
block.put (transaction_a, hash_l, *constants.genesis);
|
block.put (transaction_a, hash_l, *constants.genesis);
|
||||||
++ledger_cache_a.block_count;
|
++ledger_cache_a.block_count;
|
||||||
confirmation_height.put (transaction_a, constants.genesis->account (), nano::confirmation_height_info{ 1, constants.genesis->hash () });
|
confirmation_height.put (transaction_a, constants.genesis->account ().value (), nano::confirmation_height_info{ 1, constants.genesis->hash () });
|
||||||
++ledger_cache_a.cemented_count;
|
++ledger_cache_a.cemented_count;
|
||||||
ledger_cache_a.final_votes_confirmation_canary = (constants.final_votes_canary_account == constants.genesis->account () && 1 >= constants.final_votes_canary_height);
|
ledger_cache_a.final_votes_confirmation_canary = (constants.final_votes_canary_account == constants.genesis->account () && 1 >= constants.final_votes_canary_height);
|
||||||
account.put (transaction_a, constants.genesis->account (), { hash_l, constants.genesis->account (), constants.genesis->hash (), std::numeric_limits<nano::uint128_t>::max (), nano::seconds_since_epoch (), 1, nano::epoch::epoch_0 });
|
account.put (transaction_a, constants.genesis->account ().value (), { hash_l, constants.genesis->account ().value (), constants.genesis->hash (), std::numeric_limits<nano::uint128_t>::max (), nano::seconds_since_epoch (), 1, nano::epoch::epoch_0 });
|
||||||
++ledger_cache_a.account_count;
|
++ledger_cache_a.account_count;
|
||||||
ledger_cache_a.rep_weights.representation_put (constants.genesis->account (), std::numeric_limits<nano::uint128_t>::max ());
|
ledger_cache_a.rep_weights.representation_put (constants.genesis->account ().value (), std::numeric_limits<nano::uint128_t>::max ());
|
||||||
frontier.put (transaction_a, hash_l, constants.genesis->account ());
|
frontier.put (transaction_a, hash_l, constants.genesis->account ().value ());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue