2017-08-21 19:49:21 +00:00
|
|
|
#pragma once
|
|
|
|
/**
|
|
|
|
* Piggyback on the datastore to access the journal entries
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2017-08-24 15:08:27 +00:00
|
|
|
#include "lmdb.h"
|
2017-08-21 19:49:21 +00:00
|
|
|
#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
|
|
|
|
*/
|
2017-08-24 18:30:44 +00:00
|
|
|
int repo_journalstore_cursor_close(struct Datastore* datastore, void* cursor);
|
2017-08-21 19:49:21 +00:00
|
|
|
|
|
|
|
int journal_record_free(struct JournalRecord* rec);
|
2017-08-24 15:08:27 +00:00
|
|
|
|
|
|
|
int lmdb_journalstore_journal_add(MDB_txn* mdb_txn, unsigned long long timestamp, const uint8_t *hash, size_t hash_size);
|