From 2ffb47d0043e57707474e5ae811f97c2e5e93f25 Mon Sep 17 00:00:00 2001 From: Aleksi Lindeman <0xdec05eba@gmail.com> Date: Mon, 5 Mar 2018 22:45:56 +0100 Subject: 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. --- include/DatabaseStorage.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'include/DatabaseStorage.hpp') 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 #include @@ -28,6 +29,8 @@ namespace odhtdb u64 timestamp; // In microseconds std::vector groups; std::vector 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; + using DatabaseStorageMap = MapHashKey; class DatabaseStorage { public: - // Throws DatabaseStorageAlreadyExists if data with key already exists - void createStorage(const Key &key, std::vector &&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; }; -- cgit v1.2.3