The beginnings of datastore
A lot of code cleanup, plus beginning the implementation of a datastore.
This commit is contained in:
parent
0b765481da
commit
c64a700223
28 changed files with 1169 additions and 132 deletions
|
@ -74,11 +74,18 @@ int config_path(char* config_root, char* extension, char* result, int max_len);
|
|||
*/
|
||||
int repo_config_init(struct RepoConfig* config, unsigned int num_bits_for_keypair, char* repo_path);
|
||||
|
||||
/***
|
||||
* Initialize memory for a RepoConfig struct
|
||||
* @param config the structure to initialize
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int ipfs_repo_config_new(struct RepoConfig** config);
|
||||
|
||||
/***
|
||||
* free all resources that were allocated to store config information
|
||||
* @param config the config
|
||||
* @returns true(1)
|
||||
*/
|
||||
int repo_config_free(struct RepoConfig* config);
|
||||
int ipfs_repo_config_free(struct RepoConfig* config);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -11,27 +11,41 @@ struct Datastore {
|
|||
char* storage_max;
|
||||
int storage_gc_watermark;
|
||||
char* gc_period;
|
||||
|
||||
char* params;
|
||||
int no_sync;
|
||||
int hash_on_read;
|
||||
int bloom_filter_size;
|
||||
|
||||
// function pointers for datastore operations
|
||||
int (*datastore_open)(int argc, char** argv, struct Datastore* datastore);
|
||||
int (*datastore_close)(int argc, char** argv, struct Datastore* datastore);
|
||||
// a handle to the datastore "context" used by the datastore
|
||||
void* handle;
|
||||
};
|
||||
|
||||
/***
|
||||
* initialize the structure of the datastore
|
||||
* Initialize the structure of the datastore to default settings. Used for
|
||||
* creating a new datastore on the disk.
|
||||
* @param datastore the struct to initialize
|
||||
* @param config_root the path to the root of IPFS
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int repo_config_datastore_init(struct Datastore* datastore, char* config_root);
|
||||
int ipfs_repo_config_datastore_init(struct Datastore* datastore, char* config_root);
|
||||
|
||||
/***
|
||||
* initialize the structure of the datastore
|
||||
* @param datastore the struct to initialize
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int ipfs_repo_config_datastore_new(struct Datastore** datastore);
|
||||
|
||||
|
||||
/***
|
||||
* deallocate the memory and clear resources from a datastore_init
|
||||
* @param datastore the struct to deallocate
|
||||
* @returns true(1)
|
||||
*/
|
||||
int repo_config_datastore_free(struct Datastore* datastore);
|
||||
int ipfs_repo_config_datastore_free(struct Datastore* datastore);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,7 +19,15 @@ struct Identity {
|
|||
/***
|
||||
* initializes a new keypair, and puts it in the Identity struct
|
||||
*/
|
||||
int repo_config_identity_new(struct Identity* identity, unsigned long num_bits_for_keypair);
|
||||
int repo_config_identity_init(struct Identity* identity, unsigned long num_bits_for_keypair);
|
||||
|
||||
/***
|
||||
* Build a RsaPrivateKey struct from a base64 string of the private key
|
||||
* @param identity where to put the new struct
|
||||
* @param base64 the base 64 encoded private key in DER format
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int repo_config_identity_build_private_key(struct Identity* identity, const char* base64);
|
||||
|
||||
/***
|
||||
* Frees resources held by Identity
|
||||
|
@ -28,4 +36,11 @@ int repo_config_identity_new(struct Identity* identity, unsigned long num_bits_f
|
|||
*/
|
||||
int repo_config_identity_free(struct Identity* identity);
|
||||
|
||||
/***
|
||||
* Initializes a new identity struct that will need to be identity_free'd
|
||||
* @param identity the identity to allocate memory for
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int repo_config_identity_new(struct Identity** identity);
|
||||
|
||||
#endif /* identity_h */
|
||||
|
|
|
@ -15,7 +15,7 @@ struct FSRepo {
|
|||
int closed;
|
||||
char* path;
|
||||
struct IOCloser* lock_file;
|
||||
struct Config* config;
|
||||
struct RepoConfig* config;
|
||||
struct Datastore* data_store;
|
||||
};
|
||||
|
||||
|
@ -25,7 +25,7 @@ struct FSRepo {
|
|||
* @param repo where to store the repo info
|
||||
* @return 0 if there was a problem, otherwise 1
|
||||
*/
|
||||
int fs_repo_open(char* repo_path, struct FSRepo* repo);
|
||||
int ipfs_repo_fsrepo_open(struct FSRepo* repo);
|
||||
|
||||
/***
|
||||
* checks to see if the repo is initialized
|
||||
|
@ -48,7 +48,20 @@ int fs_repo_write_config_file(char* path, struct RepoConfig* config);
|
|||
* @param config the information for the config file
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int fs_repo_init(char* repo_path, struct RepoConfig* config);
|
||||
int ipfs_repo_fsrepo_new(char* repo_path, struct RepoConfig* config, struct FSRepo** fs_repo);
|
||||
|
||||
/***
|
||||
* Free all resources used by this struct
|
||||
* @param repo the repo to clean up
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int ipfs_repo_fsrepo_free(struct FSRepo* config);
|
||||
|
||||
/***
|
||||
* Initialize a new repo with the specified configuration
|
||||
* @param config the information in order to build the repo
|
||||
* @returns true(1) on success
|
||||
*/
|
||||
int ipfs_repo_fsrepo_init(struct FSRepo* config);
|
||||
|
||||
#endif /* fs_repo_h */
|
||||
|
|
30
include/ipfs/repo/fsrepo/lmdb_datastore.h
Normal file
30
include/ipfs/repo/fsrepo/lmdb_datastore.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
#ifndef __FS_REPO_LMDB_DATASTORE_H__
|
||||
#define __FS_REPO_LMDB_DATASTORE_H__
|
||||
|
||||
#include "ipfs/repo/config/datastore.h"
|
||||
|
||||
/***
|
||||
* 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
|
||||
*/
|
||||
int repo_fsrepo_lmdb_close(int argc, char** argv, struct Datastore* datastore);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue