roughly get rid of rocksdb dependency
This commit is contained in:
parent
3c9a39d431
commit
0f207a1411
5 changed files with 2 additions and 60 deletions
|
@ -6,7 +6,6 @@ project('floof store-and-forward library', 'c', 'cpp',
|
||||||
|
|
||||||
threads = dependency('threads')
|
threads = dependency('threads')
|
||||||
glib = dependency('glib-2.0')
|
glib = dependency('glib-2.0')
|
||||||
rocksdb = dependency('rocksdb')
|
|
||||||
sodium = dependency('libsodium')
|
sodium = dependency('libsodium')
|
||||||
|
|
||||||
subdir('src')
|
subdir('src')
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs.glib
|
pkgs.glib
|
||||||
pkgs.rocksdb
|
|
||||||
pkgs.libsodium
|
pkgs.libsodium
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <rocksdb/db.h>
|
|
||||||
#include <rocksdb/slice.h>
|
|
||||||
#include <rocksdb/write_batch.h>
|
|
||||||
|
|
||||||
#include <sodium.h>
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
typedef rocksdb::DB floof_db_t;
|
|
||||||
|
|
||||||
int floof_db_open(floof_db_t ** db, const char * path) {
|
|
||||||
rocksdb::Options options;
|
|
||||||
options.create_if_missing = true;
|
|
||||||
rocksdb::Status status;
|
|
||||||
|
|
||||||
status = rocksdb::DB::Open(options, path, &*db);
|
|
||||||
if(status.ok()) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void floof_db_close(floof_db_t ** db) {
|
|
||||||
if(!*db) return;
|
|
||||||
delete (*db);
|
|
||||||
*db = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void floof_db_insert_packet(floof_db_t * db, floof_worker_task_t * packet) {
|
|
||||||
rocksdb::WriteBatch batch;
|
|
||||||
|
|
||||||
unsigned char sigblock[crypto_sign_PUBLICKEYBYTES + crypto_sign_BYTES];
|
|
||||||
memcpy(&sigblock[0], packet->pubkey, crypto_sign_PUBLICKEYBYTES);
|
|
||||||
memcpy(&sigblock[crypto_sign_PUBLICKEYBYTES], packet->sig, crypto_sign_BYTES);
|
|
||||||
|
|
||||||
batch.Put(rocksdb::Slice(sigblock, crypto_sign_PUBLICKEYBYTES + crypto_sign_BYTES),
|
|
||||||
rocksdb::Slice(packet->data, packet->datalen));
|
|
||||||
|
|
||||||
rocksdb::Status status;
|
|
||||||
status = db->Write(rocksdb::WriteOptions(), &batch);
|
|
||||||
|
|
||||||
if(!status.ok()) {
|
|
||||||
const std::string tmp = status.ToString();
|
|
||||||
g_warning("Floof failed to insert packet into database: %s", tmp.c_str());
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include "floof_int.h"
|
|
||||||
struct floof_db_t;
|
|
||||||
int floof_db_open(floof_db_t ** db, const char * path);
|
|
||||||
void floof_db_close(floof_db_t ** db);
|
|
||||||
void floof_db_insert_packet(floof_db_t * db, floof_worker_task_t * packet);
|
|
|
@ -1,6 +1,6 @@
|
||||||
install_headers('floof.h')
|
install_headers('floof.h')
|
||||||
|
|
||||||
libfloof_sources = files('floof.c', 'floof_db.cxx')
|
libfloof_sources = files('floof.c')
|
||||||
|
|
||||||
libfloof = shared_library('floof',
|
libfloof = shared_library('floof',
|
||||||
libfloof_sources,
|
libfloof_sources,
|
||||||
|
@ -8,5 +8,5 @@ libfloof = shared_library('floof',
|
||||||
c_args : ['-fno-plt'],
|
c_args : ['-fno-plt'],
|
||||||
cpp_args : ['-fno-plt', '-fno-rtti']
|
cpp_args : ['-fno-plt', '-fno-rtti']
|
||||||
include_directories : include_directories('.')
|
include_directories : include_directories('.')
|
||||||
dependencies : [threads, glib, rocksdb, sodium],
|
dependencies : [threads, glib, sodium],
|
||||||
install : true)
|
install : true)
|
||||||
|
|
Loading…
Reference in a new issue