Skip to content

Commit

Permalink
update to 0.4 preview
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoManiac committed Apr 15, 2013
1 parent 9cc27ae commit 84a4a77
Show file tree
Hide file tree
Showing 167 changed files with 21,050 additions and 10,336 deletions.
110 changes: 67 additions & 43 deletions novacoin-qt.pro
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
TEMPLATE = app
TARGET = novacoin-qt
VERSION = 0.6.3.0
VERSION = 0.7.2
INCLUDEPATH += src src/json src/qt
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
CONFIG += no_include_pwd
CONFIG += thread

# for boost 1.37, add -mt to the boost libraries
# for boost 1.37, add -mt to the boost libraries
# use: qmake BOOST_LIB_SUFFIX=-mt
# for boost thread win32 with _win32 sufix
# use: BOOST_THREAD_LIB_SUFFIX=_win32-...
# or when linking against a specific BerkelyDB version: BDB_LIB_SUFFIX=-4.8

# Dependency library locations can be customized with BOOST_INCLUDE_PATH,
# BOOST_LIB_PATH, BDB_INCLUDE_PATH, BDB_LIB_PATH
# OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively
# Dependency library locations can be customized with:
# BOOST_INCLUDE_PATH, BOOST_LIB_PATH, BDB_INCLUDE_PATH,
# BDB_LIB_PATH, OPENSSL_INCLUDE_PATH and OPENSSL_LIB_PATH respectively

OBJECTS_DIR = build
MOC_DIR = build
Expand All @@ -30,6 +31,16 @@ contains(RELEASE, 1) {
}
}

!win32 {
# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection
QMAKE_CXXFLAGS *= -fstack-protector-all --param ssp-buffer-size=1
QMAKE_LFLAGS *= -fstack-protector-all --param ssp-buffer-size=1
# We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable!
# This can be enabled for Windows, when we switch to MinGW >= 4.4.x.
}
# for extra security on Windows: enable ASLR and DEP via GCC linker flags
win32:QMAKE_LFLAGS *= -Wl,--dynamicbase -Wl,--nxcompat

# use: qmake "USE_QRCODE=1"
# libqrencode (http://fukuchi.org/works/qrencode/index.en.html) must be installed for support
contains(USE_QRCODE, 1) {
Expand Down Expand Up @@ -62,38 +73,35 @@ contains(USE_DBUS, 1) {
QT += dbus
}

# use: qmake "FIRST_CLASS_MESSAGING=1"
contains(FIRST_CLASS_MESSAGING, 1) {
message(Building with first-class messaging)
DEFINES += FIRST_CLASS_MESSAGING
# use: qmake "USE_IPV6=1" ( enabled by default; default)
# or: qmake "USE_IPV6=0" (disabled by default)
# or: qmake "USE_IPV6=-" (not supported)
contains(USE_IPV6, -) {
message(Building without IPv6 support)
} else {
count(USE_IPV6, 0) {
USE_IPV6=1
}
DEFINES += USE_IPV6=$$USE_IPV6
}

contains(BITCOIN_NEED_QT_PLUGINS, 1) {
DEFINES += BITCOIN_NEED_QT_PLUGINS
QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs qtaccessiblewidgets
}

!windows {
# for extra security against potential buffer overflows
QMAKE_CXXFLAGS += -fstack-protector
QMAKE_LFLAGS += -fstack-protector
# do not enable this on windows, as it will result in a non-working executable!
}

# regenerate src/build.h
!windows | contains(USE_BUILD_INFO, 1) {
!windows|contains(USE_BUILD_INFO, 1) {
genbuild.depends = FORCE
genbuild.commands = cd $$PWD; /bin/sh share/genbuild.sh $$OUT_PWD/build/build.h
genbuild.target = genbuildhook
PRE_TARGETDEPS += genbuildhook
genbuild.target = $$OUT_PWD/build/build.h
PRE_TARGETDEPS += $$OUT_PWD/build/build.h
QMAKE_EXTRA_TARGETS += genbuild
DEFINES += HAVE_BUILD_INFO
}

QMAKE_CXXFLAGS += -msse2
QMAKE_CFLAGS += -msse2

QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wformat-security -Wno-invalid-offsetof -Wno-sign-compare -Wno-unused-parameter
QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector

# Input
DEPENDPATH += src src/json src/qt
Expand All @@ -103,20 +111,23 @@ HEADERS += src/qt/bitcoingui.h \
src/qt/optionsdialog.h \
src/qt/sendcoinsdialog.h \
src/qt/addressbookpage.h \
src/qt/messagepage.h \
src/qt/signverifymessagedialog.h \
src/qt/aboutdialog.h \
src/qt/editaddressdialog.h \
src/qt/bitcoinaddressvalidator.h \
src/alert.h \
src/addrman.h \
src/base58.h \
src/bignum.h \
src/checkpoints.h \
src/compat.h \
src/sync.h \
src/util.h \
src/uint256.h \
src/serialize.h \
src/kernel.h \
src/scrypt_mine.h \
src/pbkdf2.h \
src/serialize.h \
src/strlcpy.h \
src/main.h \
src/net.h \
Expand Down Expand Up @@ -164,36 +175,36 @@ HEADERS += src/qt/bitcoingui.h \
src/qt/qtipcserver.h \
src/allocators.h \
src/ui_interface.h \
src/kernel.h
src/qt/rpcconsole.h \
src/version.h \
src/netbase.h \
src/clientversion.h

SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/transactiontablemodel.cpp \
src/qt/addresstablemodel.cpp \
src/qt/optionsdialog.cpp \
src/qt/sendcoinsdialog.cpp \
src/qt/addressbookpage.cpp \
src/qt/messagepage.cpp \
src/qt/signverifymessagedialog.cpp \
src/qt/aboutdialog.cpp \
src/qt/editaddressdialog.cpp \
src/qt/bitcoinaddressvalidator.cpp \
src/alert.cpp \
src/version.cpp \
src/sync.cpp \
src/util.cpp \
src/netbase.cpp \
src/key.cpp \
src/script.cpp \
src/main.cpp \
src/scrypt_mine.cpp \
src/pbkdf2.cpp \
src/init.cpp \
src/net.cpp \
src/irc.cpp \
src/checkpoints.cpp \
src/addrman.cpp \
src/db.cpp \
src/walletdb.cpp \
src/json/json_spirit_writer.cpp \
src/json/json_spirit_value.cpp \
src/json/json_spirit_reader.cpp \
src/qt/clientmodel.cpp \
src/qt/guiutil.cpp \
src/qt/transactionrecord.cpp \
Expand All @@ -210,6 +221,11 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/walletmodel.cpp \
src/bitcoinrpc.cpp \
src/rpcdump.cpp \
src/rpcnet.cpp \
src/rpcmining.cpp \
src/rpcwallet.cpp \
src/rpcblockchain.cpp \
src/rpcrawtransaction.cpp \
src/qt/overviewpage.cpp \
src/qt/csvmodelwriter.cpp \
src/crypter.cpp \
Expand All @@ -221,24 +237,29 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/protocol.cpp \
src/qt/notificator.cpp \
src/qt/qtipcserver.cpp \
src/qt/rpcconsole.cpp \
src/noui.cpp \
src/kernel.cpp \
src/scrypt-x86.S \
src/scrypt-x86_64.S

src/scrypt-x86_64.S \
src/scrypt_mine.cpp \
src/pbkdf2.cpp

RESOURCES += \
src/qt/bitcoin.qrc

FORMS += \
src/qt/forms/sendcoinsdialog.ui \
src/qt/forms/addressbookpage.ui \
src/qt/forms/messagepage.ui \
src/qt/forms/signverifymessagedialog.ui \
src/qt/forms/aboutdialog.ui \
src/qt/forms/editaddressdialog.ui \
src/qt/forms/transactiondescdialog.ui \
src/qt/forms/overviewpage.ui \
src/qt/forms/sendcoinsentry.ui \
src/qt/forms/askpassphrasedialog.ui
src/qt/forms/askpassphrasedialog.ui \
src/qt/forms/rpcconsole.ui \
src/qt/forms/optionsdialog.ui

contains(USE_QRCODE, 1) {
HEADERS += src/qt/qrcodedialog.h
Expand Down Expand Up @@ -266,24 +287,23 @@ isEmpty(QMAKE_LRELEASE) {
win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\\lrelease.exe
else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease
}
isEmpty(TS_DIR):TS_DIR = src/qt/locale
isEmpty(QM_DIR):QM_DIR = $$PWD/src/qt/locale
# automatically build translations, so they can be included in resource file
TSQM.name = lrelease ${QMAKE_FILE_IN}
TSQM.input = TRANSLATIONS
TSQM.output = $$TS_DIR/${QMAKE_FILE_BASE}.qm
TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN}
TSQM.output = $$QM_DIR/${QMAKE_FILE_BASE}.qm
TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT}
TSQM.CONFIG = no_link
QMAKE_EXTRA_COMPILERS += TSQM
PRE_TARGETDEPS += compiler_TSQM_make_all

# "Other files" to show in Qt Creator
OTHER_FILES += \
doc/*.rst doc/*.txt doc/README README.md res/bitcoin-qt.rc
doc/*.rst doc/*.txt doc/README README.md res/bitcoin-qt.rc src/test/*.cpp src/test/*.h src/qt/test/*.cpp src/qt/test/*.h

# platform specific defaults, if not overridden on command line
isEmpty(BOOST_LIB_SUFFIX) {
macx:BOOST_LIB_SUFFIX = -mt
windows:BOOST_LIB_SUFFIX = -mgw44-mt-1_53
windows:BOOST_LIB_SUFFIX = -mgw44-mt-s-1_50
}

isEmpty(BOOST_THREAD_LIB_SUFFIX) {
Expand Down Expand Up @@ -324,7 +344,7 @@ windows:!contains(MINGW_THREAD_BUGFIX, 0) {
QMAKE_LIBS_QT_ENTRY = -lmingwthrd $$QMAKE_LIBS_QT_ENTRY
}

!windows:!mac {
!windows:!macx {
DEFINES += LINUX
LIBS += -lrt
}
Expand All @@ -335,14 +355,18 @@ macx:LIBS += -framework Foundation -framework ApplicationServices -framework App
macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0
macx:ICON = src/qt/res/icons/bitcoin.icns
macx:TARGET = "NovaCoin-Qt"
macx:QMAKE_CFLAGS_THREAD += -pthread
macx:QMAKE_LFLAGS_THREAD += -pthread
macx:QMAKE_CXXFLAGS_THREAD += -pthread

# Set libraries and includes at end, to use platform-defined defaults if not overridden
INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH
LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,)
LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX
# -lgdi32 has to happen after -lcrypto (see #681)
windows:LIBS += -lmswsock -loleaut32 -lws2_32 -lshlwapi -lole32 -luuid -lgdi32
windows:LIBS += -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32
LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX
windows:LIBS += -lboost_chrono$$BOOST_LIB_SUFFIX

contains(RELEASE, 1) {
!windows:!macx {
Expand Down
11 changes: 5 additions & 6 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,11 @@ CAddrInfo* CAddrMan::Create(const CAddress &addr, const CNetAddr &addrSource, in
return &mapInfo[nId];
}

void CAddrMan::SwapRandom(int nRndPos1, int nRndPos2)
void CAddrMan::SwapRandom(unsigned int nRndPos1, unsigned int nRndPos2)
{
if (nRndPos1 == nRndPos2)
return;

assert(nRndPos1 >= 0 && nRndPos2 >= 0);
assert(nRndPos1 < vRandom.size() && nRndPos2 < vRandom.size());

int nId1 = vRandom[nRndPos1];
Expand Down Expand Up @@ -149,7 +148,7 @@ int CAddrMan::SelectTried(int nKBucket)

int CAddrMan::ShrinkNew(int nUBucket)
{
assert(nUBucket >= 0 && nUBucket < vvNew.size());
assert(nUBucket >= 0 && (unsigned int)nUBucket < vvNew.size());
std::set<int> &vNew = vvNew[nUBucket];

// first look for deletable items
Expand Down Expand Up @@ -188,7 +187,7 @@ int CAddrMan::ShrinkNew(int nUBucket)
}
assert(mapInfo.count(nOldest) == 1);
CAddrInfo &info = mapInfo[nOldest];
if (--info.nRefCount == 0)
if (--info.nRefCount == 0)
{
SwapRandom(info.nRandomPos, vRandom.size()-1);
vRandom.pop_back();
Expand Down Expand Up @@ -242,7 +241,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
infoOld.nRefCount = 1;
// do not update nTried, as we are going to move something else there immediately

// check whether there is place in that one,
// check whether there is place in that one,
if (vNew.size() < ADDRMAN_NEW_BUCKET_SIZE)
{
// if so, move it back there
Expand Down Expand Up @@ -411,7 +410,7 @@ CAddress CAddrMan::Select_(int nUnkBias)
fChanceFactor *= 1.2;
}
} else {
// use an new node
// use a new node
double fChanceFactor = 1.0;
while(1)
{
Expand Down
19 changes: 10 additions & 9 deletions src/addrman.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "netbase.h"
#include "protocol.h"
#include "util.h"
#include "sync.h"


#include <map>
Expand All @@ -22,13 +23,13 @@ class CAddrInfo : public CAddress
// where knowledge about this address first came from
CNetAddr source;

// last succesfull connection by us
// last successful connection by us
int64 nLastSuccess;

// last try whatsoever by us:
// int64 CAddress::nLastTry

// connection attempts since last succesful attempt
// connection attempts since last successful attempt
int nAttempts;

// reference count in new sets (memory only)
Expand Down Expand Up @@ -116,7 +117,7 @@ class CAddrInfo : public CAddress
// * Bucket selection is based on cryptographic hashing, using a randomly-generated 256-bit key, which should not
// be observable by adversaries.
// * Several indexes are kept for high performance. Defining DEBUG_ADDRMAN will introduce frequent (and expensive)
// consistency checks for the entire datastructure.
// consistency checks for the entire data structure.

// total number of buckets for tried addresses
#define ADDRMAN_TRIED_BUCKET_COUNT 64
Expand Down Expand Up @@ -173,13 +174,13 @@ class CAddrMan
// last used nId
int nIdCount;

// table with information about all nId's
// table with information about all nIds
std::map<int, CAddrInfo> mapInfo;

// find an nId based on its network address
std::map<CNetAddr, int> mapAddr;

// randomly-ordered vector of all nId's
// randomly-ordered vector of all nIds
std::vector<int> vRandom;

// number of "tried" entries
Expand All @@ -204,7 +205,7 @@ class CAddrMan
CAddrInfo* Create(const CAddress &addr, const CNetAddr &addrSource, int *pnId = NULL);

// Swap two elements in vRandom.
void SwapRandom(int nRandomPos1, int nRandomPos2);
void SwapRandom(unsigned int nRandomPos1, unsigned int nRandomPos2);

// Return position in given bucket to replace.
int SelectTried(int nKBucket);
Expand All @@ -213,7 +214,7 @@ class CAddrMan
// This is the only place where actual deletes occur.
// They are never deleted while in the "tried" table, only possibly evicted back to the "new" table.
int ShrinkNew(int nUBucket);

// Move an entry from the "new" table(s) to the "tried" table
// @pre vvUnkown[nOrigin].count(nId) != 0
void MakeTried(CAddrInfo& info, int nId, int nOrigin);
Expand Down Expand Up @@ -252,8 +253,8 @@ class CAddrMan
// * nNew
// * nTried
// * number of "new" buckets
// * all nNew addrinfo's in vvNew
// * all nTried addrinfo's in vvTried
// * all nNew addrinfos in vvNew
// * all nTried addrinfos in vvTried
// * for each bucket:
// * number of elements
// * for each element: index
Expand Down
Loading

0 comments on commit 84a4a77

Please sign in to comment.