-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Updating classes to new design. Stripping runtime mentions
- Loading branch information
1 parent
1b1f076
commit 900e0e6
Showing
22 changed files
with
232 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/** | ||
* @file AuthorityUpdateObserverFactory.hpp | ||
* @brief | ||
* @date 2024-02-29 | ||
* @author Henrique A. Klein ([email protected]) | ||
*/ | ||
#ifndef _AUTHORITY_UPDATE_OBSERVER_FACTORY_HPP_ | ||
#define _AUTHORITY_UPDATE_OBSERVER_FACTORY_HPP_ | ||
|
||
#include "verification/authority/impl/authority_manager_impl.hpp" | ||
#include "integration/CComponentFactory.hpp" | ||
#include "application/app_state_manager.hpp" | ||
#include "blockchain/block_tree.hpp" | ||
#include "storage/buffer_map_types.hpp" | ||
|
||
class AuthorityUpdateObserverFactory | ||
{ | ||
public: | ||
static std::shared_ptr<sgns::authority::AuthorityUpdateObserver> create() | ||
{ | ||
auto component_factory = SINGLETONINSTANCE( CComponentFactory ); | ||
auto result = component_factory->GetComponent( "AppStateManager", boost::none ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize AppStateManager first" ); | ||
} | ||
|
||
auto app_state_manager = std::dynamic_pointer_cast<sgns::application::AppStateManager>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "ProductionConfiguration", boost::none ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize ProductionConfiguration first" ); | ||
} | ||
|
||
auto prod_config = std::dynamic_pointer_cast<sgns::primitives::ProductionConfiguration>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "BlockTree", boost::none ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize BlockTree first" ); | ||
} | ||
|
||
auto block_tree = std::dynamic_pointer_cast<sgns::blockchain::BlockTree>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "BufferStorage", boost::make_optional(std::string("rocksdb")) ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize BufferStorage first" ); | ||
} | ||
|
||
auto buff_storage = std::dynamic_pointer_cast<sgns::storage::BufferStorage>( result.value() ); | ||
|
||
return std::make_shared<sgns::authority::AuthorityManagerImpl>( // | ||
app_state_manager, // | ||
prod_config, // | ||
block_tree, // | ||
buff_storage // | ||
); | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* @file EpochStorageFactory.hpp | ||
* @brief | ||
* @date 2024-02-29 | ||
* @author Henrique A. Klein ([email protected]) | ||
*/ | ||
#ifndef _EPOCH_STORAGE_HPP_ | ||
#define _EPOCH_STORAGE_HPP_ | ||
#include "verification/production/impl/epoch_storage_impl.hpp" | ||
#include "integration/CComponentFactory.hpp" | ||
#include "storage/buffer_map_types.hpp" | ||
|
||
class EpochStorageFactory | ||
{ | ||
public: | ||
static std::shared_ptr<sgns::verification::EpochStorage> create() | ||
{ | ||
auto component_factory = SINGLETONINSTANCE( CComponentFactory ); | ||
|
||
auto result = component_factory->GetComponent( "BufferStorage", boost::make_optional(std::string("rocksdb"))); | ||
|
||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize BufferStorage first" ); | ||
} | ||
auto buffer_storage = std::dynamic_pointer_cast<sgns::storage::BufferStorage>( result.value() ); | ||
|
||
return std::make_shared<sgns::verification::EpochStorageImpl>( buffer_storage ); | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @file ProposerFactory.hpp | ||
* @brief | ||
* @date 2024-02-29 | ||
* @author Henrique A. Klein ([email protected]) | ||
*/ | ||
#ifndef _PROPOSER_FACTORY_HPP_ | ||
#define _PROPOSER_FACTORY_HPP_ | ||
|
||
#include "authorship/impl/proposer_impl.hpp" | ||
#include "integration/CComponentFactory.hpp" | ||
#include "transaction_pool/transaction_pool.hpp" | ||
|
||
class ProposerFactory | ||
{ | ||
public: | ||
static std::shared_ptr<sgns::authorship::Proposer> create() | ||
{ | ||
//TODO - Removed runtime::BlockBuilder because of binaryen dependecy | ||
auto component_factory = SINGLETONINSTANCE( CComponentFactory ); | ||
|
||
auto result = component_factory->GetComponent( "BlockBuilderFactory", boost::none ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize BlockBuilderFactory first" ); | ||
} | ||
auto block_builder_factory = std::dynamic_pointer_cast<sgns::authorship::BlockBuilderFactory>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "TransactionPool", boost::none ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize TransactionPool first" ); | ||
} | ||
auto transaction_pool = std::dynamic_pointer_cast<sgns::transaction_pool::TransactionPool>( result.value() ); | ||
|
||
return std::make_shared<sgns::authorship::ProposerImpl>( block_builder_factory, transaction_pool); | ||
} | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @file SR25519ProviderFactory.hpp | ||
* @brief | ||
* @date 2024-02-28 | ||
* @author Henrique A. Klein ([email protected]) | ||
*/ | ||
#ifndef _SR25519_PROVIDER_FACTORY_HPP_ | ||
#define _SR25519_PROVIDER_FACTORY_HPP_ | ||
|
||
#include "crypto/sr25519/sr25519_provider_impl.hpp" | ||
#include "crypto/random_generator/boost_generator.hpp" | ||
|
||
class SR25519ProviderFactory | ||
{ | ||
public: | ||
static std::shared_ptr<sgns::crypto::SR25519Provider> create() | ||
{ | ||
return std::make_shared<sgns::crypto::SR25519ProviderImpl>(std::make_shared<sgns::crypto::BoostRandomGenerator>()); | ||
} | ||
}; | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.