2013-08-01 20:05:00 -03:00
|
|
|
#ifndef TWISTER_H
|
|
|
|
#define TWISTER_H
|
|
|
|
|
2013-08-05 22:33:38 -03:00
|
|
|
#include "util.h"
|
2013-10-02 19:04:38 -03:00
|
|
|
#include "key.h"
|
2013-08-01 20:05:00 -03:00
|
|
|
#include <boost/thread.hpp>
|
|
|
|
|
|
|
|
#define LIBTORRENT_PORT_OFFSET 1000
|
|
|
|
|
2013-09-21 16:18:56 -03:00
|
|
|
#define USERPOST_FLAG_RT 0x01
|
|
|
|
#define USERPOST_FLAG_DM 0x02
|
|
|
|
|
2013-10-26 16:00:16 -02:00
|
|
|
#define BLOCK_AGE_TO_EXPIRE_DHT_ENTRY (2016) // about 2 weeks
|
2013-10-27 22:54:47 -02:00
|
|
|
#define BLOCK_AGE_TO_EXPIRE_DHT_POSTS (4320*2) // about 2 months
|
2013-10-26 16:00:16 -02:00
|
|
|
|
2013-09-21 16:18:56 -03:00
|
|
|
|
2013-08-01 20:05:00 -03:00
|
|
|
class twister
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
twister();
|
|
|
|
};
|
|
|
|
|
|
|
|
void startSessionTorrent(boost::thread_group& threadGroup);
|
2013-08-02 00:43:04 -03:00
|
|
|
void stopSessionTorrent();
|
2013-08-01 20:05:00 -03:00
|
|
|
|
2013-11-06 09:22:05 -02:00
|
|
|
bool getUserPubKey(std::string const &strUsername, CPubKey &pubkey, int maxHeight = -1);
|
2013-10-02 19:04:38 -03:00
|
|
|
std::string createSignature(std::string const &strMessage, CKeyID &keyID);
|
2013-08-04 18:26:45 -03:00
|
|
|
std::string createSignature(std::string const &strMessage, std::string const &strUsername);
|
2013-11-06 09:22:05 -02:00
|
|
|
bool verifySignature(std::string const &strMessage, std::string const &strUsername, std::string const &strSign, int maxHeight = -1);
|
2013-08-04 00:17:52 -03:00
|
|
|
|
2013-09-21 16:18:56 -03:00
|
|
|
bool acceptSignedPost(char const *data, int data_size, std::string username, int seq, std::string &errmsg, boost::uint32_t *flags);
|
2013-08-18 21:05:23 -03:00
|
|
|
bool validatePostNumberForUser(std::string const &username, int k);
|
2013-10-18 12:08:54 -03:00
|
|
|
bool usernameExists(std::string const &username);
|
2013-08-18 20:33:54 -03:00
|
|
|
|
2013-10-01 08:57:51 -03:00
|
|
|
void receivedSpamMessage(std::string const &message, std::string const &user);
|
|
|
|
|
2013-08-04 16:16:36 -03:00
|
|
|
int getBestHeight();
|
2013-10-18 12:08:54 -03:00
|
|
|
bool shouldDhtResourceExpire(std::string resource, bool multi, int height);
|
2013-08-04 00:17:52 -03:00
|
|
|
|
2013-12-31 09:46:19 -02:00
|
|
|
int getDhtNodes(boost::int64_t *dht_global_nodes = NULL);
|
2013-11-14 15:07:47 -02:00
|
|
|
|
2013-08-01 20:05:00 -03:00
|
|
|
#endif // TWISTER_H
|