Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::protocol_feature_manager Class Reference

#include <protocol_feature_manager.hpp>

Collaboration diagram for sysio::chain::protocol_feature_manager:

Classes

struct  builtin_protocol_feature_entry
 
class  const_iterator
 
struct  protocol_feature_entry
 

Public Types

using const_reverse_iterator = std::reverse_iterator<const_iterator>
 

Public Member Functions

 protocol_feature_manager (protocol_feature_set &&pfs, std::function< deep_mind_handler *()> get_deep_mind_logger)
 
void init (chainbase::database &db)
 
bool is_initialized () const
 
const protocol_feature_setget_protocol_feature_set () const
 
std::optional< digest_typeget_builtin_digest (builtin_protocol_feature_t feature_codename) const
 
const_iterator cbegin () const
 
const_iterator begin () const
 
const_iterator cend () const
 
const_iterator end () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator crend () const
 
const_reverse_iterator rend () const
 
const_iterator at_activation_ordinal (uint32_t activation_ordinal) const
 
const_iterator lower_bound (uint32_t block_num) const
 
const_iterator upper_bound (uint32_t block_num) const
 
bool is_builtin_activated (builtin_protocol_feature_t feature_codename, uint32_t current_block_num) const
 
void activate_feature (const digest_type &feature_digest, uint32_t current_block_num)
 
void popped_blocks_to (uint32_t block_num)
 

Protected Attributes

protocol_feature_set _protocol_feature_set
 
vector< protocol_feature_entry_activated_protocol_features
 
vector< builtin_protocol_feature_entry_builtin_protocol_features
 
size_t _head_of_builtin_activation_list = builtin_protocol_feature_entry::no_previous
 
bool _initialized = false
 

Friends

class const_iterator
 

Detailed Description

Definition at line 265 of file protocol_feature_manager.hpp.

Member Typedef Documentation

◆ const_reverse_iterator

Constructor & Destructor Documentation

◆ protocol_feature_manager()

sysio::chain::protocol_feature_manager::protocol_feature_manager ( protocol_feature_set && pfs,
std::function< deep_mind_handler *()> get_deep_mind_logger )

Definition at line 580 of file protocol_feature_manager.cpp.

583 :_protocol_feature_set( std::move(pfs) ), _get_deep_mind_logger(get_deep_mind_logger)
584 {
586 }
vector< builtin_protocol_feature_entry > _builtin_protocol_features
vector< protocol_feature_set_type::const_iterator > _recognized_builtin_protocol_features

Member Function Documentation

◆ activate_feature()

void sysio::chain::protocol_feature_manager::activate_feature ( const digest_type & feature_digest,
uint32_t current_block_num )

Definition at line 721 of file protocol_feature_manager.cpp.

723 {
724 SYS_ASSERT( is_initialized(), protocol_feature_exception, "protocol_feature_manager is not yet initialized" );
725
726 auto itr = _protocol_feature_set.find( feature_digest );
727
728 SYS_ASSERT( itr != _protocol_feature_set.end(), protocol_feature_exception,
729 "unrecognized protocol feature digest: ${digest}", ("digest", feature_digest) );
730
731 if( _activated_protocol_features.size() > 0 ) {
732 const auto& last = _activated_protocol_features.back();
733 SYS_ASSERT( last.activation_block_num <= current_block_num,
734 protocol_feature_exception,
735 "last protocol feature activation block num is ${last_activation_block_num} yet "
736 "attempting to activate protocol feature with a current block num of ${current_block_num}"
737 "protocol features is ${last_activation_block_num}",
738 ("current_block_num", current_block_num)
739 ("last_activation_block_num", last.activation_block_num)
740 );
741 }
742
743 SYS_ASSERT( itr->builtin_feature,
744 protocol_feature_exception,
745 "invariant failure: encountered non-builtin protocol feature which is not yet supported"
746 );
747
748 uint32_t indx = static_cast<uint32_t>( *itr->builtin_feature );
749
750 SYS_ASSERT( indx < _builtin_protocol_features.size(), protocol_feature_exception,
751 "invariant failure while trying to activate feature with digest '${digest}': "
752 "unsupported builtin_protocol_feature_t ${codename}",
753 ("digest", feature_digest)
754 ("codename", indx)
755 );
756
758 protocol_feature_exception,
759 "cannot activate already activated builtin feature with digest: ${digest}",
760 ("digest", feature_digest)
761 );
762
763 if (auto dm_logger = _get_deep_mind_logger()) {
764 dm_logger->on_activate_feature(*itr);
765 }
766
767 _activated_protocol_features.push_back( protocol_feature_entry{itr, current_block_num} );
769 _builtin_protocol_features[indx].activation_block_num = current_block_num;
771 }
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
vector< protocol_feature_entry > _activated_protocol_features
const_iterator find(const K &x) const
unsigned int uint32_t
Definition stdint.h:126
static constexpr uint32_t not_active
Here is the call graph for this function:
Here is the caller graph for this function:

