Loading src/authdb.cpp +1 −5 Changes for src/authdb.cpp: 1 added line, 5 removed lines. Original line number Diff line number Diff line Loading @@ -557,11 +557,7 @@ int main(int argc,char *argv[]){ } std::string backendPath; if (clusterEnabled) { auto *clusterPath = config.getKey("/AUTHDB/CLUSTER/PATH"); if (clusterPath) backendPath = config.getValue(clusterPath, 0); } else { if (!clusterEnabled) { backendPath = config.getValue(config.getKey("/AUTHDB/ADMINDB/PATH"), 0); } Loading src/backends/cluster.cpp +3 −43 Changes for src/backends/cluster.cpp: 3 added lines, 43 removed lines. Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ #include <cstring> #include <iostream> #include <algorithm> #include <fstream> #include <crypto/sha.h> Loading Loading @@ -110,14 +109,7 @@ namespace authdb { : _Domain(domain), _Pos(0), _Dirty(false), _ParityGroupId(0), _HasParityGroup(false) { if (filepath && filepath[0] != '\0') _FilePath = filepath; // Try to load from local file first loadFromFile(); // Then try to fetch from cluster peers if (_Buffer.empty()) // Try to fetch existing data from cluster/store fetchFromCluster(); if (_Buffer.empty()) { Loading @@ -133,17 +125,14 @@ namespace authdb { std::memcpy(_Buffer.data(), &head, sizeof(AuthHeader)); _Dirty = true; // Push initial header to cluster // Push initial header to cluster/store pushToCluster(); saveToFile(); } } ClusterBackend::~ClusterBackend() { if (_Dirty) { if (_Dirty) pushToCluster(); saveToFile(); } } void ClusterBackend::read(unsigned char *src, size_t srcsize) { Loading @@ -169,7 +158,6 @@ namespace authdb { void ClusterBackend::unlock() { pushToCluster(); saveToFile(); } void ClusterBackend::setPos(size_t pos) { Loading Loading @@ -272,32 +260,4 @@ namespace authdb { _Dirty = true; } void ClusterBackend::loadFromFile() { if (_FilePath.empty()) return; std::ifstream in(_FilePath, std::ios::binary | std::ios::ate); if (!in.is_open()) return; auto size = in.tellg(); if (size <= 0) return; in.seekg(0, std::ios::beg); _Buffer.resize(static_cast<size_t>(size)); in.read(reinterpret_cast<char*>(_Buffer.data()), size); } void ClusterBackend::saveToFile() { if (_FilePath.empty() || _Buffer.empty()) return; std::ofstream out(_FilePath, std::ios::binary | std::ios::trunc); if (!out.is_open()) return; out.write(reinterpret_cast<const char*>(_Buffer.data()), _Buffer.size()); } } src/backends/cluster.h +0 −3 Changes for src/backends/cluster.h: 0 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -65,11 +65,8 @@ namespace authdb { uint64_t domainGroupId() const; void fetchFromCluster(); void pushToCluster(); void loadFromFile(); void saveToFile(); std::string _Domain; std::string _FilePath; std::vector<uint8_t> _Buffer; size_t _Pos; bool _Dirty; Loading Loading
src/authdb.cpp +1 −5 Changes for src/authdb.cpp: 1 added line, 5 removed lines. Original line number Diff line number Diff line Loading @@ -557,11 +557,7 @@ int main(int argc,char *argv[]){ } std::string backendPath; if (clusterEnabled) { auto *clusterPath = config.getKey("/AUTHDB/CLUSTER/PATH"); if (clusterPath) backendPath = config.getValue(clusterPath, 0); } else { if (!clusterEnabled) { backendPath = config.getValue(config.getKey("/AUTHDB/ADMINDB/PATH"), 0); } Loading
src/backends/cluster.cpp +3 −43 Changes for src/backends/cluster.cpp: 3 added lines, 43 removed lines. Original line number Diff line number Diff line Loading @@ -28,7 +28,6 @@ #include <cstring> #include <iostream> #include <algorithm> #include <fstream> #include <crypto/sha.h> Loading Loading @@ -110,14 +109,7 @@ namespace authdb { : _Domain(domain), _Pos(0), _Dirty(false), _ParityGroupId(0), _HasParityGroup(false) { if (filepath && filepath[0] != '\0') _FilePath = filepath; // Try to load from local file first loadFromFile(); // Then try to fetch from cluster peers if (_Buffer.empty()) // Try to fetch existing data from cluster/store fetchFromCluster(); if (_Buffer.empty()) { Loading @@ -133,17 +125,14 @@ namespace authdb { std::memcpy(_Buffer.data(), &head, sizeof(AuthHeader)); _Dirty = true; // Push initial header to cluster // Push initial header to cluster/store pushToCluster(); saveToFile(); } } ClusterBackend::~ClusterBackend() { if (_Dirty) { if (_Dirty) pushToCluster(); saveToFile(); } } void ClusterBackend::read(unsigned char *src, size_t srcsize) { Loading @@ -169,7 +158,6 @@ namespace authdb { void ClusterBackend::unlock() { pushToCluster(); saveToFile(); } void ClusterBackend::setPos(size_t pos) { Loading Loading @@ -272,32 +260,4 @@ namespace authdb { _Dirty = true; } void ClusterBackend::loadFromFile() { if (_FilePath.empty()) return; std::ifstream in(_FilePath, std::ios::binary | std::ios::ate); if (!in.is_open()) return; auto size = in.tellg(); if (size <= 0) return; in.seekg(0, std::ios::beg); _Buffer.resize(static_cast<size_t>(size)); in.read(reinterpret_cast<char*>(_Buffer.data()), size); } void ClusterBackend::saveToFile() { if (_FilePath.empty() || _Buffer.empty()) return; std::ofstream out(_FilePath, std::ios::binary | std::ios::trunc); if (!out.is_open()) return; out.write(reinterpret_cast<const char*>(_Buffer.data()), _Buffer.size()); } }
src/backends/cluster.h +0 −3 Changes for src/backends/cluster.h: 0 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -65,11 +65,8 @@ namespace authdb { uint64_t domainGroupId() const; void fetchFromCluster(); void pushToCluster(); void loadFromFile(); void saveToFile(); std::string _Domain; std::string _FilePath; std::vector<uint8_t> _Buffer; size_t _Pos; bool _Dirty; Loading