aboutsummaryrefslogtreecommitdiff
path: root/include/DatabaseStorage.hpp
diff options
context:
space:
mode:
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;
};