aboutsummaryrefslogtreecommitdiff
path: root/include/DatabaseStorage.hpp
diff options
context:
space:
mode:
authorAleksi Lindeman <0xdec05eba@gmail.com>2018-03-05 22:45:56 +0100
committerAleksi Lindeman <0xdec05eba@gmail.com>2018-03-05 22:48:26 +0100
commit2ffb47d0043e57707474e5ae811f97c2e5e93f25 (patch)
treefd60b300cdf736de5adc68b395105dcfc6a43f09 /include/DatabaseStorage.hpp
parent66661e47dc826f50b690e080057f47a0ea27016c (diff)
Implement 'create' operation, add seeding
Seeding is currently only done on the key you specify, in the future the user should request data that it can seed.
Diffstat (limited to 'include/DatabaseStorage.hpp')
-rw-r--r--include/DatabaseStorage.hpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/include/DatabaseStorage.hpp b/include/DatabaseStorage.hpp
index 863c5d9..6f251d1 100644
--- a/include/DatabaseStorage.hpp
+++ b/include/DatabaseStorage.hpp
@@ -1,8 +1,9 @@
#pragma once
-#include "Key.hpp"
+#include "Hash.hpp"
#include "DataView.hpp"
#include "Signature.hpp"
+#include "Encryption.hpp"
#include <vector>
#include <stdexcept>
@@ -28,6 +29,8 @@ namespace odhtdb
u64 timestamp; // In microseconds
std::vector<Group*> groups;
std::vector<DatabaseStorageObject> objects;
+ u8 *createData;
+ usize createDataSize;
};
class DatabaseStorageAlreadyExists : public std::runtime_error
@@ -42,16 +45,19 @@ namespace odhtdb
DatabaseStorageNotFound(const std::string &errMsg) : std::runtime_error(errMsg) {}
};
- using DatabaseStorageMap = KeyMap<DatabaseStorageObjectList*>;
+ using DatabaseStorageMap = MapHashKey<DatabaseStorageObjectList*>;
class DatabaseStorage
{
public:
- // Throws DatabaseStorageAlreadyExists if data with key already exists
- void createStorage(const Key &key, std::vector<Group*> &&groups, u64 timestamp);
+ // Throws DatabaseStorageAlreadyExists if data with hash already exists
+ void createStorage(const Hash &hash, Group *creatorGroup, u64 timestamp, const u8 *data, usize dataSize);
- // Throws DatabaseStorageNotFound if data with key does not exist
- void appendStorage(const Key &key, DataView &data, u64 timestamp, const Signature::PublicKey &creatorPublicKey);
+ // Throws DatabaseStorageNotFound if data with hash does not exist
+ void appendStorage(const Hash &hash, DataView &data, u64 timestamp, const Signature::PublicKey &creatorPublicKey);
+
+ // Returns nullptr if not storage with provided hash exists
+ const DatabaseStorageObjectList* getStorage(const Hash &hash) const;
private:
DatabaseStorageMap storageMap;
};