Ledger maintenance refactor. (#130)

* Added ledger namespace.
* Thread-safe lcl access and update.
* Refactored history sync and serving into a thread.
* Restructured ledger cache item.
This commit is contained in:
Ravin Perera
2020-10-08 22:25:47 +05:30
committed by GitHub
parent 31048f55b8
commit cb4d0c4f59
30 changed files with 945 additions and 754 deletions

View File

@@ -11,7 +11,8 @@
#include "usr/usr.hpp"
#include "usr/read_req.hpp"
#include "p2p/p2p.hpp"
#include "cons/cons.hpp"
#include "consensus.hpp"
#include "ledger.hpp"
#include "hpfs/hpfs.hpp"
#include "state/state_sync.hpp"
#include "state/state_serve.hpp"
@@ -67,7 +68,8 @@ int parse_cmd(int argc, char **argv)
*/
void deinit()
{
cons::deinit();
consensus::deinit();
ledger::deinit();
state_sync::deinit();
state_serve::deinit();
read_req::deinit();
@@ -191,7 +193,7 @@ int main(int argc, char **argv)
LOG_INFO << "Public key: " << conf::cfg.pubkeyhex.substr(2); // Public key without 'ed' prefix.
if (hpfs::init() != 0 || p2p::init() != 0 || usr::init() != 0 || read_req::init() != 0 ||
state_serve::init() != 0 || state_sync::init() != 0 || cons::init() != 0)
state_serve::init() != 0 || state_sync::init() != 0 || ledger::init() || consensus::init() != 0)
{
deinit();
return -1;
@@ -201,7 +203,7 @@ int main(int argc, char **argv)
signal(SIGINT, &sigint_handler);
// Wait until consensus thread finishes.
cons::wait();
consensus::wait();
// deinit() here only gets called when there is an error in consensus.
// If not deinit in the sigint handler is called when a SIGINT is received.