Moved the frontier LMDB table handler to its store class

This commit is contained in:
Thiago Silva 2022-04-11 14:52:43 -03:00
commit 23e5d96579
No known key found for this signature in database
GPG key ID: 034303EB8F453169
3 changed files with 12 additions and 10 deletions

View file

@ -2,6 +2,8 @@
#include <nano/secure/store.hpp> #include <nano/secure/store.hpp>
#include <lmdb/libraries/liblmdb/lmdb.h>
namespace nano namespace nano
{ {
namespace lmdb namespace lmdb
@ -9,6 +11,9 @@ namespace lmdb
class store; class store;
class frontier_store : public nano::frontier_store class frontier_store : public nano::frontier_store
{ {
private:
nano::lmdb::store & store;
public: public:
frontier_store (nano::lmdb::store & store); frontier_store (nano::lmdb::store & store);
void put (nano::write_transaction const &, nano::block_hash const &, nano::account const &) override; void put (nano::write_transaction const &, nano::block_hash const &, nano::account const &) override;
@ -19,8 +24,11 @@ namespace lmdb
nano::store_iterator<nano::block_hash, nano::account> end () const override; nano::store_iterator<nano::block_hash, nano::account> end () const override;
void for_each_par (std::function<void (nano::read_transaction const &, nano::store_iterator<nano::block_hash, nano::account>, nano::store_iterator<nano::block_hash, nano::account>)> const & action_a) const override; void for_each_par (std::function<void (nano::read_transaction const &, nano::store_iterator<nano::block_hash, nano::account>, nano::store_iterator<nano::block_hash, nano::account>)> const & action_a) const override;
private: /**
nano::lmdb::store & store; * Maps head block to owning account
* nano::block_hash -> nano::account
*/
MDB_dbi frontiers_handle{ 0 };
}; };
} }
} }

View file

@ -210,7 +210,7 @@ nano::mdb_txn_callbacks nano::lmdb::store::create_txn_callbacks () const
void nano::lmdb::store::open_databases (bool & error_a, nano::transaction const & transaction_a, unsigned flags) void nano::lmdb::store::open_databases (bool & error_a, nano::transaction const & transaction_a, unsigned flags)
{ {
error_a |= mdb_dbi_open (env.tx (transaction_a), "frontiers", flags, &frontiers_handle) != 0; error_a |= mdb_dbi_open (env.tx (transaction_a), "frontiers", flags, &frontier_store.frontiers_handle) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "unchecked", flags, &unchecked_handle) != 0; error_a |= mdb_dbi_open (env.tx (transaction_a), "unchecked", flags, &unchecked_handle) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "online_weight", flags, &online_weight_handle) != 0; error_a |= mdb_dbi_open (env.tx (transaction_a), "online_weight", flags, &online_weight_handle) != 0;
error_a |= mdb_dbi_open (env.tx (transaction_a), "meta", flags, &meta_handle) != 0; error_a |= mdb_dbi_open (env.tx (transaction_a), "meta", flags, &meta_handle) != 0;
@ -861,7 +861,7 @@ MDB_dbi nano::lmdb::store::table_to_dbi (tables table_a) const
switch (table_a) switch (table_a)
{ {
case tables::frontiers: case tables::frontiers:
return frontiers_handle; return frontier_store.frontiers_handle;
case tables::accounts: case tables::accounts:
return accounts_handle; return accounts_handle;
case tables::blocks: case tables::blocks:

View file

@ -94,12 +94,6 @@ namespace lmdb
public: public:
nano::mdb_env env; nano::mdb_env env;
/**
* Maps head block to owning account
* nano::block_hash -> nano::account
*/
MDB_dbi frontiers_handle{ 0 };
/** /**
* Maps account v1 to account information, head, rep, open, balance, timestamp and block count. (Removed) * Maps account v1 to account information, head, rep, open, balance, timestamp and block count. (Removed)
* nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t * nano::account -> nano::block_hash, nano::block_hash, nano::block_hash, nano::amount, uint64_t, uint64_t