aboutsummaryrefslogtreecommitdiff
path: root/include/DatabaseStorage.hpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-03-05 22:45:56 +0100
committerdec05eba <dec05eba@protonmail.com>2020-08-18 23:25:46 +0200
commiteda9a7bbefc5587bf1ff895a9214f450e64575fa (patch)
tree0f968fb7373a29cf116b4b6d473a966e28e62825 /include/DatabaseStorage.hpp
parent33e823ddddddd4a13b1a05b90ae5b419b89bcb1d (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;
};