Skip to content

Commit 7a0df8c

Browse files
Merge pull request #68 from vertoe/devel-0.9
Align branches with upstream
2 parents 0184cf7 + c2cf2fb commit 7a0df8c

File tree

15 files changed

+55
-98
lines changed

15 files changed

+55
-98
lines changed

Makefile.am

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ BITCOIN_QT_BIN=$(top_builddir)/src/qt/darkcoin-qt$(EXEEXT)
99
BITCOIN_CLI_BIN=$(top_builddir)/src/darkcoin-cli$(EXEEXT)
1010
BITCOIN_WIN_INSTALLER=$(PACKAGE)-$(PACKAGE_VERSION)-win$(WINDOWS_BITS)-setup$(EXEEXT)
1111

12-
OSX_APP=Bitcoin-Qt.app
13-
OSX_DMG=Bitcoin-Qt.dmg
12+
OSX_APP=Darkcoin-Qt.app
13+
OSX_DMG=Darkcoin-Qt.dmg
1414
OSX_DEPLOY_SCRIPT=$(top_srcdir)/contrib/macdeploy/macdeployqtplus
1515
OSX_FANCY_PLIST=$(top_srcdir)/contrib/macdeploy/fancy.plist
1616
OSX_INSTALLER_ICONS=$(top_srcdir)/src/qt/res/icons/bitcoin.icns
@@ -72,13 +72,13 @@ $(OSX_APP)/Contents/Resources/bitcoin.icns: $(OSX_INSTALLER_ICONS)
7272
$(MKDIR_P) $(@D)
7373
$(INSTALL_DATA) $< $@
7474

75-
$(OSX_APP)/Contents/MacOS/Bitcoin-Qt: $(BITCOIN_QT_BIN)
75+
$(OSX_APP)/Contents/MacOS/Darkcoin-Qt: $(BITCOIN_QT_BIN)
7676
$(MKDIR_P) $(@D)
7777
STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $< $@
7878

7979
OSX_APP_BUILT=$(OSX_APP)/Contents/PkgInfo $(OSX_APP)/Contents/Resources/empty.lproj \
8080
$(OSX_APP)/Contents/Resources/bitcoin.icns $(OSX_APP)/Contents/Info.plist \
81-
$(OSX_APP)/Contents/MacOS/Bitcoin-Qt
81+
$(OSX_APP)/Contents/MacOS/Darkcoin-Qt
8282

8383
if BUILD_DARWIN
8484
$(OSX_DMG): $(OSX_APP_BUILT) $(OSX_PACKAGING)
@@ -91,7 +91,7 @@ $(OSX_DMG): $(OSX_APP_BUILT) $(OSX_PACKAGING)
9191
$(INSTALL) contrib/macdeploy/background.png dist/.background
9292
$(INSTALL) contrib/macdeploy/DS_Store dist/.DS_Store
9393
cd dist; $(LN_S) /Applications Applications
94-
$(GENISOIMAGE) -no-cache-inodes -l -probe -V "Bitcoin-Qt" -no-pad -r -apple -o $@ dist
94+
$(GENISOIMAGE) -no-cache-inodes -l -probe -V "Darkcoin-Qt" -no-pad -r -apple -o $@ dist
9595
endif
9696

9797
if TARGET_DARWIN

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ DONE:
2323
- Reset testnet (v4) with new genesis and address version (start with x)
2424
- BIP0032 addresses xpub and xpriv start with x (unchanged by design)
2525
- Changed Darkcoin units to DRK and added duffs
26+
- Fixed internal walletminer
2627

2728

2829
MANDATORY:

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,11 +563,11 @@ fi
563563

564564
BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)
565565

566-
AC_MSG_CHECKING([whether to build bitcoind])
566+
AC_MSG_CHECKING([whether to build darkcoind])
567567
AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
568568
AC_MSG_RESULT($build_bitcoind)
569569

570-
AC_MSG_CHECKING([whether to build bitcoin-cli])
570+
AC_MSG_CHECKING([whether to build darkcoin-cli])
571571
AM_CONDITIONAL([BUILD_BITCOIN_CLI], [test x$build_bitcoin_cli = xyes])
572572
AC_MSG_RESULT($build_bitcoin_cli)
573573

