summaryrefslogtreecommitdiffstats
path: root/src/db.h
diff options
context:
space:
mode:
authorErik Andersson <erik@packy.se>2016-11-22 23:56:43 +0100
committerErik Andersson <erik@packy.se>2016-11-22 23:56:43 +0100
commit41954fffc10bfd230f857f57c6871b412d5f2e91 (patch)
tree010bcf28f294a58b4a22b7276cf615758648bcbe /src/db.h
parented374a8dbcdaaf273964293d2805bdd61b148022 (diff)
downloadocelot-master.zip
ocelot-master.tar.gz
ocelot-master.tar.bz2
Ocelot v1.0HEADv1.0master
Diffstat (limited to 'src/db.h')
-rw-r--r--src/db.h25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/db.h b/src/db.h
index 7886abc..f08b757 100644
--- a/src/db.h
+++ b/src/db.h
@@ -6,6 +6,7 @@
#include <unordered_map>
#include <queue>
#include <mutex>
+#include "config.h"
class mysql {
private:
@@ -23,8 +24,9 @@ class mysql {
std::queue<std::string> snatch_queue;
std::queue<std::string> token_queue;
- std::string db, server, db_user, pw;
+ std::string mysql_db, mysql_host, mysql_username, mysql_password;
bool u_active, t_active, p_active, s_active, tok_active;
+ bool readonly;
// These locks prevent more than one thread from reading/writing the buffers.
// These should be held for the minimum time possible.
@@ -35,6 +37,9 @@ class mysql {
std::mutex snatch_queue_lock;
std::mutex token_queue_lock;
+ void load_config(config * conf);
+ void load_tokens(torrent_list &torrents);
+
void do_flush_users();
void do_flush_torrents();
void do_flush_snatches();
@@ -51,25 +56,27 @@ class mysql {
public:
bool verbose_flush;
- mysql(std::string mysql_db, std::string mysql_host, std::string username, std::string password);
+ mysql(config * conf);
+ void reload_config(config * conf);
bool connected();
void load_torrents(torrent_list &torrents);
void load_users(user_list &users);
- void load_tokens(torrent_list &torrents);
void load_whitelist(std::vector<std::string> &whitelist);
- void record_user(std::string &record); // (id,uploaded_change,downloaded_change)
- void record_torrent(std::string &record); // (id,seeders,leechers,snatched_change,balance)
- void record_snatch(std::string &record, std::string &ip); // (uid,fid,tstamp)
- void record_peer(std::string &record, std::string &ip, std::string &peer_id, std::string &useragent); // (uid,fid,active,peerid,useragent,ip,uploaded,downloaded,upspeed,downspeed,left,timespent,announces,tstamp)
- void record_peer(std::string &record, std::string &peer_id); // (fid,peerid,timespent,announces,tstamp)
- void record_token(std::string &record);
+ void record_user(const std::string &record); // (id,uploaded_change,downloaded_change)
+ void record_torrent(const std::string &record); // (id,seeders,leechers,snatched_change,balance)
+ void record_snatch(const std::string &record, const std::string &ip); // (uid,fid,tstamp)
+ void record_peer(const std::string &record, const std::string &ip, const std::string &peer_id, const std::string &useragent); // (uid,fid,active,peerid,useragent,ip,uploaded,downloaded,upspeed,downspeed,left,timespent,announces,tstamp)
+ void record_peer(const std::string &record, const std::string &peer_id); // (fid,peerid,timespent,announces,tstamp)
+ void record_token(const std::string &record);
void flush();
bool all_clear();
std::mutex torrent_list_mutex;
+ std::mutex user_list_mutex;
+ std::mutex whitelist_mutex;
};
#pragma GCC visibility pop