diff options
author | dec05eba <0xdec05eba@gmail.com> | 2018-05-14 22:25:26 +0200 |
---|---|---|
committer | dec05eba <0xdec05eba@gmail.com> | 2018-05-14 22:25:29 +0200 |
commit | 2260790118358449a18527fcd9e6ff46d2caccf7 (patch) | |
tree | 9bc70e9bedc290ad4f147f5bf8f23e29b40794a0 /include | |
parent | 7d675a45023e44cfa03d7fa95e4ec20e3a1c2fb9 (diff) |
Implement node load/fetch order
Diffstat (limited to 'include')
-rw-r--r-- | include/odhtdb/Database.hpp | 5 | ||||
-rw-r--r-- | include/odhtdb/DatabaseOrder.hpp | 18 | ||||
-rw-r--r-- | include/odhtdb/DatabaseStorage.hpp | 5 |
3 files changed, 24 insertions, 4 deletions
diff --git a/include/odhtdb/Database.hpp b/include/odhtdb/Database.hpp index 332a784..11a6cd4 100644 --- a/include/odhtdb/Database.hpp +++ b/include/odhtdb/Database.hpp @@ -12,6 +12,7 @@ #include "Encryption.hpp" #include "OwnedMemory.hpp" #include "DatabaseOperation.hpp" +#include "DatabaseOrder.hpp" #include <opendht/dhtrunner.h> #include <vector> #include <ntp/NtpClient.hpp> @@ -162,9 +163,9 @@ namespace odhtdb ~Database(); // Safe to call multiple times with same node hash, will be ignored if the node is already beeing seeded - void seed(const DatabaseNode &nodeToSeed); + void seed(const DatabaseNode &nodeToSeed, DatabaseFetchOrder fetchOrder = DatabaseFetchOrder::OLDEST_FIRST); void stopSeeding(const Hash &nodeHash); - void loadNode(const Hash &nodeHash); + void loadNode(const Hash &nodeHash, DatabaseLoadOrder loadOrder = DatabaseLoadOrder::OLDEST_FIRST); // Throws DatabaseCreateException on failure. std::unique_ptr<DatabaseCreateResponse> create(); diff --git a/include/odhtdb/DatabaseOrder.hpp b/include/odhtdb/DatabaseOrder.hpp new file mode 100644 index 0000000..d9c3906 --- /dev/null +++ b/include/odhtdb/DatabaseOrder.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "types.hpp" + +namespace odhtdb +{ + enum class DatabaseFetchOrder : u8 + { + OLDEST_FIRST, + NEWEST_FIRST + }; + + enum class DatabaseLoadOrder : u8 + { + OLDEST_FIRST, + NEWEST_FIRST + }; +} diff --git a/include/odhtdb/DatabaseStorage.hpp b/include/odhtdb/DatabaseStorage.hpp index 73b22b9..a004619 100644 --- a/include/odhtdb/DatabaseStorage.hpp +++ b/include/odhtdb/DatabaseStorage.hpp @@ -9,6 +9,7 @@ #include "Permission.hpp" #include "OwnedMemory.hpp" #include "DatabaseOperation.hpp" +#include "DatabaseOrder.hpp" #include <vector> #include <stdexcept> #include <boost/filesystem/path.hpp> @@ -75,7 +76,7 @@ namespace odhtdb DatabaseStorage(Database *database, const boost::filesystem::path &storagePath); ~DatabaseStorage(); - void loadNode(const Hash &nodeHash); + void loadNode(const Hash &nodeHash, DatabaseLoadOrder loadOrder); bool doesNodeExist(const Hash &nodeHash) const; bool doesDataExist(const Hash &requestHash) const; @@ -96,7 +97,7 @@ namespace odhtdb void addUser(const Hash &nodeHash, const Signature::PublicKey &userPublicKey, const DataView &groupId); void fetchNodeRaw(const Hash &nodeHash, FetchNodeRawCallbackFunc callbackFunc); - void fetchNodeAddDataRaw(const Hash &nodeHash, FetchNodeAddDataRawCallbackFunc callbackFunc); + void fetchNodeAddDataRaw(const Hash &nodeHash, FetchNodeAddDataRawCallbackFunc callbackFunc, DatabaseFetchOrder fetchOrder); void fetchNodeUserActionGaps(const Hash &nodeHash, FetchNodeUserActionGapsCallbackFunc callbackFunc); void fetchNodeUserLatestActionCounter(const Hash &nodeHash, FetchNodeUserLatestActionCounterCallbackFunc callbackFunc); |