Added journaling when a file is saved - beginning of backup scheme
This commit is contained in:
parent
5b242a2d08
commit
d13e4b4318
11 changed files with 346 additions and 45 deletions
33
include/ipfs/repo/fsrepo/journalstore.h
Normal file
33
include/ipfs/repo/fsrepo/journalstore.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
/**
|
||||
* Piggyback on the datastore to access the journal entries
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libp2p/db/datastore.h"
|
||||
|
||||
struct JournalRecord {
|
||||
unsigned long long timestamp;
|
||||
int pin;
|
||||
uint8_t *hash;
|
||||
size_t hash_size;
|
||||
};
|
||||
|
||||
/**
|
||||
* Open a cursor to the journalstore table
|
||||
*/
|
||||
int repo_journalstore_cursor_open(struct Datastore* datastore, void** cursor);
|
||||
|
||||
/**
|
||||
* Read a record from the cursor
|
||||
*/
|
||||
int repo_journalstore_cursor_get(struct Datastore* datastore, void* cursor, enum DatastoreCursorOp op, struct JournalRecord** record);
|
||||
|
||||
/**
|
||||
* Close the cursor
|
||||
*/
|
||||
int repo_cournalstore_cursor_close(struct Datastore* datastore, void* cursor);
|
||||
|
||||
int journal_record_free(struct JournalRecord* rec);
|
|
@ -1,8 +1,16 @@
|
|||
#ifndef __FS_REPO_LMDB_DATASTORE_H__
|
||||
#define __FS_REPO_LMDB_DATASTORE_H__
|
||||
#pragma once
|
||||
|
||||
#include "lmdb.h"
|
||||
#include "libp2p/db/datastore.h"
|
||||
|
||||
static const char* DATASTORE_DB = "DATASTORE";
|
||||
static const char* JOURNAL_DB = "JOURNAL";
|
||||
|
||||
struct lmdb_trans_cursor {
|
||||
MDB_txn* transaction;
|
||||
MDB_cursor* cursor;
|
||||
};
|
||||
|
||||
/***
|
||||
* Places the LMDB methods into the datastore's function pointers
|
||||
* @param datastore the datastore to fill
|
||||
|
@ -33,5 +41,3 @@ int repo_fsrepo_lmdb_close(struct Datastore* datastore);
|
|||
* @returns true(1) on success
|
||||
*/
|
||||
int repo_fsrepo_lmdb_create_directory(struct Datastore* datastore);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue