Browse Source

first hack compiling bitcoind (twister) + libtorrent

miguelfreitas
Miguel Freitas 12 years ago
parent
commit
fb00bb154e
  1. 2
      src/bitcoind.cpp
  2. 54
      src/init.cpp
  3. 7
      twister-qt.pro

2
src/bitcoind.cpp

@ -182,8 +182,6 @@ static bool TestCreateSpamMsgTx()
exit(1); exit(1);
} }
extern void GenesisMiner(); extern void GenesisMiner();
extern void noui_connect(); extern void noui_connect();
int main(int argc, char* argv[]) int main(int argc, char* argv[])

54
src/init.cpp

@ -32,6 +32,8 @@ using namespace boost;
CWallet* pwalletMain; CWallet* pwalletMain;
CClientUIInterface uiInterface; CClientUIInterface uiInterface;
void startSessionTorrent(boost::thread_group& threadGroup);
#ifdef WIN32 #ifdef WIN32
// Win32 LevelDB doesn't use filedescriptors, and the ones used for // Win32 LevelDB doesn't use filedescriptors, and the ones used for
// accessing block files, don't count towards to fd_set size limit // accessing block files, don't count towards to fd_set size limit
@ -947,5 +949,57 @@ bool AppInit2(boost::thread_group& threadGroup)
// Run a thread to flush wallet periodically // Run a thread to flush wallet periodically
threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile))); threadGroup.create_thread(boost::bind(&ThreadFlushWalletDB, boost::ref(pwalletMain->strWalletFile)));
startSessionTorrent(threadGroup);
return !fRequestShutdown; return !fRequestShutdown;
} }
// ===================== LIBTORRENT & DHT ===========================
#include "libtorrent/config.hpp"
#include "libtorrent/entry.hpp"
#include "libtorrent/bencode.hpp"
#include "libtorrent/session.hpp"
using namespace libtorrent;
static session *ses;
void startSessionTorrent(boost::thread_group& threadGroup)
{
error_code ec;
int listen_port = GetListenPort() + 1000;
std::string bind_to_interface = "";
printf("startSessionTorrent port=%d\n", listen_port);
ses = new session(fingerprint("LT", LIBTORRENT_VERSION_MAJOR, LIBTORRENT_VERSION_MINOR, 0, 0)
, session::add_default_plugins
, alert::all_categories
& ~(alert::dht_notification
+ alert::progress_notification
+ alert::debug_notification
+ alert::stats_notification));
/*
std::vector<char> in;
if (load_file(".ses_state", in, ec) == 0)
{
lazy_entry e;
if (lazy_bdecode(&in[0], &in[0] + in.size(), e, ec) == 0)
ses.load_state(e);
}
*/
ses->listen_on(std::make_pair(listen_port, listen_port)
, ec, bind_to_interface.c_str());
if (ec)
{
fprintf(stderr, "failed to listen%s%s on ports %d-%d: %s\n"
, bind_to_interface.empty() ? "" : " on ", bind_to_interface.c_str()
, listen_port, listen_port+1, ec.message().c_str());
}
ses->start_dht();
printf("libtorrent + dht started\n");
}

7
twister-qt.pro

@ -119,6 +119,13 @@ QMAKE_EXTRA_TARGETS += genleveldb
# Gross ugly hack that depends on qmake internals, unfortunately there is no other way to do it. # Gross ugly hack that depends on qmake internals, unfortunately there is no other way to do it.
QMAKE_CLEAN += $$PWD/src/leveldb/libleveldb.a; cd $$PWD/src/leveldb ; $(MAKE) clean QMAKE_CLEAN += $$PWD/src/leveldb/libleveldb.a; cd $$PWD/src/leveldb ; $(MAKE) clean
# libtorrent hack
INCLUDEPATH += libtorrent/include
LIBS += $$PWD/libtorrent/src/.libs/libtorrent-rasterbar.a
DEFINES += TORRENT_DEBUG
DEFINES += BOOST_ASIO_SEPARATE_COMPILATION
#DEFINES += BOOST_ASIO_DYN_LINK
# regenerate src/build.h # regenerate src/build.h
!win32|contains(USE_BUILD_INFO, 1) { !win32|contains(USE_BUILD_INFO, 1) {
genbuild.depends = FORCE genbuild.depends = FORCE

Loading…
Cancel
Save