src/chainparams.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class CTestNetParams : public CMainParams {
133133

134134
base58Prefixes[PUBKEY_ADDRESS] = list_of(138); // Testnet v4 addresses start with x
135135
base58Prefixes[SCRIPT_ADDRESS] = list_of(196);
136-
base58Prefixes[SECRET_KEY] = list_of(239);
136+
base58Prefixes[SECRET_KEY] = list_of(266);
137137
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF);
138138
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94);
139139
}

src/darkcoind.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
*
2222
* \section intro_sec Introduction
2323
*
24-
* This is the developer documentation of the reference client for an experimental new digital currency called Bitcoin (http://www.bitcoin.org/),
25-
* which enables instant payments to anyone, anywhere in the world. Bitcoin uses peer-to-peer technology to operate
24+
* This is the developer documentation of the reference client for an experimental new digital currency called Darkcoin (http://www.darkcoin.io/),
25+
* which enables instant payments to anyone, anywhere in the world. Darkcoin uses peer-to-peer technology to operate
2626
* with no central authority: managing transactions and issuing money are carried out collectively by the network.
2727
*
2828
* The software is a community-driven open source project, released under the MIT license.
@@ -86,11 +86,11 @@ bool AppInit(int argc, char* argv[])
8686

8787
if (mapArgs.count("-?") || mapArgs.count("--help"))
8888
{
89-
// First part of help message is specific to bitcoind / RPC client
89+
// First part of help message is specific to darkcoind / RPC client
9090
std::string strUsage = _("Darkcoin Core Daemon") + " " + _("version") + " " + FormatFullVersion() + "\n\n" +
9191
_("Usage:") + "\n" +
9292
" darkcoind [options] " + _("Start Darkcoin Core Daemon") + "\n" +
93-
_("Usage (deprecated, use bitcoin-cli):") + "\n" +
93+
_("Usage (deprecated, use darkcoin-cli):") + "\n" +
9494
" darkcoind [options] <command> [params] " + _("Send command to Darkcoin Core") + "\n" +
9595
" darkcoind [options] help " + _("List commands") + "\n" +
9696
" darkcoind [options] help <command> " + _("Get help for a command") + "\n";
@@ -105,7 +105,7 @@ bool AppInit(int argc, char* argv[])
105105
// Command-line RPC
106106
bool fCommandLine = false;
107107
for (int i = 1; i < argc; i++)
108-
if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "bitcoin:"))
108+
if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "darkcoin:"))
109109
fCommandLine = true;
110110

111111
if (fCommandLine)
@@ -177,7 +177,7 @@ int main(int argc, char* argv[])
177177

178178
bool fRet = false;
179179

180-
// Connect bitcoind signal handlers
180+
// Connect darkcoind signal handlers
181181
noui_connect();
182182

183183
fRet = AppInit(argc, argv);

