-
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.
Merge branch 'dev_cleanup' into develop
- Loading branch information
Showing
134 changed files
with
2,498 additions
and
291 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
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,118 @@ | ||
/** | ||
* @file ApiServiceFactory.hpp | ||
* @brief | ||
* @date 2024-03-04 | ||
* @author Henrique A. Klein ([email protected]) | ||
*/ | ||
#ifndef _API_SERVICE_FACTORY_HPP_ | ||
#define _API_SERVICE_FACTORY_HPP_ | ||
|
||
#include "api/service/api_service.hpp" | ||
#include "application/app_state_manager.hpp" | ||
#include "api/transport/rpc_thread_pool.hpp" | ||
#include "api/transport/listener.hpp" | ||
#include "api/jrpc/jrpc_server.hpp" | ||
#include "api/jrpc/jrpc_processor.hpp" | ||
#include "subscription/subscriber.hpp" | ||
|
||
class CComponnetFactory; | ||
namespace sgns | ||
{ | ||
class ApiServiceFactory | ||
{ | ||
public: | ||
std::shared_ptr<api::ApiService> 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<application::AppStateManager>( result.value() ); | ||
auto app_state_manager = AppStateManagerFactory::create(); | ||
|
||
result = component_factory->GetComponent( "RpcThreadPool", boost::none ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize RpcThreadPool first" ); | ||
} | ||
auto rpc_thread_pool = std::dynamic_pointer_cast<api::RpcThreadPool>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "Listener", boost::make_optional( std::string( "http" ) ) ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize Http Listener first" ); | ||
} | ||
auto http_listener = std::dynamic_pointer_cast<api::Listener>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "Listener", boost::make_optional( std::string( "ws" ) ) ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize Ws Listener first" ); | ||
} | ||
auto ws_listener = std::dynamic_pointer_cast<api::Listener>( result.value() ); | ||
|
||
std::vector<std::shared_ptr<api::Listener>> listeners{ std::move( http_listener ), std::move( ws_listener ) }; | ||
|
||
result = component_factory->GetComponent( "JRpcServer", boost::none ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize JRpcServer first" ); | ||
} | ||
auto jrpc_server = std::dynamic_pointer_cast<api::JRpcServer>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "JRpcProcessor", boost::make_optional( std::string( "State" ) ) ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize StateJRpcProcessor first" ); | ||
} | ||
auto state_jrpc_proc = std::dynamic_pointer_cast<api::JRpcProcessor>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "JRpcProcessor", boost::make_optional( std::string( "Author" ) ) ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize AuthorJRpcProcessor first" ); | ||
} | ||
auto author_jrpc_proc = std::dynamic_pointer_cast<api::JRpcProcessor>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "JRpcProcessor", boost::make_optional( std::string( "Chain" ) ) ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize ChainJRpcProcessor first" ); | ||
} | ||
auto chain_jrpc_proc = std::dynamic_pointer_cast<api::JRpcProcessor>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "JRpcProcessor", boost::make_optional( std::string( "System" ) ) ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize SystemJRpcProcessor first" ); | ||
} | ||
auto system_jrpc_proc = std::dynamic_pointer_cast<api::JRpcProcessor>( result.value() ); | ||
|
||
std::vector<std::shared_ptr<api::JRpcProcessor>> processors{ | ||
state_jrpc_proc, // | ||
author_jrpc_proc, // | ||
chain_jrpc_proc, // | ||
system_jrpc_proc // | ||
}; | ||
|
||
//TODO - Not sute about this. Maybe also should be a singleton of sorts | ||
using SubscriptionEngineType = | ||
subscription::SubscriptionEngine<base::Buffer, std::shared_ptr<api::Session>, base::Buffer, primitives::BlockHash>; | ||
auto subscription_engine = std::make_shared<SubscriptionEngineType>(); | ||
|
||
return std::make_shared<api::ApiService>( // | ||
app_state_manager, // | ||
rpc_thread_pool, // | ||
listeners, // | ||
jrpc_server, // | ||
processors, // | ||
subscription_engine // | ||
); | ||
} | ||
}; | ||
} | ||
|
||
#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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* @file AuthorApiFactory.hpp | ||
* @brief | ||
* @date 2024-02-26 | ||
* @author Henrique A. Klein ([email protected]) | ||
*/ | ||
#ifndef _AUTHOR_API_FACTORY_HPP_ | ||
#define _AUTHOR_API_FACTORY_HPP_ | ||
|
||
#include "api/service/author/impl/author_api_impl.hpp" | ||
#include "integration/CComponentFactory.hpp" | ||
#include "transaction_pool/transaction_pool.hpp" | ||
#include "crypto/hasher.hpp" | ||
#include "network/extrinsic_gossiper.hpp" | ||
|
||
class AuthorApiFactory | ||
{ | ||
public: | ||
//TODO - Removed "validate_transaction from runtime::TaggedTransactionQueue". Need to replace it | ||
static std::shared_ptr<sgns::api::AuthorApi> create() | ||
{ | ||
auto component_factory = SINGLETONINSTANCE( CComponentFactory ); | ||
auto result = component_factory->GetComponent( "TransactionPool", boost::none ); | ||
|
||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize TransactionPool first" ); | ||
} | ||
auto trans_pool = std::dynamic_pointer_cast<sgns::transaction_pool::TransactionPool>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "Hasher", boost::none ); | ||
|
||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize Hasher first" ); | ||
} | ||
auto hasher = std::dynamic_pointer_cast<sgns::crypto::Hasher>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "ExtrinsicGossiper", boost::none ); | ||
|
||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize ExtrinsicGossiper first" ); | ||
} | ||
auto gossiper = std::dynamic_pointer_cast<sgns::network::ExtrinsicGossiper>( result.value() ); | ||
|
||
return std::make_shared<sgns::api::AuthorApiImpl>( trans_pool, hasher, gossiper ); | ||
} | ||
}; | ||
|
||
|
||
#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,66 @@ | ||
/** | ||
* @file AuthorityManagerFactory.hpp | ||
* @brief | ||
* @date 2024-03-04 | ||
* @author Henrique A. Klein ([email protected]) | ||
*/ | ||
#ifndef _AUTHORITY_MANAGER_FACTORY_HPP_ | ||
#define _AUTHORITY_MANAGER_FACTORY_HPP_ | ||
|
||
#include "verification/authority/impl/authority_manager_impl.hpp" | ||
#include "application/app_state_manager.hpp" | ||
#include "primitives/production_configuration.hpp" | ||
#include "blockchain/block_tree.hpp" | ||
#include "storage/buffer_map_types.hpp" | ||
|
||
class CComponentFactory; | ||
namespace sgns | ||
{ | ||
|
||
class AuthorityManagerFactory | ||
{ | ||
public: | ||
std::shared_ptr<authority::AuthorityManager> 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<application::AppStateManager>( result.value() ); | ||
auto app_state_manager = AppStateManagerFactory::create(); | ||
|
||
result = component_factory->GetComponent( "ProductionConfiguration", boost::none ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize ProductionConfiguration first" ); | ||
} | ||
auto prod_configuration = std::dynamic_pointer_cast<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<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<storage::BufferStorage>( result.value() ); | ||
|
||
return std::make_shared<authority::AuthorityManagerImpl>( // | ||
app_state_manager, // | ||
prod_configuration, // | ||
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,64 @@ | ||
/** | ||
* @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<application::AppStateManager>( result.value() ); | ||
auto app_state_manager = AppStateManagerFactory::create(); | ||
|
||
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 |
Oops, something went wrong.