hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
irohad.cpp File Reference
#include <chrono>
#include <csignal>
#include <fstream>
#include <memory>
#include <thread>
#include <vector>
#include <gflags/gflags.h>
#include <grpc++/grpc++.h>
#include "ametsuchi/data_models/data_model.hpp"
#include "ametsuchi/data_models/data_model_python.hpp"
#include "ametsuchi/storage.hpp"
#include "backend/protobuf/common_objects/proto_common_objects_factory.hpp"
#include "common/bind.hpp"
#include "common/files.hpp"
#include "common/irohad_version.hpp"
#include "common/result.hpp"
#include "crypto/keys_manager_impl.hpp"
#include "logger/logger.hpp"
#include "logger/logger_manager.hpp"
#include "main/application.hpp"
#include "main/impl/pg_connection_init.hpp"
#include "main/iroha_conf_literals.hpp"
#include "main/iroha_conf_loader.hpp"
#include "main/raw_block_loader.hpp"
#include "util/status_notifier.hpp"
#include "util/utility_service.hpp"
#include "validators/field_validator.hpp"
Include dependency graph for irohad.cpp:

Functions

bool validate_config (const char *flag_name, std::string const &path)
 
bool validate_keypair_name (const char *flag_name, std::string const &path)
 
 DEFINE_string (config, "", "Specify iroha provisioning path.")
 
 DEFINE_validator (config, &validate_config)
 
 DEFINE_string (genesis_block, "", "Specify file with initial block")
 
 DEFINE_string (keypair_name, "", "Specify name of .pub and .priv files")
 
 DEFINE_validator (keypair_name, &validate_keypair_name)
 
 DEFINE_bool (overwrite_ledger, false, "Overwrite ledger data if existing")
 
 DEFINE_bool (reuse_state, false, "Try to reuse existing state data at startup.")
 
static bool validateVerbosity (const char *flagname, const std::string &val)
 
 DEFINE_string (verbosity, kLogSettingsFromConfigFile, "Log verbosity")
 Verbosity flag for spdlog configuration. More...
 
 DEFINE_validator (verbosity, &validateVerbosity)
 
std::lock_guard< std::mutex > shutdown_wait_locker (shutdown_wait_mutex)
 
void initUtilityService (const IrohadConfig::UtilityService &config, iroha::utility_service::UtilityService::ShutdownCallback shutdown_callback, logger::LoggerManagerTreePtr log_manager)
 
logger::LoggerManagerTreePtr getDefaultLogManager ()
 
std::shared_ptr< shared_model::interface::CommonObjectsFactorygetCommonObjectsFactory ()
 
std::vector< std::unique_ptr< iroha::ametsuchi::DataModel > > makeDataModels (std::vector< IrohadConfig::DataModelModule > const &config)
 
int main (int argc, char *argv[])
 

Variables

static const std::string kListenIp = "0.0.0.0"
 
static const std::string kLogSettingsFromConfigFile = "config_file"
 
static const uint32_t kMstExpirationTimeDefault = 1440
 
static const uint32_t kMaxRoundsDelayDefault = 3000
 
static const uint32_t kStaleStreamMaxRoundsDefault = 2
 
static const std::string kDefaultWorkingDatabaseName {"iroha_default"}
 
static const std::chrono::milliseconds kExitCheckPeriod {1000}
 
std::sig_atomic_t caught_signal = 0
 
std::promise< void > exit_requested
 
std::shared_ptr< iroha::utility_service::UtilityServiceutility_service
 
std::unique_ptr< iroha::network::ServerRunnerutility_server
 
std::mutex shutdown_wait_mutex
 
std::shared_ptr< iroha::utility_service::StatusNotifierdaemon_status_notifier
 

Function Documentation

◆ DEFINE_bool() [1/2]

DEFINE_bool ( overwrite_ledger  ,
false  ,
"Overwrite ledger data if existing"   
)

Creating boolean flag for overwriting already existing block storage

Here is the caller graph for this function:

◆ DEFINE_bool() [2/2]

DEFINE_bool ( reuse_state  ,
false  ,
"Try to reuse existing state data at startup."   
)

◆ DEFINE_string() [1/4]

DEFINE_string ( config  ,
""  ,
"Specify iroha provisioning path."   
)

Creating input argument for the configuration file location.

Here is the caller graph for this function:

◆ DEFINE_string() [2/4]

DEFINE_string ( genesis_block  ,
""  ,
"Specify file with initial block"   
)

Creating input argument for the genesis block file location.

◆ DEFINE_string() [3/4]

DEFINE_string ( keypair_name  ,
""  ,
"Specify name of .pub and .priv files"   
)

Creating input argument for the keypair files location.

◆ DEFINE_string() [4/4]

DEFINE_string ( verbosity  ,
kLogSettingsFromConfigFile  ,
"Log verbosity"   
)

Verbosity flag for spdlog configuration.

◆ DEFINE_validator() [1/3]

DEFINE_validator ( config  ,
validate_config 
)

Registering validator for the configuration file location.

Here is the caller graph for this function:

◆ DEFINE_validator() [2/3]

DEFINE_validator ( keypair_name  ,
validate_keypair_name 
)

Registering validator for the keypair files location.

◆ DEFINE_validator() [3/3]

DEFINE_validator ( verbosity  ,
validateVerbosity 
)

◆ getCommonObjectsFactory()

std::shared_ptr<shared_model::interface::CommonObjectsFactory> getCommonObjectsFactory ( )
Here is the caller graph for this function:

◆ getDefaultLogManager()

logger::LoggerManagerTreePtr getDefaultLogManager ( )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ initUtilityService()

void initUtilityService ( const IrohadConfig::UtilityService config,
iroha::utility_service::UtilityService::ShutdownCallback  shutdown_callback,
logger::LoggerManagerTreePtr  log_manager 
)
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

if there are any blocks in blockstore, then true

genesis block file is specified as launch parameter

overwrite ledger flag was set as launch parameter

Here is the call graph for this function:

◆ makeDataModels()

std::vector<std::unique_ptr<iroha::ametsuchi::DataModel> > makeDataModels ( std::vector< IrohadConfig::DataModelModule > const &  config)

◆ shutdown_wait_locker()

std::lock_guard<std::mutex> shutdown_wait_locker ( shutdown_wait_mutex  )

◆ validate_config()

bool validate_config ( const char *  flag_name,
std::string const &  path 
)

Gflag validator. Validator for the configuration file path input argument. Path is considered to be valid if it is not empty.

Parameters
flag_name- flag name. Must be 'config' in this case
path- file name. Should be path to the config file
Returns
true if argument is valid
Here is the caller graph for this function:

◆ validate_keypair_name()

bool validate_keypair_name ( const char *  flag_name,
std::string const &  path 
)

Gflag validator. Validator for the keypair files path input argument. Path is considered to be valid if it is not empty.

Parameters
flag_name- flag name. Must be 'keypair_name' in this case
path- file name. Should be path to the keypair files
Returns
true if argument is valid
Here is the call graph for this function:

◆ validateVerbosity()

static bool validateVerbosity ( const char *  flagname,
const std::string &  val 
)
static
Here is the call graph for this function:

Variable Documentation

◆ caught_signal

std::sig_atomic_t caught_signal = 0

◆ daemon_status_notifier

std::shared_ptr<iroha::utility_service::StatusNotifier> daemon_status_notifier
Initial value:
=
std::make_shared<iroha::utility_service::StatusNotifier>()

◆ exit_requested

std::promise<void> exit_requested

◆ kDefaultWorkingDatabaseName

const std::string kDefaultWorkingDatabaseName {"iroha_default"}
static

◆ kExitCheckPeriod

const std::chrono::milliseconds kExitCheckPeriod {1000}
static

◆ kListenIp

const std::string kListenIp = "0.0.0.0"
static

Copyright Soramitsu Co., Ltd. All Rights Reserved. SPDX-License-Identifier: Apache-2.0

◆ kLogSettingsFromConfigFile

const std::string kLogSettingsFromConfigFile = "config_file"
static

◆ kMaxRoundsDelayDefault

const uint32_t kMaxRoundsDelayDefault = 3000
static

◆ kMstExpirationTimeDefault

const uint32_t kMstExpirationTimeDefault = 1440
static

◆ kStaleStreamMaxRoundsDefault

const uint32_t kStaleStreamMaxRoundsDefault = 2
static

◆ shutdown_wait_mutex

std::mutex shutdown_wait_mutex

◆ utility_server

std::unique_ptr<iroha::network::ServerRunner> utility_server

◆ utility_service

std::shared_ptr<iroha::utility_service::UtilityService> utility_service