Skip to content

Commit

Permalink
Feat: Adding defintions that are not yet compiling [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
henriqueaklein committed Feb 25, 2024
1 parent 149a11d commit 10b6079
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 16 deletions.
28 changes: 18 additions & 10 deletions app/integration/BlockTreeFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,36 @@
*/
#ifndef _BLOCK_TREE_FACTORY_HPP_
#define _BLOCK_TREE_FACTORY_HPP_

#include "integration/CComponentFactory.hpp"
class BlockTreeFactory
{
public:
static std::shared_ptr<sgns::blockchain::BlockTree> create( const std::string &db_path )
{
auto header_repo_ = std::make_shared<sgns::blockchain::KeyValueBlockHeaderRepository>( BufferStorageFactory::create( "rocksdb", db_path ),
HasherFactory::create() );

auto result = sgns::blockchain::BlockTreeImpl::create( //
header_repo_, //
);
auto component_factory = SINGLETONINSTANCE( CComponentFactory );
auto result = component_factory->GetComponent( "BlockHeaderRepository", boost::none );

if ( result )
if ( !result )
{
return result.value();
throw std::runtime_error( "Initialize BlockHeaderRepository first" );
}
auto blk_header = std::dynamic_pointer_cast<sgns::blockchain::BlockHeaderRepository>( result.value() );

auto result = sgns::blockchain::BlockTreeImpl::create( //
blk_header.value(), //
);
else
{
throw std::runtime_error( "BlockTree not created" );
}
}
}

#endif
// outcome::result<std::shared_ptr<BlockTreeImpl>> BlockTreeImpl::create(
// std::shared_ptr<BlockHeaderRepository> header_repo,
// std::shared_ptr<BlockStorage> storage,
// const primitives::BlockId &last_finalized_block,
// std::shared_ptr<network::ExtrinsicObserver> extrinsic_observer,
// std::shared_ptr<crypto::Hasher> hasher) {

#endif
50 changes: 44 additions & 6 deletions app/integration/ProductionFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,58 @@
#ifndef _PRODUCTION_FACTORY_HPP_
#define _PRODUCTION_FACTORY_HPP_

#include "integration/CComponentFactory.hpp"
#include "application/app_state_manager.hpp"

class ProductionFactory
{
public:
static std::shared_ptr<sgns::verification::Production> create()
static std::shared_ptr<sgns::verification::Production> create( const std::string &db_path )
{
auto component_factory = SINGLETONINSTANCE( CComponentFactory );

BlockExecutor
return std::make_shared<verification::ProductionImpl>( //
AppStateManagerFactory::create(),//
ProductionLotteryFactory::create(),//
auto maybe_app_st_manager = component_factory->GetComponent( "AppStateManager", boost::none );
if ( !maybe_app_st_manager )
{
throw std::runtime_error( "Initialize AppStateManager first" );
}
auto app_st_manager = std::dynamic_pointer_cast<sgns::application::AppStateManager>( maybe_app_st_manager.value() );

auto maybe_prod_lottery = component_factory->GetComponent( "ProductionLottery", boost::none );
if ( !maybe_prod_lottery )
{
throw std::runtime_error( "Initialize ProductionLottery first" );
}
auto prod_lottery = std::dynamic_pointer_cast<sgns::verification::ProductionLottery>( maybe_prod_lottery.value() );

auto maybe_block_executor = component_factory->GetComponent( "BlockExecutor", boost::none );
if ( !maybe_block_executor )
{
throw std::runtime_error( "Initialize BlockExecutor first" );
}
auto block_executor = std::dynamic_pointer_cast<sgns::verification::BlockExecutor>( maybe_block_executor.value() );

);
return std::make_shared<verification::ProductionImpl>( //
app_st_manager, //
prod_lottery, //
block_executor, //
);

// BlockExecutor(std::shared_ptr<blockchain::BlockTree> block_tree,
// std::shared_ptr<primitives::ProductionConfiguration> configuration,
// std::shared_ptr<ProductionSynchronizer> production_synchronizer,
// std::shared_ptr<BlockValidator> block_validator,
// std::shared_ptr<EpochStorage> epoch_storage,
// std::shared_ptr<transaction_pool::TransactionPool> tx_pool,
// std::shared_ptr<crypto::Hasher> hasher,
// std::shared_ptr<authority::AuthorityUpdateObserver>
// authority_update_observer);

/**
* std::shared_ptr<BlockExecutor> block_executor,
ProductionImpl(std::shared_ptr<application::AppStateManager> app_state_manager,
std::shared_ptr<ProductionLottery> lottery,
std::shared_ptr<BlockExecutor> block_executor,
std::shared_ptr<storage::trie::TrieStorage> trie_db,
std::shared_ptr<EpochStorage> epoch_storage,
std::shared_ptr<primitives::ProductionConfiguration> configuration,
Expand All @@ -34,6 +71,7 @@ class ProductionFactory
std::shared_ptr<crypto::Hasher> hasher,
std::unique_ptr<clock::Timer> timer,
std::shared_ptr<authority::AuthorityUpdateObserver>
authority_update_observer);
*/
}
};
Expand Down

0 comments on commit 10b6079

Please sign in to comment.