Files
hpcore/src/state/state_common.cpp
Ravin Perera 202a6a2715 Ledger and state sync improvements. (#143)
* Increased stage time window.
* Introduced central state tracker.
* Used shared mutex for target state update.
* Refactored lcl and state sync checks in consensus.
* lcl/state sync loop wait time improvements.
2020-11-04 16:01:10 +05:30

28 lines
709 B
C++

#include "state_common.hpp"
#include "../hpfs/hpfs.hpp"
#include "../hplog.hpp"
namespace state_common
{
state_context ctx;
/**
* Get the contract state hash.
*/
int init()
{
hpfs::h32 initial_state;
if (hpfs::start_fs_session(conf::ctx.state_rw_dir) == -1 ||
hpfs::get_hash(initial_state, conf::ctx.state_rw_dir, "/") == -1 ||
hpfs::stop_fs_session(conf::ctx.state_rw_dir) == -1)
{
LOG_ERROR << "Failed to get initial state hash.";
return -1;
}
ctx.set_state(initial_state);
LOG_INFO << "Initial state: " << initial_state;
return 0;
}
} // namespace state_common