2017-08-21 19:49:21 +00:00
|
|
|
#pragma once
|
2016-11-17 20:07:59 +00:00
|
|
|
|
2017-08-21 19:49:21 +00:00
|
|
|
#include "lmdb.h"
|
2017-04-06 14:33:28 +00:00
|
|
|
#include "libp2p/db/datastore.h"
|
2016-11-17 20:07:59 +00:00
|
|
|
|
2017-08-21 19:49:21 +00:00
|
|
|
static const char* DATASTORE_DB = "DATASTORE";
|
|
|
|
static const char* JOURNAL_DB = "JOURNAL";
|
|
|
|
|
|
|
|
struct lmdb_trans_cursor {
|
|
|
|
MDB_txn* transaction;
|
|
|
|
MDB_cursor* cursor;
|
|
|
|
};
|
|
|
|
|
2016-11-17 20:07:59 +00:00
|
|
|
/***
|
|
|
|
* Places the LMDB methods into the datastore's function pointers
|
|
|
|
* @param datastore the datastore to fill
|
|
|
|
* @returns true(1) on success;
|
|
|
|
*/
|
|
|
|
int repo_fsrepo_lmdb_cast(struct Datastore* datastore);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Open an lmdb database with the given parameters.
|
|
|
|
* Note: for now, the parameters are not used
|
|
|
|
* @param argc number of parameters in the following array
|
|
|
|
* @param argv an array of parameters
|
|
|
|
*/
|
|
|
|
int repo_fsrepro_lmdb_open(int argc, char** argv, struct Datastore* datastore);
|
|
|
|
|
|
|
|
/***
|
|
|
|
* Close an LMDB database
|
|
|
|
* NOTE: for now, argc and argv are not used
|
|
|
|
* @param argc number of parameters in the argv array
|
|
|
|
* @param argv parameters to be passed in
|
|
|
|
* @param datastore the datastore struct that contains information about the opened database
|
|
|
|
*/
|
2016-12-01 18:08:30 +00:00
|
|
|
int repo_fsrepo_lmdb_close(struct Datastore* datastore);
|
2016-11-17 20:07:59 +00:00
|
|
|
|
2016-11-30 16:46:41 +00:00
|
|
|
/***
|
|
|
|
* Creates the directory
|
|
|
|
* @param datastore contains the path that needs to be created
|
|
|
|
* @returns true(1) on success
|
|
|
|
*/
|
|
|
|
int repo_fsrepo_lmdb_create_directory(struct Datastore* datastore);
|