2016-10-27 01:14:07 +00:00
|
|
|
#ifndef __DATASTORE_H__
|
|
|
|
#define __DATASTORE_H__
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2016-11-30 16:46:41 +00:00
|
|
|
#include "ipfs/blocks/block.h"
|
2016-10-27 01:14:07 +00:00
|
|
|
|
2016-10-27 03:32:23 +00:00
|
|
|
//const char* datastore_default_directory = "datastore";
|
2016-10-27 01:14:07 +00:00
|
|
|
|
2016-10-27 18:11:34 +00:00
|
|
|
struct Datastore {
|
2016-10-27 01:14:07 +00:00
|
|
|
char* type;
|
|
|
|
char* path;
|
|
|
|
char* storage_max;
|
2016-11-02 18:09:38 +00:00
|
|
|
int storage_gc_watermark;
|
2016-10-27 01:14:07 +00:00
|
|
|
char* gc_period;
|
|
|
|
char* params;
|
|
|
|
int no_sync;
|
|
|
|
int hash_on_read;
|
|
|
|
int bloom_filter_size;
|
2016-11-17 20:07:59 +00:00
|
|
|
|
|
|
|
// function pointers for datastore operations
|
|
|
|
int (*datastore_open)(int argc, char** argv, struct Datastore* datastore);
|
2016-12-01 18:08:30 +00:00
|
|
|
int (*datastore_close)(struct Datastore* datastore);
|
2016-12-05 22:23:58 +00:00
|
|
|
int (*datastore_put)(const unsigned char* key, size_t key_size, unsigned char* data, size_t data_length, const struct Datastore* datastore);
|
|
|
|
int (*datastore_put_block)(const struct Block* block, const struct Datastore* datastore);
|
|
|
|
int (*datastore_get)(const char* key, size_t key_size, unsigned char* data, size_t max_data_length, size_t* data_length, const struct Datastore* datastore);
|
|
|
|
int (*datastore_get_block)(const struct Cid* cid, struct Block** block, const struct Datastore* datastore);
|
2016-11-17 20:07:59 +00:00
|
|
|
// a handle to the datastore "context" used by the datastore
|
|
|
|
void* handle;
|
2016-10-27 01:14:07 +00:00
|
|
|
};
|
|
|
|
|
2016-11-02 18:09:38 +00:00
|
|
|
/***
|
2016-11-17 20:07:59 +00:00
|
|
|
* Initialize the structure of the datastore to default settings. Used for
|
|
|
|
* creating a new datastore on the disk.
|
2016-11-02 18:09:38 +00:00
|
|
|
* @param datastore the struct to initialize
|
|
|
|
* @param config_root the path to the root of IPFS
|
|
|
|
* @returns true(1) on success
|
|
|
|
*/
|
2016-12-05 22:23:58 +00:00
|
|
|
int ipfs_repo_config_datastore_init(struct Datastore* datastore, const char* config_root);
|
2016-11-17 20:07:59 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
* 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);
|
|
|
|
|
2016-11-02 18:09:38 +00:00
|
|
|
|
|
|
|
/***
|
|
|
|
* deallocate the memory and clear resources from a datastore_init
|
|
|
|
* @param datastore the struct to deallocate
|
|
|
|
* @returns true(1)
|
|
|
|
*/
|
2016-11-17 20:07:59 +00:00
|
|
|
int ipfs_repo_config_datastore_free(struct Datastore* datastore);
|
2016-11-02 18:09:38 +00:00
|
|
|
|
|
|
|
|
2016-10-27 01:14:07 +00:00
|
|
|
#endif
|