Skip to content

Commit

Permalink
Remove some friend directives in block_state_legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
greg7mdp committed Dec 19, 2023
1 parent 88092c3 commit 60555a4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 24 deletions.
2 changes: 1 addition & 1 deletion libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class maybe_session {
public:
maybe_session() = default;

maybe_session( maybe_session&& other)
maybe_session( maybe_session&& other) noexcept
:_session(std::move(other._session))
{
}
Expand Down
13 changes: 4 additions & 9 deletions libraries/chain/fork_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ namespace eosio::chain {
template<class bsp, class bhsp>
const uint32_t fork_database<bsp, bhsp>::max_supported_version = 2;

// work around block_state_legacy::is_valid being private
inline bool block_state_is_valid( const block_state_legacy& bs ) {
return bs.is_valid();
}

/**
* History:
* Version 1: initial version of the new refactored fork database portable format
Expand Down Expand Up @@ -269,7 +264,7 @@ namespace eosio::chain {
index.clear();
root = std::make_shared<bs>();
static_cast<bhs&>(*root) = root_bhs;
root->validated = true;
root->set_valid(true);
head = root;
}

Expand All @@ -285,7 +280,7 @@ namespace eosio::chain {
auto itr = by_id_idx.begin();
while (itr != by_id_idx.end()) {
by_id_idx.modify( itr, [&]( bsp& _bsp ) {
_bsp->validated = false;
_bsp->set_valid(false);
} );
++itr;
}
Expand Down Expand Up @@ -565,7 +560,7 @@ namespace eosio::chain {

template<class bsp, class bhsp>
void fork_database_impl<bsp, bhsp>::mark_valid_impl( const bsp& h ) {
if( h->validated ) return;
if( h->is_valid() ) return;

auto& by_id_idx = index.template get<by_block_id>();

Expand All @@ -575,7 +570,7 @@ namespace eosio::chain {
("id", h->id()) );

by_id_idx.modify( itr, []( bsp& _bsp ) {
_bsp->validated = true;
_bsp->set_valid(true);
} );

auto candidate = index.template get<by_lib_block_num>().begin();
Expand Down
10 changes: 3 additions & 7 deletions libraries/chain/include/eosio/chain/block_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ namespace eosio::chain {
uint32_t block_num() const { return block_header_state::block_num(); }
block_timestamp_type timestamp() const { return block_header_state::timestamp(); }
const extensions_type& header_extensions() const { return block_header_state::header.header_extensions; }
bool is_valid() const { return validated; }
void set_valid(bool b) { validated = b; }
uint32_t irreversible_blocknum() const { return 0; } // [greg todo] equivalent of dpos_irreversible_blocknum

protocol_feature_activation_set_ptr get_activated_protocol_features() const { return block_header_state::activated_protocol_features; }
deque<transaction_metadata_ptr> extract_trxs_metas() { return {}; }; // [greg todo] see impl in block_state_legacy.hpp

// [greg todo] equivalent of block_state_legacy_common::dpos_irreversible_blocknum - ref in fork_database.cpp
uint32_t irreversible_blocknum() const { return 0; }

// [greg todo] equivalent of block_state_legacy::validated - ref in fork_database.cpp
bool is_valid() const { return validated; }

};

using block_state_ptr = std::shared_ptr<block_state>;
Expand Down
11 changes: 4 additions & 7 deletions libraries/chain/include/eosio/chain/block_state_legacy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@ namespace eosio { namespace chain {
block_timestamp_type timestamp() const { return header.timestamp; }
const extensions_type& header_extensions() const { return header.header_extensions; }
bool is_valid() const { return validated; }
protocol_feature_activation_set_ptr get_activated_protocol_features() const { return activated_protocol_features; }
void set_valid(bool b) { validated = b; }
protocol_feature_activation_set_ptr get_activated_protocol_features() const { return activated_protocol_features; }
const deque<transaction_metadata_ptr>& trxs_metas() const { return _cached_trxs; }


private: // internal use only, not thread safe
friend struct fc::reflector<block_state_legacy>;
friend bool block_state_is_valid( const block_state_legacy& ); // work-around for multi-index access
friend struct controller_impl;
template<class bsp, class bhsp> friend class fork_database;
template<class bsp, class bhsp> friend struct fork_database_impl;
friend class unapplied_transaction_queue;
friend struct pending_state;
friend struct completed_block;

bool is_pub_keys_recovered()const { return _pub_keys_recovered; }
Expand All @@ -61,7 +59,6 @@ namespace eosio { namespace chain {
_pub_keys_recovered = keys_recovered;
_cached_trxs = std::move( trxs_metas );
}
const deque<transaction_metadata_ptr>& trxs_metas()const { return _cached_trxs; }

bool validated = false;

Expand Down

0 comments on commit 60555a4

Please sign in to comment.