twisterp2pblockchainnetworkbittorrentmicrobloggingipv6social-networkdhtdecentralizedtwisterarmyp2p-networktwister-servertwister-ipv6twister-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
2.0 KiB
55 lines
2.0 KiB
#ifndef TWISTER_H |
|
#define TWISTER_H |
|
|
|
#include "util.h" |
|
#include "key.h" |
|
#include <boost/thread.hpp> |
|
|
|
#define LIBTORRENT_PORT_OFFSET 1000 |
|
|
|
#define USERPOST_FLAG_RT 0x01 |
|
#define USERPOST_FLAG_DM 0x02 |
|
|
|
#define BLOCK_AGE_TO_EXPIRE_DHT_ENTRY (2016) // about 2 weeks |
|
#define BLOCK_AGE_TO_EXPIRE_DHT_POSTS (4320*2) // about 2 months |
|
|
|
namespace libtorrent { |
|
class entry; |
|
} |
|
|
|
class twister |
|
{ |
|
public: |
|
twister(); |
|
}; |
|
|
|
void startSessionTorrent(boost::thread_group& threadGroup); |
|
void stopSessionTorrent(); |
|
|
|
bool getUserPubKey(std::string const &strUsername, CPubKey &pubkey, int maxHeight = -1); |
|
std::string createSignature(std::string const &strMessage, CKeyID &keyID); |
|
std::string createSignature(std::string const &strMessage, std::string const &strUsername); |
|
bool verifySignature(std::string const &strMessage, std::string const &strUsername, std::string const &strSign, int maxHeight = -1); |
|
|
|
bool acceptSignedPost(char const *data, int data_size, std::string username, int seq, std::string &errmsg, boost::uint32_t *flags); |
|
bool validatePostNumberForUser(std::string const &username, int k); |
|
bool usernameExists(std::string const &username); |
|
|
|
void receivedSpamMessage(std::string const &message, std::string const &user); |
|
|
|
int getBestHeight(); |
|
bool shouldDhtResourceExpire(std::string resource, bool multi, int height); |
|
|
|
int getDhtNodes(boost::int64_t *dht_global_nodes = NULL); |
|
|
|
void updateSeenHashtags(std::string &message, int64_t msgTime); |
|
|
|
// interface to dht api of the libtorrent current session |
|
void dhtGetData(std::string const &username, std::string const &resource, bool multi); |
|
void dhtPutData(std::string const &username, std::string const &resource, bool multi, |
|
libtorrent::entry const &value, std::string const &sig_user, |
|
boost::int64_t timeutc, int seq); |
|
void dhtPutDataSigned(std::string const &username, std::string const &resource, bool multi, |
|
libtorrent::entry const &p, std::string const &sig_p, std::string const &sig_user, bool local); |
|
|
|
#endif // TWISTER_H
|
|
|