◆ at_activation_ordinal()

protocol_feature_manager::const_iterator sysio::chain::protocol_feature_manager::at_activation_ordinal ( uint32_t activation_ordinal) const

Definition at line 673 of file protocol_feature_manager.cpp.

673 {
674 if( activation_ordinal >= _activated_protocol_features.size() ) {
675 return cend();
676 }
677
678 return const_iterator{this, static_cast<std::size_t>(activation_ordinal)};
679 }
Here is the call graph for this function:

◆ begin()

const_iterator sysio::chain::protocol_feature_manager::begin ( ) const
inline

Definition at line 351 of file protocol_feature_manager.hpp.

351{ return cbegin(); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cbegin()

protocol_feature_manager::const_iterator sysio::chain::protocol_feature_manager::cbegin ( ) const

Definition at line 664 of file protocol_feature_manager.cpp.

664 {
665 if( _activated_protocol_features.size() == 0 ) {
666 return cend();
667 } else {
668 return const_iterator( this, 0 );
669 }
670 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cend()

const_iterator sysio::chain::protocol_feature_manager::cend ( ) const
inline

Definition at line 353 of file protocol_feature_manager.hpp.

353{ return const_iterator( this ); }
Here is the caller graph for this function:

◆ crbegin()

const_reverse_iterator sysio::chain::protocol_feature_manager::crbegin ( ) const
inline

Definition at line 356 of file protocol_feature_manager.hpp.

356{ return std::make_reverse_iterator( cend() ); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ crend()

const_reverse_iterator sysio::chain::protocol_feature_manager::crend ( ) const
inline

Definition at line 359 of file protocol_feature_manager.hpp.

359{ return std::make_reverse_iterator( cbegin() ); }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ end()

const_iterator sysio::chain::protocol_feature_manager::end ( ) const
inline

Definition at line 354 of file protocol_feature_manager.hpp.

354{ return cend(); }
Here is the call graph for this function:

◆ get_builtin_digest()

std::optional< digest_type > sysio::chain::protocol_feature_manager::get_builtin_digest ( builtin_protocol_feature_t feature_codename) const
inline

Definition at line 344 of file protocol_feature_manager.hpp.

344 {
345 return _protocol_feature_set.get_builtin_digest( feature_codename );
346 }
std::optional< digest_type > get_builtin_digest(builtin_protocol_feature_t feature_codename) const
Here is the call graph for this function:

◆ get_protocol_feature_set()

const protocol_feature_set & sysio::chain::protocol_feature_manager::get_protocol_feature_set ( ) const
inline

Definition at line 342 of file protocol_feature_manager.hpp.

342{ return _protocol_feature_set; }
Here is the caller graph for this function:

◆ init()

void sysio::chain::protocol_feature_manager::init ( chainbase::database & db)

Definition at line 588 of file protocol_feature_manager.cpp.

588 {
589 SYS_ASSERT( !is_initialized(), protocol_feature_exception, "cannot initialize protocol_feature_manager twice" );
590
591
592 auto reset_initialized = fc::make_scoped_exit( [this]() { _initialized = false; } );
593 _initialized = true;
594
595 for( const auto& f : db.get<protocol_state_object>().activated_protocol_features ) {
596 activate_feature( f.feature_digest, f.activation_block_num );
597 }
598
599 reset_initialized.cancel();
600 }
const ObjectType & get(CompatibleKey &&key) const
void activate_feature(const digest_type &feature_digest, uint32_t current_block_num)
scoped_exit< Callback > make_scoped_exit(Callback &&c)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_builtin_activated()

bool sysio::chain::protocol_feature_manager::is_builtin_activated ( builtin_protocol_feature_t feature_codename,
uint32_t current_block_num ) const

Definition at line 711 of file protocol_feature_manager.cpp.

713 {
714 uint32_t indx = static_cast<uint32_t>( feature_codename );
715
716 if( indx >= _builtin_protocol_features.size() ) return false;
717
718 return (_builtin_protocol_features[indx].activation_block_num <= current_block_num);
719 }

◆ is_initialized()

bool sysio::chain::protocol_feature_manager::is_initialized ( ) const
inline

Definition at line 340 of file protocol_feature_manager.hpp.

340{ return _initialized; }
Here is the caller graph for this function:

◆ lower_bound()

protocol_feature_manager::const_iterator sysio::chain::protocol_feature_manager::lower_bound ( uint32_t block_num) const

Definition at line 682 of file protocol_feature_manager.cpp.

682 {
683 const auto begin = _activated_protocol_features.cbegin();
684 const auto end = _activated_protocol_features.cend();
685 auto itr = std::lower_bound( begin, end, block_num, []( const protocol_feature_entry& lhs, uint32_t rhs ) {
686 return lhs.activation_block_num < rhs;
687 } );
688
689 if( itr == end ) {
690 return cend();
691 }
692
693 return const_iterator{this, static_cast<std::size_t>(itr - begin)};
694 }
Here is the call graph for this function:

◆ popped_blocks_to()

void sysio::chain::protocol_feature_manager::popped_blocks_to ( uint32_t block_num)

Definition at line 773 of file protocol_feature_manager.cpp.

773 {
774 SYS_ASSERT( is_initialized(), protocol_feature_exception, "protocol_feature_manager is not yet initialized" );
775
778 if( e.activation_block_num <= block_num ) break;
779
782 e.activation_block_num = builtin_protocol_feature_entry::not_active;
783 }
784
785 while( _activated_protocol_features.size() > 0
786 && block_num < _activated_protocol_features.back().activation_block_num )
787 {
789 }
790 }
static constexpr size_t no_previous
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rbegin()

const_reverse_iterator sysio::chain::protocol_feature_manager::rbegin ( ) const
inline

Definition at line 357 of file protocol_feature_manager.hpp.

357{ return crbegin(); }
Here is the call graph for this function:

◆ rend()

const_reverse_iterator sysio::chain::protocol_feature_manager::rend ( ) const
inline

Definition at line 360 of file protocol_feature_manager.hpp.

360{ return crend(); }
Here is the call graph for this function:

◆ upper_bound()

protocol_feature_manager::const_iterator sysio::chain::protocol_feature_manager::upper_bound ( uint32_t block_num) const

Definition at line 697 of file protocol_feature_manager.cpp.

697 {
698 const auto begin = _activated_protocol_features.cbegin();
699 const auto end = _activated_protocol_features.cend();
700 auto itr = std::upper_bound( begin, end, block_num, []( uint32_t lhs, const protocol_feature_entry& rhs ) {
701 return lhs < rhs.activation_block_num;
702 } );
703
704 if( itr == end ) {
705 return cend();
706 }
707
708 return const_iterator{this, static_cast<std::size_t>(itr - begin)};
709 }
Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ const_iterator

friend class const_iterator
friend

Definition at line 334 of file protocol_feature_manager.hpp.

Member Data Documentation

◆ _activated_protocol_features

vector<protocol_feature_entry> sysio::chain::protocol_feature_manager::_activated_protocol_features
protected

Definition at line 391 of file protocol_feature_manager.hpp.

◆ _builtin_protocol_features

vector<builtin_protocol_feature_entry> sysio::chain::protocol_feature_manager::_builtin_protocol_features
protected

Definition at line 392 of file protocol_feature_manager.hpp.

◆ _head_of_builtin_activation_list

size_t sysio::chain::protocol_feature_manager::_head_of_builtin_activation_list = builtin_protocol_feature_entry::no_previous
protected

Definition at line 393 of file protocol_feature_manager.hpp.

◆ _initialized

bool sysio::chain::protocol_feature_manager::_initialized = false
protected

Definition at line 394 of file protocol_feature_manager.hpp.

◆ _protocol_feature_set

protocol_feature_set sysio::chain::protocol_feature_manager::_protocol_feature_set
protected

Definition at line 390 of file protocol_feature_manager.hpp.


The documentation for this class was generated from the following files: