From 58819e501f2705a7d1dd678eb0112e97697e4366 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Tue, 1 May 2018 11:59:15 +0200 Subject: Remove unnecessary dependency 'fmt' --- README.md | 6 ++++++ include/odhtdb/Database.hpp | 2 +- include/odhtdb/Group.hpp | 2 ++ include/odhtdb/Signature.hpp | 4 ++-- project.conf | 1 - src/Database.cpp | 6 ++---- src/Signature.cpp | 4 ++-- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 5e62b91..5c61bf6 100644 --- a/README.md +++ b/README.md @@ -35,3 +35,9 @@ This database is used for chat application, and in chat applications you may wan Functionality for an invite link that is only available for a certain amount of time can be added by generating an invite packet as an admin user with timestamp and the user that should be added can be excluded from the signed packet, allowing any user to be added to channel while the invite link is valid. The invite link could be converted to hex string to make it shareable and also generate QR-code using it to make it easy to join with mobile device. +## UDT +Combine opendht with udt. Use opendht to find other peers and udt for communication. +## New node download +Use a merkle tree and when requesting new nodes when connecting, send X latest hashes and other peers can send you where you have missing data and send you it. +If all X hashes are wrong, send older hashes. +However if we are only using opendht to find other peers, we might as well use https://github.com/DavidKeller/kademlia or https://github.com/ytakano/libcage diff --git a/include/odhtdb/Database.hpp b/include/odhtdb/Database.hpp index 18ae5a1..e34fd9d 100644 --- a/include/odhtdb/Database.hpp +++ b/include/odhtdb/Database.hpp @@ -163,7 +163,7 @@ namespace odhtdb // Throws PermissionDeniedException if user @userToPerformActionWith is not allowed to add data to node void addData(const DatabaseNode &nodeInfo, const LocalUser *userToPerformActionWith, DataView dataToAdd); // Throws PermissionDeniedException if user @userToPerformActionWith is not allowed to add user @userToAdd to group @groupToAddUserTo - void addUser(const DatabaseNode &nodeInfo, LocalUser *userToPerformActionWith, const std::string &userToAddName, const Signature::PublicKey &userToAddPublicKey, Group *groupToAddUserTo); + void addUser(const DatabaseNode &nodeInfo, const LocalUser *userToPerformActionWith, const std::string &userToAddName, const Signature::PublicKey &userToAddPublicKey, Group *groupToAddUserTo); void commit(); void setOnCreateNodeCallback(std::function callbackFunc); diff --git a/include/odhtdb/Group.hpp b/include/odhtdb/Group.hpp index cd28923..99307e1 100644 --- a/include/odhtdb/Group.hpp +++ b/include/odhtdb/Group.hpp @@ -3,6 +3,7 @@ #include "types.hpp" #include "DataView.hpp" #include "Permission.hpp" +#include "utils.hpp" #include #include #include @@ -25,6 +26,7 @@ namespace odhtdb class Group { + DISABLE_COPY(Group) friend class User; public: Group(const std::string &name, uint8_t id[GROUP_ID_LENGTH], const Permission &permission); diff --git a/include/odhtdb/Signature.hpp b/include/odhtdb/Signature.hpp index 270b099..dac856b 100644 --- a/include/odhtdb/Signature.hpp +++ b/include/odhtdb/Signature.hpp @@ -53,7 +53,7 @@ namespace odhtdb { friend class KeyPair; public: - static PublicKey ZERO; + const static PublicKey ZERO; // Throws InvalidSignatureKeySize if size is not PUBLIC_KEY_NUM_BYTES PublicKey(const char *data, size_t size); @@ -93,7 +93,7 @@ namespace odhtdb { friend class KeyPair; public: - static PrivateKey ZERO; + const static PrivateKey ZERO; // Throws InvalidSignatureKeySize if size is not PRIVATE_KEY_NUM_BYTES PrivateKey(const char *data, size_t size); diff --git a/project.conf b/project.conf index 29d12d2..1d687b0 100644 --- a/project.conf +++ b/project.conf @@ -10,7 +10,6 @@ expose_include_dirs = ["include"] [dependencies] opendht = "1.7.0" -fmt = "4.1.0" libsodium = "1.0.16" ntpclient = "0.2.1" sibs-serializer = "0.2.0" diff --git a/src/Database.cpp b/src/Database.cpp index aa852f6..8cca298 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -8,7 +8,6 @@ #include "../include/odhtdb/Log.hpp" #include #include -#include #include #include #include @@ -105,8 +104,7 @@ namespace odhtdb /*.proxy_server = */"", /*.push_node_id = */"" }); - fmt::MemoryWriter portStr; - portStr << port; + auto portStr = to_string(port); node.bootstrap(bootstrapNodeAddr, portStr.c_str()); // TODO: Make this work for multiple threads initializing database at same time @@ -388,7 +386,7 @@ namespace odhtdb return nullptr; } - void Database::addUser(const DatabaseNode &nodeInfo, LocalUser *userToPerformActionWith, const string &userToAddName, const Signature::PublicKey &userToAddPublicKey, Group *groupToAddUserTo) + void Database::addUser(const DatabaseNode &nodeInfo, const LocalUser *userToPerformActionWith, const string &userToAddName, const Signature::PublicKey &userToAddPublicKey, Group *groupToAddUserTo) { auto groupWithAddUserRights = getGroupWithRightsToAddUserToGroup(userToPerformActionWith->getGroups(), groupToAddUserTo); if(!groupWithAddUserRights) diff --git a/src/Signature.cpp b/src/Signature.cpp index 9f44ad2..af04017 100644 --- a/src/Signature.cpp +++ b/src/Signature.cpp @@ -10,7 +10,7 @@ namespace odhtdb { namespace Signature { - PublicKey PublicKey::ZERO("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", PUBLIC_KEY_NUM_BYTES); + const PublicKey PublicKey::ZERO("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", PUBLIC_KEY_NUM_BYTES); PublicKey::PublicKey(const char *_data, size_t size) { @@ -64,7 +64,7 @@ namespace odhtdb return bin2hex(data, PUBLIC_KEY_NUM_BYTES); } - PrivateKey PrivateKey::ZERO("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", PRIVATE_KEY_NUM_BYTES); + const PrivateKey PrivateKey::ZERO("\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", PRIVATE_KEY_NUM_BYTES); PrivateKey::PrivateKey(const char *_data, size_t size) { -- cgit v1.2.3