Skip to content

Commit

Permalink
2.1 (#16)
Browse files Browse the repository at this point in the history
* update JSON library

* update LevelDB to 1.18

* syncing optimizations

*  update GUI

* add checkpoint
  • Loading branch information
withthelemons authored Jan 10, 2018
1 parent 588de7b commit a410002
Show file tree
Hide file tree
Showing 263 changed files with 20,434 additions and 9,154 deletions.
97 changes: 62 additions & 35 deletions hempcoin-qt.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ TEMPLATE = app
TARGET = hempcoin-qt
VERSION = 0.7.5
INCLUDEPATH += src src/json src/qt
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE
QT += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE __STDC_FORMAT_MACROS __STDC_LIMIT_MACROS
CONFIG += no_include_pwd
CONFIG += thread
CONFIG += static
CONFIG += widgets
QT += core gui network widgets

DEFINES += USE_SSE2 USE_SSE2_ALWAYS
DEFINES += USE_SSE2

QMAKE_CXXFLAGS = -fpermissive -msse2
QMAKE_CXXFLAGS = -fpermissive

greaterThan(QT_MAJOR_VERSION, 4) {
QT += widgets
Expand Down Expand Up @@ -167,6 +167,7 @@ QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wno-ignored-qu
# Input
DEPENDPATH += src src/json src/qt
HEADERS += src/qt/bitcoingui.h \
src/qt/intro.h \
src/qt/transactiontablemodel.h \
src/qt/addresstablemodel.h \
src/qt/optionsdialog.h \
Expand All @@ -178,6 +179,10 @@ HEADERS += src/qt/bitcoingui.h \
src/qt/aboutdialog.h \
src/qt/editaddressdialog.h \
src/qt/bitcoinaddressvalidator.h \
src/qt/mintingfilterproxy.h \
src/qt/mintingtablemodel.h \
src/qt/mintingview.h \
src/kernelrecord.h \
src/alert.h \
src/addrman.h \
src/base58.h \
Expand All @@ -188,25 +193,16 @@ HEADERS += src/qt/bitcoingui.h \
src/sync.h \
src/util.h \
src/timestamps.h \
src/hash.h \
src/uint256.h \
src/kernel.h \
src/kernel_worker.h \
src/scrypt.h \
src/zerocoin/Accumulator.h \
src/zerocoin/AccumulatorProofOfKnowledge.h \
src/zerocoin/Coin.h \
src/zerocoin/CoinSpend.h \
src/zerocoin/Commitment.h \
src/zerocoin/ParamGeneration.h \
src/zerocoin/Params.h \
src/zerocoin/SerialNumberSignatureOfKnowledge.h \
src/zerocoin/SpendMetaData.h \
src/zerocoin/ZeroTest.h \
src/zerocoin/Zerocoin.h \
src/serialize.h \
src/strlcpy.h \
src/main.h \
src/miner.h \
src/net.h \
src/ministun.h \
src/key.h \
src/db.h \
src/txdb.h \
Expand Down Expand Up @@ -247,17 +243,26 @@ HEADERS += src/qt/bitcoingui.h \
src/qt/bitcoinunits.h \
src/qt/qvaluecombobox.h \
src/qt/askpassphrasedialog.h \
src/qt/trafficgraphwidget.h \
src/protocol.h \
src/qt/notificator.h \
src/qt/qtipcserver.h \
src/allocators.h \
src/ui_interface.h \
src/qt/rpcconsole.h \
src/version.h \
src/ntp.h \
src/netbase.h \
src/clientversion.h
src/clientversion.h \
src/qt/multisigaddressentry.h \
src/qt/multisiginputentry.h \
src/qt/multisigdialog.h \
src/qt/secondauthdialog.h \
src/ies.h \
src/ipcollector.h

SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/intro.cpp \
src/qt/transactiontablemodel.cpp \
src/qt/addresstablemodel.cpp \
src/qt/optionsdialog.cpp \
Expand All @@ -269,18 +274,27 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/aboutdialog.cpp \
src/qt/editaddressdialog.cpp \
src/qt/bitcoinaddressvalidator.cpp \
src/qt/trafficgraphwidget.cpp \
src/qt/mintingfilterproxy.cpp \
src/qt/mintingtablemodel.cpp \
src/qt/mintingview.cpp \
src/kernelrecord.cpp \
src/alert.cpp \
src/version.cpp \
src/sync.cpp \
src/util.cpp \
src/netbase.cpp \
src/ntp.cpp \
src/key.cpp \
src/script.cpp \
src/main.cpp \
src/miner.cpp \
src/init.cpp \
src/net.cpp \
src/stun.cpp \
src/irc.cpp \
src/scrypt.cpp \
src/scrypt-sse2.cpp \
src/checkpoints.cpp \
src/addrman.cpp \
src/db.cpp \
Expand All @@ -300,6 +314,7 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/transactionview.cpp \
src/qt/walletmodel.cpp \
src/bitcoinrpc.cpp \
src/rpccrypt.cpp \
src/rpcdump.cpp \
src/rpcnet.cpp \
src/rpcmining.cpp \
Expand All @@ -320,24 +335,22 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \
src/qt/rpcconsole.cpp \
src/noui.cpp \
src/kernel.cpp \
src/scrypt.cpp \
src/scrypt-sse2.cpp \
src/zerocoin/Accumulator.cpp \
src/zerocoin/AccumulatorProofOfKnowledge.cpp \
src/zerocoin/Coin.cpp \
src/zerocoin/CoinSpend.cpp \
src/zerocoin/Commitment.cpp \
src/zerocoin/ParamGeneration.cpp \
src/zerocoin/Params.cpp \
src/zerocoin/SerialNumberSignatureOfKnowledge.cpp \
src/zerocoin/SpendMetaData.cpp \
src/zerocoin/ZeroTest.cpp
src/kernel_worker.cpp \
src/qt/multisigaddressentry.cpp \
src/qt/multisiginputentry.cpp \
src/qt/multisigdialog.cpp \
src/qt/secondauthdialog.cpp \
src/base58.cpp \
src/cryptogram.cpp \
src/ecies.cpp \
src/ipcollector.cpp

RESOURCES += \
src/qt/bitcoin.qrc \
src/qt/Background.qrc

FORMS += \
src/qt/forms/intro.ui \
src/qt/forms/coincontroldialog.ui \
src/qt/forms/sendcoinsdialog.ui \
src/qt/forms/addressbookpage.ui \
Expand All @@ -349,12 +362,16 @@ FORMS += \
src/qt/forms/sendcoinsentry.ui \
src/qt/forms/askpassphrasedialog.ui \
src/qt/forms/rpcconsole.ui \
src/qt/forms/optionsdialog.ui
src/qt/forms/optionsdialog.ui \
src/qt/forms/multisigaddressentry.ui \
src/qt/forms/multisiginputentry.ui \
src/qt/forms/multisigdialog.ui \
src/qt/forms/secondauthdialog.ui

contains(USE_QRCODE, 1) {
HEADERS += src/qt/qrcodedialog.h
SOURCES += src/qt/qrcodedialog.cpp
FORMS += src/qt/forms/qrcodedialog.ui
HEADERS += src/qt/qrcodedialog.h
SOURCES += src/qt/qrcodedialog.cpp
FORMS += src/qt/forms/qrcodedialog.ui
}

CODECFORTR = UTF-8
Expand Down Expand Up @@ -455,4 +472,14 @@ contains(RELEASE, 1) {
}
}

system($$QMAKE_LRELEASE -silent $$_PRO_FILE_)
linux-* {
# We may need some linuxism here
LIBS += -ldl
}

netbsd-*|freebsd-*|openbsd-* {
# libexecinfo is required for back trace
LIBS += -lexecinfo
}

system($$QMAKE_LRELEASE -silent $$PWD/src/qt/locale/translations.pro)
50 changes: 31 additions & 19 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "addrman.h"
#include "hash.h"

using namespace std;

Expand All @@ -11,12 +12,12 @@ int CAddrInfo::GetTriedBucket(const std::vector<unsigned char> &nKey) const
CDataStream ss1(SER_GETHASH, 0);
std::vector<unsigned char> vchKey = GetKey();
ss1 << nKey << vchKey;
uint64 hash1 = Hash(ss1.begin(), ss1.end()).Get64();
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).Get64();

CDataStream ss2(SER_GETHASH, 0);
std::vector<unsigned char> vchGroupKey = GetGroup();
ss2 << nKey << vchGroupKey << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP);
uint64 hash2 = Hash(ss2.begin(), ss2.end()).Get64();
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).Get64();
return hash2 % ADDRMAN_TRIED_BUCKET_COUNT;
}

Expand All @@ -26,15 +27,15 @@ int CAddrInfo::GetNewBucket(const std::vector<unsigned char> &nKey, const CNetAd
std::vector<unsigned char> vchGroupKey = GetGroup();
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup();
ss1 << nKey << vchGroupKey << vchSourceGroupKey;
uint64 hash1 = Hash(ss1.begin(), ss1.end()).Get64();
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).Get64();

CDataStream ss2(SER_GETHASH, 0);
ss2 << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP);
uint64 hash2 = Hash(ss2.begin(), ss2.end()).Get64();
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).Get64();
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
}

bool CAddrInfo::IsTerrible(int64 nNow) const
bool CAddrInfo::IsTerrible(int64_t nNow) const
{
if (nLastTry && nLastTry >= nNow-60) // never remove things tried the last minute
return false;
Expand All @@ -54,12 +55,12 @@ bool CAddrInfo::IsTerrible(int64 nNow) const
return false;
}

double CAddrInfo::GetChance(int64 nNow) const
double CAddrInfo::GetChance(int64_t nNow) const
{
double fChance = 1.0;

int64 nSinceLastSeen = nNow - nTime;
int64 nSinceLastTry = nNow - nLastTry;
int64_t nSinceLastSeen = nNow - nTime;
int64_t nSinceLastTry = nNow - nLastTry;

if (nSinceLastSeen < 0) nSinceLastSeen = 0;
if (nSinceLastTry < 0) nSinceLastTry = 0;
Expand Down Expand Up @@ -128,7 +129,7 @@ int CAddrMan::SelectTried(int nKBucket)

// random shuffle the first few elements (using the entire list)
// find the least recently tried among them
int64 nOldest = -1;
int64_t nOldest = -1;
int nOldestPos = -1;
for (unsigned int i = 0; i < ADDRMAN_TRIED_ENTRIES_INSPECT_ON_EVICT && i < vTried.size(); i++)
{
Expand Down Expand Up @@ -258,7 +259,7 @@ void CAddrMan::MakeTried(CAddrInfo& info, int nId, int nOrigin)
return;
}

void CAddrMan::Good_(const CService &addr, int64 nTime)
void CAddrMan::Good_(const CService &addr, int64_t nTime)
{
// printf("Good: addr=%s\n", addr.ToString().c_str());

Expand Down Expand Up @@ -309,7 +310,7 @@ void CAddrMan::Good_(const CService &addr, int64 nTime)
MakeTried(info, nId, nUBucket);
}

bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePenalty)
bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty)
{
if (!addr.IsRoutable())
return false;
Expand All @@ -322,9 +323,9 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePen
{
// periodically update nTime
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
int64 nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
if (addr.nTime && (!pinfo->nTime || pinfo->nTime < addr.nTime - nUpdateInterval - nTimePenalty))
pinfo->nTime = max((int64)0, addr.nTime - nTimePenalty);
pinfo->nTime = max((int64_t)0, addr.nTime - nTimePenalty);

// add services
pinfo->nServices |= addr.nServices;
Expand All @@ -349,7 +350,7 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePen
return false;
} else {
pinfo = Create(addr, source, &nId);
pinfo->nTime = max((int64)0, (int64)pinfo->nTime - nTimePenalty);
pinfo->nTime = max((int64_t)0, (int64_t)pinfo->nTime - nTimePenalty);
// printf("Added %s [nTime=%fhr]\n", pinfo->ToString().c_str(), (GetAdjustedTime() - pinfo->nTime) / 3600.0);
nNew++;
fNew = true;
Expand All @@ -367,7 +368,7 @@ bool CAddrMan::Add_(const CAddress &addr, const CNetAddr& source, int64 nTimePen
return fNew;
}

void CAddrMan::Attempt_(const CService &addr, int64 nTime)
void CAddrMan::Attempt_(const CService &addr, int64_t nTime)
{
CAddrInfo *pinfo = Find(addr);

Expand Down Expand Up @@ -492,12 +493,12 @@ int CAddrMan::Check_()

void CAddrMan::GetAddr_(std::vector<CAddress> &vAddr)
{
int nNodes = ADDRMAN_GETADDR_MAX_PCT*vRandom.size()/100;
size_t nNodes = ADDRMAN_GETADDR_MAX_PCT*vRandom.size()/100;
if (nNodes > ADDRMAN_GETADDR_MAX)
nNodes = ADDRMAN_GETADDR_MAX;

// perform a random shuffle over the first nNodes elements of vRandom (selecting from all)
for (int n = 0; n<nNodes; n++)
for (unsigned int n = 0; n<nNodes; n++)
{
int nRndPos = GetRandInt(vRandom.size() - n) + n;
SwapRandom(n, nRndPos);
Expand All @@ -506,7 +507,18 @@ void CAddrMan::GetAddr_(std::vector<CAddress> &vAddr)
}
}

void CAddrMan::Connected_(const CService &addr, int64 nTime)
void CAddrMan::GetOnlineAddr_(std::vector<CAddrInfo> &vAddr)
{
for (std::map<int, CAddrInfo>::const_iterator it = mapInfo.begin(); it != mapInfo.end(); it++)
{
CAddrInfo addr = it->second;
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < nOneDay);
if (fCurrentlyOnline)
vAddr.push_back(addr);
}
}

void CAddrMan::Connected_(const CService &addr, int64_t nTime)
{
CAddrInfo *pinfo = Find(addr);

Expand All @@ -521,7 +533,7 @@ void CAddrMan::Connected_(const CService &addr, int64 nTime)
return;

// update info
int64 nUpdateInterval = 20 * 60;
int64_t nUpdateInterval = 20 * 60;
if (nTime - info.nTime > nUpdateInterval)
info.nTime = nTime;
}
Loading

0 comments on commit a410002

Please sign in to comment.