-
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: Finished JRpc stuff. Need to check now finality dependency
- Loading branch information
1 parent
b601b74
commit 4a47722
Showing
12 changed files
with
177 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @file ChainApiFactory.hpp | ||
* @brief | ||
* @date 2024-03-05 | ||
* @author Henrique A. Klein ([email protected]) | ||
*/ | ||
#ifndef _CHAIN_API_FACTORY_HPP_ | ||
#define _CHAIN_API_FACTORY_HPP_ | ||
|
||
#include "api/service/chain/impl/chain_api_impl.hpp" | ||
#include "blockchain/block_header_repository.hpp" | ||
#include "blockchain/block_tree.hpp" | ||
|
||
class CComponentFactory; | ||
namespace sgns | ||
{ | ||
class ChainApiFactory | ||
{ | ||
public: | ||
std::shared_ptr<api::ChainApi> create() | ||
{ | ||
auto component_factory = SINGLETONINSTANCE( CComponentFactory ); | ||
auto result = component_factory->GetComponent( "BlockHeaderRepository", boost::none ); | ||
|
||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize BlockHeaderRepository first" ); | ||
} | ||
auto block_header_repo = std::dynamic_pointer_cast<blockchain::BlockHeaderRepository>( 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() ); | ||
|
||
return std::make_shared<api::ChainApiImpl>(block_header_repo, block_tree); | ||
} | ||
}; | ||
} | ||
|
||
#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,52 @@ | ||
/** | ||
* @file StateApiFactory.hpp | ||
* @brief | ||
* @date 2024-03-05 | ||
* @author Henrique A. Klein ([email protected]) | ||
*/ | ||
#ifndef _STATE_API_FACTORY_HPP_ | ||
#define _STATE_API_FACTORY_HPP_ | ||
|
||
#include "api/service/state/impl/state_api_impl.hpp" | ||
#include "blockchain/block_header_repository.hpp" | ||
#include "storage/trie/trie_storage.hpp" | ||
#include "blockchain/block_tree.hpp" | ||
|
||
class CComponentFactory; | ||
namespace sgns | ||
{ | ||
class StateApiFactory | ||
{ | ||
//TODO - Check removed runtime::Core from binaryen | ||
public: | ||
std::shared_ptr<api::StateApi> create() | ||
{ | ||
auto component_factory = SINGLETONINSTANCE( CComponentFactory ); | ||
auto result = component_factory->GetComponent( "BlockHeaderRepository", boost::none ); | ||
|
||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize BlockHeaderRepository first" ); | ||
} | ||
auto block_header_repo = std::dynamic_pointer_cast<blockchain::BlockHeaderRepository>( result.value() ); | ||
|
||
result = component_factory->GetComponent( "TrieStorage", boost::none ); | ||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize TrieStorage first" ); | ||
} | ||
auto trie_storage = std::dynamic_pointer_cast<storage::trie::TrieStorage>( 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() ); | ||
|
||
return std::make_shared<api::StateApiImpl>( block_header_repo, trie_storage, block_tree ); | ||
} | ||
}; | ||
} | ||
|
||
#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,38 @@ | ||
/** | ||
* @file SystemApiFactory.hpp | ||
* @brief | ||
* @date 2024-03-05 | ||
* @author Henrique A. Klein ([email protected]) | ||
*/ | ||
#ifndef _SYSTEM_API_FACTORY_HPP_ | ||
#define _SYSTEM_API_FACTORY_HPP_ | ||
|
||
#include "api/service/system/impl/system_api_impl.hpp" | ||
#include "blockchain/block_header_repository.hpp" | ||
#include "storage/trie/trie_storage.hpp" | ||
#include "blockchain/block_tree.hpp" | ||
|
||
class CComponentFactory; | ||
namespace sgns | ||
{ | ||
class SystemApiFactory | ||
{ | ||
//TODO - Check removed runtime::Core from binaryen | ||
public: | ||
std::shared_ptr<api::SystemApi> create() | ||
{ | ||
auto component_factory = SINGLETONINSTANCE( CComponentFactory ); | ||
auto result = component_factory->GetComponent( "ConfigurationStorage", boost::none ); | ||
|
||
if ( !result ) | ||
{ | ||
throw std::runtime_error( "Initialize ConfigurationStorage first" ); | ||
} | ||
auto config_storage = std::dynamic_pointer_cast<application::ConfigurationStorage>( result.value() ); | ||
|
||
return std::make_shared<api::SystemApiImpl>( config_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
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