app/integration/BlockValidatorFactory.hpp¶
Classes¶
| Name | |
|---|---|
| class | BlockValidatorFactory |
Detailed Description¶
Date: 2024-02-28 Henrique A. Klein ([email protected])
Source code¶
#ifndef _BLOCK_VALIDATOR_FACTORY_HPP_
#define _BLOCK_VALIDATOR_FACTORY_HPP_
#include "verification/validation/production_block_validator.hpp"
#include "singleton/CComponentFactory.hpp"
#include "blockchain/block_tree.hpp"
#include "crypto/hasher.hpp"
#include "crypto/sr25519_provider.hpp"
class BlockValidatorFactory
{
public:
//TODO - Check the removal of TaggedTransactionQueue
static std::shared_ptr<sgns::verification::BlockValidator> create()
{
auto component_factory = SINGLETONINSTANCE( CComponentFactory );
auto 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( "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( "VRFProvider", boost::none );
if ( !result )
{
throw std::runtime_error( "Initialize VRFProvider first" );
}
auto vrf_provider = std::dynamic_pointer_cast<sgns::crypto::VRFProvider>( result.value() );
result = component_factory->GetComponent( "SR25519Provider", boost::none );
if ( !result )
{
throw std::runtime_error( "Initialize SR25519Provider first" );
}
auto sr25519_provider = std::dynamic_pointer_cast<sgns::crypto::SR25519Provider>( result.value() );
return std::make_shared<sgns::verification::ProductionBlockValidator>( //
block_tree, //
hasher, //
vrf_provider, //
sr25519_provider //
);
}
};
#endif
Updated on 2026-03-04 at 13:10:44 -0800