src/m4/bitcoin_qt.m4

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ dnl Output: If qt version is auto, set bitcoin_enable_qt to false. Else, exit.
33
AC_DEFUN([BITCOIN_QT_FAIL],[
44
if test "x$bitcoin_qt_want_version" = "xauto" && test x$bitcoin_qt_force != xyes; then
55
if test x$bitcoin_enable_qt != xno; then
6-
AC_MSG_WARN([$1; bitcoin-qt frontend will not be built])
6+
AC_MSG_WARN([$1; darkcoin-qt frontend will not be built])
77
fi
88
bitcoin_enable_qt=no
99
else
@@ -123,7 +123,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
123123
124124
125125
dnl enable qt support
126-
AC_MSG_CHECKING(whether to build Bitcoin Core GUI)
126+
AC_MSG_CHECKING(whether to build Darkcoin Core GUI)
127127
BITCOIN_QT_CHECK([
128128
bitcoin_enable_qt=yes
129129
bitcoin_enable_qt_test=yes
@@ -343,14 +343,14 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[
343343
dnl check a header to find out. When Qt is built statically, some plugins must
344344
dnl be linked into the final binary as well. These plugins have changed between
345345
dnl Qt4 and Qt5. With Qt5, languages moved into core and the WindowsIntegration
346-
dnl plugin was added. Since we can't tell if Qt4 is static or not, it is
346+
dnl plugin was added. Since we can't tell if Qt4 is static or not, it is
347347
dnl assumed for all non-pkg-config builds.
348348
dnl _BITCOIN_QT_CHECK_STATIC_PLUGINS does a quick link-check and appends the
349349
dnl results to QT_LIBS.
350350
BITCOIN_QT_CHECK([
351351
if test x$bitcoin_qt_got_major_vers == x5; then
352352
_BITCOIN_QT_IS_STATIC
353-
if test x$bitcoin_cv_static_qt == xyes; then
353+
if test x$bitcoin_cv_static_qt == xyes; then
354354
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
355355
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(AccessibleFactory)], [-lqtaccessiblewidgets])
356356
if test x$TARGET_OS == xwindows; then

src/main.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void EraseOrphansFor(NodeId peer);
7777
// Constant stuff for coinbase transactions we create:
7878
CScript COINBASE_FLAGS;
7979

80-
const string strMessageMagic = "DarkCoin Signed Message:\n";
80+
const string strMessageMagic = "Darkcoin Signed Message:\n";
8181

8282
// Internal stuff
8383
namespace {
@@ -1637,14 +1637,11 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
16371637
// Go back by what we want to be 14 days worth of blocks
16381638
const CBlockIndex* pindexFirst = pindexLast;
16391639
for (int i = 0; pindexFirst && i < blockstogoback; i++)
1640-
//for (int i = 0; pindexFirst && i < nInterval-1; i++)
16411640
pindexFirst = pindexFirst->pprev;
16421641
assert(pindexFirst);
16431642

16441643
// Limit adjustment step
1645-
//int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
16461644
int64_t nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
1647-
//LogPrintf(" nActualTimespan = %d before bounds\n", nActualTimespan);
16481645
LogPrintf(" nActualTimespan = %d before bounds\n", nActualTimespan);
16491646
if (nActualTimespan < nTargetTimespan/4)
16501647
nActualTimespan = nTargetTimespan/4;
@@ -1662,11 +1659,8 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
16621659

16631660
/// debug print
16641661
LogPrintf("GetNextWorkRequired RETARGET\n");
1665-
//LogPrintf("nTargetTimespan = %d nActualTimespan = %d\n", nTargetTimespan, nActualTimespan);
16661662
LogPrintf("nTargetTimespan = %d nActualTimespan = %d\n", nTargetTimespan, nActualTimespan);
1667-
//LogPrintf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString().c_str());
16681663
LogPrintf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString());
1669-
//LogPrintf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString().c_str());
16701664
LogPrintf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString());
16711665

16721666
return bnNew.GetCompact();
@@ -4669,6 +4663,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
46694663
LogPrint("net", "Reject %s\n", SanitizeString(ss.str()));
46704664
}
46714665
}
4666+
46724667
else
46734668
{
46744669
//probably one the extensions
@@ -4678,7 +4673,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
46784673
}
46794674

46804675

4681-
46824676
// Update the last seen time for this node's address
46834677
if (pfrom->fNetworkNode)
46844678
if (strCommand == "version" || strCommand == "addr" || strCommand == "inv" || strCommand == "getdata" || strCommand == "ping")

src/miner.cpp

Lines changed: 8 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -468,41 +468,6 @@ void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash
468468
double dHashesPerSec = 0.0;
469469
int64_t nHPSTimerStart = 0;
470470

471-
//
472-
// ScanHash scans nonces looking for a hash with at least some zero bits.
473-
// It operates on big endian data. Caller does the byte reversing.
474-
// All input buffers are 16-byte aligned. nNonce is usually preserved
475-
// between calls, but periodically or if nNonce is 0xffff0000 or above,
476-
// the block is rebuilt and nNonce starts over at zero.
477-
//
478-
unsigned int static ScanHash_CryptoPP(char* pmidstate, char* pdata, char* phash1, char* phash, unsigned int& nHashesDone)
479-
{
480-
unsigned int& nNonce = *(unsigned int*)(pdata + 12);
481-
for (;;)
482-
{
483-
// Crypto++ SHA256
484-
// Hash pdata using pmidstate as the starting state into
485-
// pre-formatted buffer phash1, then hash phash1 into phash
486-
nNonce++;
487-
SHA256Transform(phash1, pdata, pmidstate);
488-
SHA256Transform(phash, phash1, pSHA256InitState);
489-
490-
// Return the nonce if the hash has at least some zero bits,
491-
// caller will check if it has enough to reach the target
492-
if (((unsigned short*)phash)[14] == 0)
493-
return nNonce;
494-
495-
// If nothing found after trying for a while, return -1
496-
if ((nNonce & 0xffff) == 0)
497-
{
498-
nHashesDone = 0xffff+1;
499-
return (unsigned int) -1;
500-
}
501-
if ((nNonce & 0xfff) == 0)
502-
boost::this_thread::interruption_point();
503-
}
504-
}
505-
506471
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
507472
{
508473
CPubKey pubkey;
@@ -595,37 +560,23 @@ void static BitcoinMiner(CWallet *pwallet)
595560

596561
unsigned int& nBlockTime = *(unsigned int*)(pdata + 64 + 4);
597562
unsigned int& nBlockBits = *(unsigned int*)(pdata + 64 + 8);
598-
unsigned int& nBlockNonce = *(unsigned int*)(pdata + 64 + 12);
599-
600563

601564
//
602565
// Search
603566
//
604567
int64_t nStart = GetTime();
605568
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
606-
uint256 hashbuf[2];
607-
uint256& hash = *alignup<16>(hashbuf);
608569
while (true)
609570
{
610571
unsigned int nHashesDone = 0;
611-
unsigned int nNonceFound;
612-
613-
// Crypto++ SHA256
614-
nNonceFound = ScanHash_CryptoPP(pmidstate, pdata + 64, phash1,
615-
(char*)&hash, nHashesDone);
616572

617-
// Check if something found
618-
if (nNonceFound != (unsigned int) -1)
573+
uint256 hash;
574+
while (true)
619575
{
620-
for (unsigned int i = 0; i < sizeof(hash)/4; i++)
621-
((unsigned int*)&hash)[i] = ByteReverse(((unsigned int*)&hash)[i]);
622-
576+
hash = pblock->GetHash();
623577
if (hash <= hashTarget)
624578
{
625579
// Found a solution
626-
pblock->nNonce = ByteReverse(nNonceFound);
627-
assert(hash == pblock->GetHash());
628-
629580
SetThreadPriority(THREAD_PRIORITY_NORMAL);
630581
CheckWork(pblock, *pwallet, reservekey);
631582
SetThreadPriority(THREAD_PRIORITY_LOWEST);
@@ -637,6 +588,10 @@ void static BitcoinMiner(CWallet *pwallet)
637588

638589
break;
639590
}
591+
pblock->nNonce += 1;
592+
nHashesDone += 1;
593+
if ((pblock->nNonce & 0xFF) == 0)
594+
break;
640595
}
641596

642597
// Meter hashes/sec
@@ -672,7 +627,7 @@ void static BitcoinMiner(CWallet *pwallet)
672627
boost::this_thread::interruption_point();
673628
if (vNodes.empty() && Params().NetworkID() != CChainParams::REGTEST)
674629
break;
675-
if (nBlockNonce >= 0xffff0000)
630+
if (pblock->nNonce >= 0xffff0000)
676631
break;
677632
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
678633
break;

src/net.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ namespace boost {
4141
static const unsigned int MAX_INV_SZ = 50000;
4242
/** The maximum number of entries in mapAskFor */
4343
static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
44+
/** The maximum number of new addresses to accumulate before announcing. */
45+
static const unsigned int MAX_ADDR_TO_SEND = 1000;
4446

4547
inline unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); }
4648
inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); }
@@ -404,8 +406,13 @@ class CNode
404406
// Known checking here is only to save space from duplicates.
405407
// SendMessages will filter it again for knowns that were added
406408
// after addresses were pushed.
407-
if (addr.IsValid() && !setAddrKnown.count(addr))
408-
vAddrToSend.push_back(addr);
409+
if (addr.IsValid() && !setAddrKnown.count(addr)) {
410+
if (vAddrToSend.size() >= MAX_ADDR_TO_SEND) {
411+
vAddrToSend[insecure_rand() % vAddrToSend.size()] = addr;
412+
} else {
413+
vAddrToSend.push_back(addr);
414+
}
415+
}
409416
}
410417

411418

0 commit comments

Comments
 (0)