Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align branches with upstream #68

Merged
merged 13 commits into from
Dec 11, 2014
10 changes: 5 additions & 5 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ BITCOIN_QT_BIN=$(top_builddir)/src/qt/darkcoin-qt$(EXEEXT)
BITCOIN_CLI_BIN=$(top_builddir)/src/darkcoin-cli$(EXEEXT)
BITCOIN_WIN_INSTALLER=$(PACKAGE)-$(PACKAGE_VERSION)-win$(WINDOWS_BITS)-setup$(EXEEXT)

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

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

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

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

if TARGET_DARWIN
Expand Down
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ DONE:
- Reset testnet (v4) with new genesis and address version (start with x)
- BIP0032 addresses xpub and xpriv start with x (unchanged by design)
- Changed Darkcoin units to DRK and added duffs
- Fixed internal walletminer


MANDATORY:
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -563,11 +563,11 @@ fi

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

AC_MSG_CHECKING([whether to build bitcoind])
AC_MSG_CHECKING([whether to build darkcoind])
AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
AC_MSG_RESULT($build_bitcoind)

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

Expand Down
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class CTestNetParams : public CMainParams {

base58Prefixes[PUBKEY_ADDRESS] = list_of(138); // Testnet v4 addresses start with x
base58Prefixes[SCRIPT_ADDRESS] = list_of(196);
base58Prefixes[SECRET_KEY] = list_of(239);
base58Prefixes[SECRET_KEY] = list_of(266);
base58Prefixes[EXT_PUBLIC_KEY] = list_of(0x04)(0x35)(0x87)(0xCF);
base58Prefixes[EXT_SECRET_KEY] = list_of(0x04)(0x35)(0x83)(0x94);
}
Expand Down
12 changes: 6 additions & 6 deletions src/darkcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*
* \section intro_sec Introduction
*
* This is the developer documentation of the reference client for an experimental new digital currency called Bitcoin (http://www.bitcoin.org/),
* which enables instant payments to anyone, anywhere in the world. Bitcoin uses peer-to-peer technology to operate
* This is the developer documentation of the reference client for an experimental new digital currency called Darkcoin (http://www.darkcoin.io/),
* which enables instant payments to anyone, anywhere in the world. Darkcoin uses peer-to-peer technology to operate
* with no central authority: managing transactions and issuing money are carried out collectively by the network.
*
* The software is a community-driven open source project, released under the MIT license.
Expand Down Expand Up @@ -86,11 +86,11 @@ bool AppInit(int argc, char* argv[])

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

if (fCommandLine)
Expand Down Expand Up @@ -177,7 +177,7 @@ int main(int argc, char* argv[])

bool fRet = false;

// Connect bitcoind signal handlers
// Connect darkcoind signal handlers
noui_connect();

fRet = AppInit(argc, argv);
Expand Down
8 changes: 4 additions & 4 deletions src/m4/bitcoin_qt.m4
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ dnl Output: If qt version is auto, set bitcoin_enable_qt to false. Else, exit.
AC_DEFUN([BITCOIN_QT_FAIL],[
if test "x$bitcoin_qt_want_version" = "xauto" && test x$bitcoin_qt_force != xyes; then
if test x$bitcoin_enable_qt != xno; then
AC_MSG_WARN([$1; bitcoin-qt frontend will not be built])
AC_MSG_WARN([$1; darkcoin-qt frontend will not be built])
fi
bitcoin_enable_qt=no
else
Expand Down Expand Up @@ -123,7 +123,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[


dnl enable qt support
AC_MSG_CHECKING(whether to build Bitcoin Core GUI)
AC_MSG_CHECKING(whether to build Darkcoin Core GUI)
BITCOIN_QT_CHECK([
bitcoin_enable_qt=yes
bitcoin_enable_qt_test=yes
Expand Down Expand Up @@ -343,14 +343,14 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[
dnl check a header to find out. When Qt is built statically, some plugins must
dnl be linked into the final binary as well. These plugins have changed between
dnl Qt4 and Qt5. With Qt5, languages moved into core and the WindowsIntegration
dnl plugin was added. Since we can't tell if Qt4 is static or not, it is
dnl plugin was added. Since we can't tell if Qt4 is static or not, it is
dnl assumed for all non-pkg-config builds.
dnl _BITCOIN_QT_CHECK_STATIC_PLUGINS does a quick link-check and appends the
dnl results to QT_LIBS.
BITCOIN_QT_CHECK([
if test x$bitcoin_qt_got_major_vers == x5; then
_BITCOIN_QT_IS_STATIC
if test x$bitcoin_cv_static_qt == xyes; then
if test x$bitcoin_cv_static_qt == xyes; then
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(AccessibleFactory)], [-lqtaccessiblewidgets])
if test x$TARGET_OS == xwindows; then
Expand Down
10 changes: 2 additions & 8 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ void EraseOrphansFor(NodeId peer);
// Constant stuff for coinbase transactions we create:
CScript COINBASE_FLAGS;

const string strMessageMagic = "DarkCoin Signed Message:\n";
const string strMessageMagic = "Darkcoin Signed Message:\n";

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

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

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

return bnNew.GetCompact();
Expand Down Expand Up @@ -4669,6 +4663,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
LogPrint("net", "Reject %s\n", SanitizeString(ss.str()));
}
}

else
{
//probably one the extensions
Expand All @@ -4678,7 +4673,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
}



// Update the last seen time for this node's address
if (pfrom->fNetworkNode)
if (strCommand == "version" || strCommand == "addr" || strCommand == "inv" || strCommand == "getdata" || strCommand == "ping")
Expand Down
61 changes: 8 additions & 53 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,41 +468,6 @@ void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash
double dHashesPerSec = 0.0;
int64_t nHPSTimerStart = 0;

//
// ScanHash scans nonces looking for a hash with at least some zero bits.
// It operates on big endian data. Caller does the byte reversing.
// All input buffers are 16-byte aligned. nNonce is usually preserved
// between calls, but periodically or if nNonce is 0xffff0000 or above,
// the block is rebuilt and nNonce starts over at zero.
//
unsigned int static ScanHash_CryptoPP(char* pmidstate, char* pdata, char* phash1, char* phash, unsigned int& nHashesDone)
{
unsigned int& nNonce = *(unsigned int*)(pdata + 12);
for (;;)
{
// Crypto++ SHA256
// Hash pdata using pmidstate as the starting state into
// pre-formatted buffer phash1, then hash phash1 into phash
nNonce++;
SHA256Transform(phash1, pdata, pmidstate);
SHA256Transform(phash, phash1, pSHA256InitState);

// Return the nonce if the hash has at least some zero bits,
// caller will check if it has enough to reach the target
if (((unsigned short*)phash)[14] == 0)
return nNonce;

// If nothing found after trying for a while, return -1
if ((nNonce & 0xffff) == 0)
{
nHashesDone = 0xffff+1;
return (unsigned int) -1;
}
if ((nNonce & 0xfff) == 0)
boost::this_thread::interruption_point();
}
}

CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
{
CPubKey pubkey;
Expand Down Expand Up @@ -595,37 +560,23 @@ void static BitcoinMiner(CWallet *pwallet)

unsigned int& nBlockTime = *(unsigned int*)(pdata + 64 + 4);
unsigned int& nBlockBits = *(unsigned int*)(pdata + 64 + 8);
unsigned int& nBlockNonce = *(unsigned int*)(pdata + 64 + 12);


//
// Search
//
int64_t nStart = GetTime();
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
uint256 hashbuf[2];
uint256& hash = *alignup<16>(hashbuf);
while (true)
{
unsigned int nHashesDone = 0;
unsigned int nNonceFound;

// Crypto++ SHA256
nNonceFound = ScanHash_CryptoPP(pmidstate, pdata + 64, phash1,
(char*)&hash, nHashesDone);

// Check if something found
if (nNonceFound != (unsigned int) -1)
uint256 hash;
while (true)
{
for (unsigned int i = 0; i < sizeof(hash)/4; i++)
((unsigned int*)&hash)[i] = ByteReverse(((unsigned int*)&hash)[i]);

hash = pblock->GetHash();
if (hash <= hashTarget)
{
// Found a solution
pblock->nNonce = ByteReverse(nNonceFound);
assert(hash == pblock->GetHash());

SetThreadPriority(THREAD_PRIORITY_NORMAL);
CheckWork(pblock, *pwallet, reservekey);
SetThreadPriority(THREAD_PRIORITY_LOWEST);
Expand All @@ -637,6 +588,10 @@ void static BitcoinMiner(CWallet *pwallet)

break;
}
pblock->nNonce += 1;
nHashesDone += 1;
if ((pblock->nNonce & 0xFF) == 0)
break;
}

// Meter hashes/sec
Expand Down Expand Up @@ -672,7 +627,7 @@ void static BitcoinMiner(CWallet *pwallet)
boost::this_thread::interruption_point();
if (vNodes.empty() && Params().NetworkID() != CChainParams::REGTEST)
break;
if (nBlockNonce >= 0xffff0000)
if (pblock->nNonce >= 0xffff0000)
break;
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
break;
Expand Down
11 changes: 9 additions & 2 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ namespace boost {
static const unsigned int MAX_INV_SZ = 50000;
/** The maximum number of entries in mapAskFor */
static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
/** The maximum number of new addresses to accumulate before announcing. */
static const unsigned int MAX_ADDR_TO_SEND = 1000;

inline unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); }
inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); }
Expand Down Expand Up @@ -404,8 +406,13 @@ class CNode
// Known checking here is only to save space from duplicates.
// SendMessages will filter it again for knowns that were added
// after addresses were pushed.
if (addr.IsValid() && !setAddrKnown.count(addr))
vAddrToSend.push_back(addr);
if (addr.IsValid() && !setAddrKnown.count(addr)) {
if (vAddrToSend.size() >= MAX_ADDR_TO_SEND) {
vAddrToSend[insecure_rand() % vAddrToSend.size()] = addr;
} else {
vAddrToSend.push_back(addr);
}
}
}


Expand Down
Loading