More storage implementation
Successfully writing to lightningdb. Now to pull it back out. Also need to write to the blockstore.
This commit is contained in:
parent
4626b69381
commit
b462d9ef53
29 changed files with 448 additions and 123 deletions
|
@ -72,7 +72,7 @@ int config_path(char* config_root, char* extension, char* result, int max_len);
|
|||
* @param num_bits_for_keypair number of bits for the key pair
|
||||
* @returns true(1) on success, otherwise 0
|
||||
*/
|
||||
int repo_config_init(struct RepoConfig* config, unsigned int num_bits_for_keypair, char* repo_path);
|
||||
int ipfs_repo_config_init(struct RepoConfig* config, unsigned int num_bits_for_keypair, char* repo_path);
|
||||
|
||||
/***
|
||||
* Initialize memory for a RepoConfig struct
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __DATASTORE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "ipfs/blocks/block.h"
|
||||
|
||||
//const char* datastore_default_directory = "datastore";
|
||||
|
||||
|
@ -19,6 +20,8 @@ struct Datastore {
|
|||
// 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);
|
||||
int (*datastore_put)(const char* key, struct Block* block, struct Datastore* datastore);
|
||||
//int (*datastore_get)(const char* key, struct Block* block);
|
||||
// a handle to the datastore "context" used by the datastore
|
||||
void* handle;
|
||||
};
|
||||
|
|
|
@ -16,13 +16,11 @@ struct FSRepo {
|
|||
char* path;
|
||||
struct IOCloser* lock_file;
|
||||
struct RepoConfig* config;
|
||||
struct Datastore* data_store;
|
||||
};
|
||||
|
||||
/**
|
||||
* opens a fsrepo
|
||||
* @param repo_path the path to the repo
|
||||
* @param repo where to store the repo info
|
||||
* @param repo the repo struct. Should contain the path. This method will do the rest
|
||||
* @return 0 if there was a problem, otherwise 1
|
||||
*/
|
||||
int ipfs_repo_fsrepo_open(struct FSRepo* repo);
|
||||
|
@ -43,10 +41,12 @@ int fs_repo_is_initialized(char* repo_path);
|
|||
int fs_repo_write_config_file(char* path, struct RepoConfig* config);
|
||||
|
||||
/**
|
||||
* Initializes a new FSRepo at the given path with the provided config
|
||||
* @param repo_path the path to use
|
||||
* @param config the information for the config file
|
||||
* @returns true(1) on success
|
||||
* constructs the FSRepo struct.
|
||||
* Remember: ipfs_repo_fsrepo_free must be called
|
||||
* @param repo_path the path to the repo
|
||||
* @param config the optional config file. NOTE: if passed, fsrepo_free will free resources of the RepoConfig.
|
||||
* @param repo the struct to allocate memory for
|
||||
* @returns false(0) if something bad happened, otherwise true(1)
|
||||
*/
|
||||
int ipfs_repo_fsrepo_new(char* repo_path, struct RepoConfig* config, struct FSRepo** fs_repo);
|
||||
|
||||
|
|
|
@ -27,4 +27,11 @@ int repo_fsrepro_lmdb_open(int argc, char** argv, struct Datastore* datastore);
|
|||
*/
|
||||
int repo_fsrepo_lmdb_close(int argc, char** argv, struct Datastore* datastore);
|
||||
|
||||
/***
|
||||
* 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);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
#ifndef __REPO_H__
|
||||
#define __REPO_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config/config.h"
|
||||
|
||||
/**
|
||||
* Get the config
|
||||
* @param config a place to put the buffer (must have been pre-allocated)
|
||||
* @returns 0 on error
|
||||
*/
|
||||
int repo_get_config(struct RepoConfig* config);
|
||||
|
||||
/**
|
||||
* Retrieves the config
|
||||
* @param config a place to get the information
|
||||
* @returns 0 on error
|
||||
*/
|
||||
int repo_set_config(struct RepoConfig* config);
|
||||
int repo_set_config_key(char* key, void* value);
|
||||
int repo_get_config_key(char* key, void* value);
|
||||
int repo_get_datastore(struct Datastore* datastore);
|
||||
int repo_get_storage_usage(uint64_t* usage);
|
||||
|
||||
#endif // __REPO_H__
|
Loading…
Add table
Add a link
Reference in a new issue