Skip to content

Commit

Permalink
#121 add reload functions to the interface
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-modelist-dev committed Feb 14, 2019
1 parent 088bdc7 commit 0c82317
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions keychain_lib/include/keychain_lib/keyfile_singleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ class keyfile_singleton
void flush_keyfile_impl(const value_t& keyfile_data) const;
void flush_logrecords_impl(const prim_key_type& key, const log_records_t& log_records) const;

void keydata_initialize();
void signlog_initialize();

void print_exception (const boost::filesystem::path& filename, fc_light::exception &er);
public:
static keyfile_singleton& instance();

void keydata_load();
void signlog_load();

using iterator = keyfile_map_t::iterator; //primary_index
using const_iterator = keyfile_map_t::const_iterator; //primary_index

Expand Down
18 changes: 9 additions & 9 deletions keychain_lib/src/keyfile_singleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const keyfile_singleton::key_random_access_index_type& keyfile_singleton::random
return m_keydata_map.get<keyfiles_map::key_random_access_tag>();
}

void keyfile_singleton::keydata_initialize()
void keyfile_singleton::keydata_load()
{
// auto curdir = bfs::current_path();

Expand Down Expand Up @@ -73,7 +73,7 @@ void keyfile_singleton::keydata_initialize()
});
}

void keyfile_singleton::signlog_initialize()
void keyfile_singleton::signlog_load()
{
// auto curdir = bfs::current_path();
bfs::path dir(SIGN_LOGS_DEFAULT_PATH_);
Expand Down Expand Up @@ -118,8 +118,8 @@ keyfile_singleton::keyfile_singleton()

try
{
keydata_initialize();
signlog_initialize();
keydata_load();
signlog_load();
}
FC_LIGHT_RETHROW_EXCEPTIONS(log_level::error, "Cannot create keyfiles map")
}
Expand Down Expand Up @@ -179,7 +179,7 @@ const keyfile_format::keyfile_t& keyfile_singleton::operator[](size_t index)
{
if(stop == true)
FC_LIGHT_THROW_EXCEPTION(fc_light::out_of_range_exception, "index = ${ind_}", ("ind_", index));
keydata_initialize();
keydata_load();
bool stop = false;
}
return ra_ind[index];
Expand All @@ -195,7 +195,7 @@ const keyfile_format::keyfile_t& keyfile_singleton::operator[](const keyfile_sin
{
if(stop == true)
FC_LIGHT_THROW_EXCEPTION(fc_light::key_not_found_exception, "Private key is not exist public = ${key_}", ("key_", key));
keydata_initialize();
keydata_load();
stop = true;
}
return *it;
Expand All @@ -213,7 +213,7 @@ const keyfile_format::keyfile_t& keyfile_singleton::operator[](const keyfile_sin
if(stop == true)
FC_LIGHT_THROW_EXCEPTION(fc_light::key_not_found_exception, "Private key is not found by keyname = ${name_}",
("name_", key));
keydata_initialize();
keydata_load();
stop = true;
}
return *it;
Expand Down Expand Up @@ -308,7 +308,7 @@ void keyfile_singleton::flush_all() const

const keyfile_singleton::log_random_access_index_type& keyfile_singleton::get_logs(const dev::Public& pkey)
{
signlog_initialize();//NOTE: it may be slowly, using sqlite and triggers is more preferable
signlog_load();//NOTE: it may be slowly, using sqlite and triggers is more preferable
auto it = m_signlog_map.find(pkey);
if (it == m_signlog_map.end())
FC_LIGHT_THROW_EXCEPTION(fc_light::file_not_found_exception, "Public_key: ${PKEY}", ("PKEY", pkey));
Expand All @@ -318,7 +318,7 @@ const keyfile_singleton::log_random_access_index_type& keyfile_singleton::get_lo

const keyfile_singleton::log_date_index_type& keyfile_singleton::get_logs_date_ordered(const dev::Public& pkey)
{
signlog_initialize();//NOTE: it may be slowly, using sqlite and triggers is more preferable
signlog_load();//NOTE: it may be slowly, using sqlite and triggers is more preferable
auto it = m_signlog_map.find(pkey);
if (it == m_signlog_map.end())
FC_LIGHT_THROW_EXCEPTION(fc_light::file_not_found_exception, "Public_key: ${PKEY}", ("PKEY", pkey));
Expand Down

0 comments on commit 0c82317

Please sign in to comment.