[Dev] Documenting Feathercoin Specific Software settings - Part 2
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/516a78744d2eac208b61a864f81d59dc9055568d
src/qt/merchantlist.h
New file for FTC reports. Add MerchantListView FTC reports commit
+// Copyright (c) 2013-2014 The Feathercoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef MERCHANTLISTVIEW_H +#define MERCHANTLISTVIEW_H + +#include <QWidget> + +class ClientModel; +class TransactionFilterProxy; +class MerViewDelegate; +class WalletModel; + +namespace Ui { + class MerchantListView;
Initial code then, 64 lines of code in new file.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/516a78744d2eac208b61a864f81d59dc9055568d
src/qt/reportview.h
Add MerchantListView FTC reports commit
+// Copyright (c) 2013-2014 The Feathercoin developers
Copyright.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/516a78744d2eac208b61a864f81d59dc9055568d
src/qt/transactionview.cpp
Updates to account for new FTC reports. Add MerchantListView FTC reports commit
+#include <QDesktopServices> +#include <QSignalMapper> +#include <QUrl>
Additional code, scrypt interface
+ dateWidget->addItem(tr("Yesterday"), Yesterday); + dateWidget->addItem(tr("Last week"), LastWeek);
FTC report requirement?
+ totalWidget= new QLabel(tr("Total:"),this); + vlayout->addWidget(totalWidget);
Totalisation added code for FTC reports?
+ QAction *showTotalAction = new QAction(tr("Show transaction total"), this);
report code
+ contextMenu->addAction(showTotalAction); + + mapperThirdPartyTxUrls = new QSignalMapper(this); // Connect actions + connect(mapperThirdPartyTxUrls, SIGNAL(mapped(QString)), this, SLOT(openThirdPartyTxUrl(QString))); +
Additional code FTC reports
+ connect(showTotalAction, SIGNAL(triggered()), this, SLOT(showTotal())); + + if (model->getOptionsModel()) + { + // Add third party transaction URLs to context menu + QStringList listUrls = model->getOptionsModel()->getThirdPartyTxUrls().split("|", QString::SkipEmptyParts); + for (int i = 0; i < listUrls.size(); ++i) + { + QString host = QUrl(listUrls[i].trimmed(), QUrl::StrictMode).host(); + if (!host.isEmpty()) + { + QAction *thirdPartyTxUrlAction = new QAction(host, this); // use host as menu item label + if (i == 0) + contextMenu->addSeparator(); + contextMenu->addAction(thirdPartyTxUrlAction); + connect(thirdPartyTxUrlAction, SIGNAL(triggered()), mapperThirdPartyTxUrls, SLOT(map())); + mapperThirdPartyTxUrls->setMapping(thirdPartyTxUrlAction, listUrls[i].trimmed()); + } + } + } + + connect(transactionView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(showTotal())); + showTotal();
Block of added code for FTC reports
+ case Yesterday:{ + QDate startOfDay = current.addDays(-1); + transactionProxyModel->setDateRange( + QDateTime(startOfDay), + QDateTime(current)); + } break;
Additional FTC report code block
+ case LastWeek: { + //from Monday to Sunday + QDate startOfWeek = current.addDays(-(current.dayOfWeek()+6)); + QDate endOfWeek = current.addDays(-(current.dayOfWeek()-1)); + transactionProxyModel->setDateRange( + QDateTime(startOfWeek), + QDateTime(endOfWeek)); + } break;
Additional FTC report code block
+ showTotal();
Show title is called a number of times dependent on if statements which define the type of filter being applied.
+ void TransactionView::showTotal() + { + float fTotal=0; + for (int i=0;i<=transactionProxyModel->rowCount();i + + ) + fTotal + =transactionProxyModel->data(transactionProxyModel->index(i,4)).toFloat(); + + totalWidget->setText(tr("Date:") + dateWidget->currentText() + " " + tr("Type:") + typeWidget->currentText() + " " + tr("Total:") + QObject::tr("%1").arg(fTotal) + " FTC"); + } + + void TransactionView::openThirdPartyTxUrl(QString url) + { + if(!transactionView || !transactionView->selectionModel()) + return; + QModelIndexList selection = transactionView->selectionModel()->selectedRows(0); + if(!selection.isEmpty()) + QDesktopServices::openUrl(QUrl::fromUserInput(url.replace("%s", selection.at(0).data(TransactionTableModel::TxHashRole).toString()))); + } +
Block of additional FTC report code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/516a78744d2eac208b61a864f81d59dc9055568d
src/qt/transactionview.h
Updates to account for / add new FTC reports. Add MerchantListView FTC reports commit
+class QSignalMapper;
Include class
+ Yesterday, + LastWeek,
Include addition time domains for reports
+ QLabel *totalWidget; + QSignalMapper *mapperThirdPartyTxUrls; + void openThirdPartyTxUrl(QString url); + void showTotal();
Additions for FTC reports.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/516a78744d2eac208b61a864f81d59dc9055568d
src/qt/walletframe.cpp
Updates to account for / add new FTC reports. Add MerchantListView FTC reports commit
+ void WalletFrame::gotoMerchantListPage() + { + QMap<QString, WalletView*>::const_iterator i; + for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); + + i) + i.value()->gotoMerchantListPage(); + } +
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/516a78744d2eac208b61a864f81d59dc9055568d
src/qt/walletframe.h
Add MerchantListView FTC reports commit
+ /** Switch to merchant list page */ + void gotoMerchantListPage();
Additions for FTC reports
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/516a78744d2eac208b61a864f81d59dc9055568d
src/qt/walletview.cpp
Add MerchantListView FTC reports commit
+#include "merchantlist.h" + merchantlistPage = new MerchantListView(); + addWidget(merchantlistPage); + overviewPage->setWalletModel(walletModel); + merchantlistPage->setWalletModel(walletModel);
Additions for reports
- overviewPage->setWalletModel(walletModel);
Bitcoin code removed
+ void WalletView::gotoMerchantListPage() + { + setCurrentWidget(merchantlistPage); + } +
Additions for FTC reports
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
https://github.com/FeatherCoin/Feathercoin/commit/516a78744d2eac208b61a864f81d59dc9055568d
src/qt/walletview.h
Add MerchantListView FTC reports commit
+class MerchantListView;
FTC report interface change
+ /** Switch to merchant list page */ + void gotoMerchantListPage();
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dACP and neoscrypt commit (2?)
+AM_PROG_AS
Additional code
+ bdb_prefix=`$BREW --prefix berkeley-db5`
Database updated
- BITCOIN_FIND_BDB48
Code replaced.
+ BITCOIN_FIND_BDB51
Bitcoin code replaced
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/Makefile.am
ACP and neoscrypt commit
+ bin_PROGRAMS += feathercoind + bin_PROGRAMS += feathercoin-cli
Name change.
+ auxpow.h \ + checkpointsync.h \ + scrypt.h \ + neoscrypt.h \
auxilliary proof of work, scrypt, neoscrpt headers added
+ auxpow.cpp \ + base58.cpp \ + scrypt.cpp \ + neoscrypt.c \ + neoscrypt_asm.S \
Add cpp file references
+ if GLIBC_BACK_COMPAT + libbitcoin_common_a_SOURCES += compat/glibc_compat.cpp + libbitcoin_common_a_SOURCES += compat/glibcxx_compat.cpp + endif +
Additional code
+# feathercoind binary # +feathercoind_LDADD = \
Bitcoin code replaced
+feathercoind_LDADD += libbitcoin_wallet.a +feathercoind_SOURCES = feathercoind.cpp +feathercoind_SOURCES += feathercoind-res.rc +feathercoind_LDADD += $(BOOST_LIBS) $(BDB_LIBS) +# feathercoin-cli binary # +feathercoin_cli_LDADD = \ +feathercoin_cli_SOURCES = feathercoin-cli.cpp +feathercoin_cli_SOURCES += feathercoin-cli-res.rc
Interface change to feathercoin name change.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/checkpoints.cpp
ACP and neoscrypt commit, (2nd commit?)
+ + uint256 GetLatestHardenedCheckpoint() + { + const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints; + return (checkpoints.rbegin()->second); + }
Additional code for checkpoints
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/checkpoints.h
ACP and neoscrypt commit, (2nd commit?)
+ // Returns the block hash of latest hardened checkpoint + uint256 GetLatestHardenedCheckpoint();
Additional checkpoint code.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/checkpointsync.cpp
Additional file for checkpoints. Large.
ACP and neoscrypt commit,
+ // Copyright (c) 2012-2013 PPCoin developers + // Copyright (c) 2013 Primecoin developers + // Distributed under conditional MIT/X11 software license, + // see the accompanying file COPYING + // + // The synchronized checkpoint system is first developed by Sunny King for + // ppcoin network in 2012, giving cryptocurrency developers a tool to gain + // additional network protection against 51% attack. + // + // Primecoin also adopts this security mechanism, and the enforcement of + // checkpoints is explicitly granted by user, thus granting only temporary + // consensual central control to developer at the threats of 51% attack. + // + // Concepts + // + // In the network there can be a privileged node known as 'checkpoint master'. + // This node can send out checkpoint messages signed by the checkpoint master + // key. Each checkpoint is a block hash, representing a block on the blockchain + // that the network should reach consensus on. + // + // Besides verifying signatures of checkpoint messages, each node also verifies + // the consistency of the checkpoints. If a conflicting checkpoint is received, + // it means either the checkpoint master key is compromised, or there is an + // operator mistake. In this situation the node would discard the conflicting + // checkpoint message and display a warning message. This precaution controls + // the damage to network caused by operator mistake or compromised key. + // + // Operations + // + // Checkpoint master key can be established by using the 'makekeypair' command + // The public key in source code should then be updated and private key kept + // in a safe place. + // + // Any node can be turned into checkpoint master by setting the 'checkpointkey' + // configuration parameter with the private key of the checkpoint master key. + // Operator should exercise caution such that at any moment there is at most + // one node operating as checkpoint master. When switching master node, the + // recommended procedure is to shutdown the master node and restart as + // regular node, note down the current checkpoint by 'getcheckpoint', then + // compare to the checkpoint at the new node to be upgraded to master node. + // When the checkpoint on both nodes match then it is safe to switch the new + // node to checkpoint master. + // + // The configuration parameter 'checkpointdepth' specifies how many blocks + // should the checkpoints lag behind the latest block in auto checkpoint mode. + // A depth of 0 is the strongest auto checkpoint policy and offers the greatest + // protection against 51% attack. A negative depth means that the checkpoints + // should not be automatically generated by the checkpoint master, but instead + // be manually entered by operator via the 'sendcheckpoint' command. The manual + // mode is also the default mode (default value -1 for checkpointdepth). + // + // Command 'enforcecheckpoint' and configuration parameter 'checkpointenforce' + // are for the users to explicitly consent to enforce the checkpoints issued + // from checkpoint master. To enforce checkpoint, user needs to either issue + // command 'enforcecheckpoint true', or set configuration parameter + // checkpointenforce=1. The current enforcement setting can be queried via + // command 'getcheckpoint', where 'subscribemode' displays either 'enforce' + // or 'advisory'. The 'enforce' mode of subscribemode means checkpoints are + // enforced. The 'advisory' mode of subscribemode means checkpoints are not + // enforced but a warning message would be displayed if the node is on a + // different blockchain fork from the checkpoint, and this is the default mode. + // +
Documentation. for checkpoints code. New file 530 lines of code.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/checkpointsync.h
Additional file for checkpoints. Large.
ACP and neoscrypt commit
+ // Copyright (c) 2011-2013 PPCoin developers + // Copyright (c) 2013 Primecoin developers + // Distributed under conditional MIT/X11 open source software license + // see the accompanying file COPYING + #ifndef PRIMECOIN_CHECKPOINTSYNC_H + #define PRIMECOIN_CHECKPOINTSYNC_H + + #include "net.h" + #include "util.h" + + class uint256; + class CBlock; + class CBlockIndex; + class CSyncCheckpoint;
Add new file 129 lines code.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/core.h
ACP and neoscrypt commit
+// Copyright (c) 2009-2013 The Bitcoin developers
Bitcoin code replaced?
+#include "neoscrypt.h" +#include "chainparams.h" +// DogeCoin aux chain ID = 0x0062 (98), Feathercoin unused
Code additions
- { - uint256 thash; - scrypt_1024_1_1_256(BEGIN(nVersion), BEGIN(thash)); - return thash;
Bitcoin code removed
+ /* Calculates block proof-of-work hash using either NeoScrypt or Scrypt */ + uint256 GetPoWHash() const { + //from 0.8.7 main.h + int nForkFour = 432000; + int nTestnetFork = 600; + unsigned int nSwitchV2 = 1413936000; // Wed, 22 Oct 2014 00:00:00 GMT + unsigned int nTestnetSwitchV2 = 1406473140; // Sun, 27 Jul 2014 14:59:00 GMT + + unsigned int profile = 0x0; + uint256 hash; + + /* All blocks generated up to this time point are Scrypt only */ + if((TestNet() && (nTime < nTestnetSwitchV2)) || + (!TestNet() && (nTime < nSwitchV2))) { + profile = 0x3; + } else { + /* All these blocks must be v2 + with valid nHeight */ + int nHeight = GetBlockHeight(); + if(TestNet()) { + if(nHeight < nTestnetFork) + profile = 0x3; + } else { + if(nHeight < nForkFour) + profile = 0x3; + } + } + + if (profile==0x0) + { + neoscrypt((unsigned char *) &nVersion, (unsigned char *) &hash, profile); + } + if (profile==0x3) + { + scrypt_1024_1_1_256(BEGIN(nVersion), BEGIN(hash)); + } + //scrypt_1024_1_1_256(BEGIN(nVersion), BEGIN(hash)); + + return(hash); } } + /* Extracts block height from v2 + coin base; + * ignores nVersion because it's unrealiable */ + int GetBlockHeight() const { + /* Prevents a crash if called on a block header alone */ + if(vtx.size()) { + /* Serialised CScript */ + std::vector<unsigned char>::const_iterator scriptsig = vtx[0].vin[0].scriptSig.begin(); + unsigned char i, scount = scriptsig[0]; + /* Optimise: nTime is 4 bytes always, + * nHeight must be less for a long time; + * check against a threshold when the time comes */ + if(scount < 4) { + int height = 0; + unsigned char *pheight = (unsigned char *) &height; + for(i = 0; i < scount; i + + ) + pheight[i] = scriptsig[i + 1]; + /* v2 + block with nHeight in coin base */ + return(height); + } + } + /* Not found */ + return(-1); + } +
Bitcoin code replaced.
+ void print() const;
Position change?
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/db.cpp
ACP and neoscrypt commit
- dbenv.set_lk_max_objects(40000); + dbenv.set_lk_max_locks(200000); + dbenv.set_lk_max_objects(200000); //from 0.8.7
Bitcoin code replaced.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/init.cpp
ACP and neoscrypt commit. 2nd Commit
+ + if (mapArgs.count("-checkpointkey")) // ppcoin: checkpoint master priv key + { + if (!SetCheckpointPrivKey(GetArg("-checkpointkey", ""))) + return InitError(_("Unable to sign checkpoint, wrong checkpointkey?")); + } +
Additional code checkpoints
+ return InitError(_("Initialization sanity check failed. Feathercoin Core is shutting down."));
Bitcoin code replaced.
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/m4/bitcoin_find_bdb51.m4
ACP and neoscrypt commit. New file 66 lines.
[FAQ] What is a .m4 file?
m4 is a general-purpose macro processor included in all UNIX-like operating systems, and is a component of the POSIX standard.
The language was designed by Brian Kernighan and Dennis Ritchie for the original versions of UNIX. It is an extension of an earlier macro processor m3, written by Ritchie for the AP-3 minicomputer.[1]
The macro preprocessor operates as a text-replacement tool. It is employed to re-use text templates, typically in computer programming applications, but also in text editing and text-processing applications. Most users require m4 as a dependency of GNU autoconf.
https://en.wikipedia.org/wiki/M4_(computer_language)
+ AC_DEFUN([BITCOIN_FIND_BDB51],[ + AC_MSG_CHECKING([for Berkeley DB C + + headers]) + BDB_CPPFLAGS= + BDB_LIBS= + bdbpath=X + bdb51path=X + bdbdirlist= + for _vn in 5.1 51 5 ''; do + for _pfx in b lib ''; do + bdbdirlist="$bdbdirlist ${_pfx}db${_vn}" + done + done + for searchpath in $bdbdirlist ''; do
Start of Additional code
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/m4/bitcoin_qt.m4
ACP and neoscrypt commit.
+ AC_MSG_WARN([$1; feathercoin-qt frontend will not be built]) + AC_MSG_CHECKING(whether to build Feathercoin Core GUI)
Name changes to feathercoin
-
Feathercoin specific changes made to convert Bitcoin to FTC 0.9.6.*
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/main.cpp
ACP and neoscrypt commit. 2nd commit
+#include "checkpointsync.h" +unsigned int nTransactionsUpdated = 0; + +int nBaseMaturity = BASE_MATURITY; + int nBestHeight = -1; + uint256 nBestChainWork = 0; + uint256 nBestInvalidWork = 0; + uint256 hashBestChain = 0; + CBlockIndex* pindexBest = NULL;
Additional code
-// The 1st hard fork -const int nForkOne = 33000; -// The 2nd hard fork -const int nForkTwo = 87948; -// The 3rd hard fork -const int nForkThree = 204639;
Bitcoin fork code removed
+ static CBigNum bnProofOfWorkLimit(~uint256(0) >> 20); // Feathercoin: starting difficulty is 1 / 2^12 + /* The difficulty after switching to NeoScrypt (0.015625) */ + static CBigNum bnNeoScryptSwitch(~uint256(0) >> 26); + +
Bitcoin code replaced with Neoscrypt code.
+map<uint256, CBlock*> mapOrphanBlocksA; + +static CBlockIndex* pblockindexFBBHLast;
Added code
+ if(nHeight >= nForkThree || (TestNet()))
Bitcoin fork code replaced
- // Subsidy is cut in half every 2100000 blocks, which will occur approximately every 4 years
- nSubsidy >>= (nHeight / 1799985); // 200,010 blocks at 200FTC and 1,599,975 at 80FTC
+ // Halving subsidy happens every 2,100,000 blocks. The code below takes account for the + // fact that the first 204,639 blocks took 2.5 minutes and after changed to 1 minute. + nSubsidy >>= (nHeight + 306960) / 2100000;
Bitcoin code replaced
+ return nSubsidy + nFees;
Code moved
+// Feathercoin: eHRC at 3rd hard fork
FTC code updated
+ /* The 4th hard fork and testnet hard fork */ + if((nHeight >= nForkFour) || (TestNet && (nHeight >= nTestnetFork))) { + if(!fNeoScrypt) fNeoScrypt = true; + /* Difficulty reset after the switch */ + if((nHeight == nForkFour) || (TestNet() && (nHeight == nTestnetFork))) + return(bnNeoScryptSwitch.GetCompact()); + } +
Fork included
- if (TestNet()) fHardFork = false;
Bitcoin code removed
+ bool fHardFork = (nHeight == nForkOne) || (nHeight == nForkTwo) || (nHeight == nForkThree) || (nHeight == nForkFour); + if(TestNet()) { + if (nHeight == nTestnetFork) { + fHardFork = true; + } else { + fHardFork = false; + } + }
Code Added
+ // Additional averaging over 4x nInterval window + if((nHeight >= nForkTwo) && (nHeight < nForkThree)) { + nInterval *= 4; + + const CBlockIndex* pindexFirst = pindexLast; + for(int i = 0; pindexFirst && i < nInterval; i + + ) + pindexFirst = pindexFirst->pprev; + + int nActualTimespanLong = + (pindexLast->GetBlockTime() - pindexFirst->GetBlockTime())/4; + + // Average between short and long windows + int nActualTimespanAvg = (nActualTimespan + nActualTimespanLong)/2; + + // Apply .25 damping + nActualTimespan = nActualTimespanAvg + 3*nTargetTimespan; + nActualTimespan /= 4; + + LogPrintf("RETARGET: nActualTimespanLong = %d, nActualTimeSpanAvg = %d, nActualTimespan (damped) = %d\n", + nActualTimespanLong, nActualTimespanAvg, nActualTimespan); + } +
Code added
+ LogPrintf("pindex->GetBlockHash()=%s \n",pindex->GetBlockHash().ToString()); + LogPrintf("view.GetBestBlock()=%s \n",view.GetBestBlock().ToString());
Code added
+ LogPrintf("ConnectBlock hashPrevBlock=%s \n",hashPrevBlock.ToString()); + LogPrintf("ConnectBlock view.GetBestBlock()=%s \n",view.GetBestBlock().ToString()); +
Code added
+ + if (!IsSyncCheckpointEnforced()) // checkpoint advisory mode + { + if (pindexBest->pprev && !CheckSyncCheckpoint(pindexBest->GetBlockHash(), pindexBest->pprev)) + strCheckpointWarning = _("Warning: checkpoint on different blockchain fork, contact developers to resolve the issue"); + else + strCheckpointWarning = ""; + } } }
Checkpointing code added
+ //0.8.7 ACP code have some problem in 0.9.3,so I delete them. + bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew) + { + return true; + } +
Checkpointing code added
+ + // ppcoin: check that the block satisfies synchronized checkpoint + // checkpoint advisory mode + if (!IsSyncCheckpointEnforced() && !CheckSyncCheckpoint(hash, pindexPrev)) + return error("checkpoint AcceptBlock() : rejected by synchronized checkpoint");
Checkpointing code
+ + // ppcoin: check pending sync-checkpoint + AcceptPendingSyncCheckpoint();
Checkpointing code
+ + // ppcoin: ask for pending sync-checkpoint if any + if (!IsInitialBlockDownload()) + AskForPendingSyncCheckpoint(pfrom);
Checkpointing code
+ + // ppcoin: if responsible for sync-checkpoint send it + if (pfrom && !CSyncCheckpoint::strMasterPrivKey.empty() && + (int)GetArg("-checkpointdepth", -1) >= 0) + SendSyncCheckpoint(AutoSelectSyncCheckpoint()); +
Checkpointing code
+ + // ppcoin: load hashSyncCheckpoint + if (!pblocktree->ReadSyncCheckpoint(hashSyncCheckpoint)) + LogPrintf("LoadBlockIndexDB(): synchronized checkpoint not read\n"); + else + LogPrintf("LoadBlockIndexDB(): synchronized checkpoint %s\n", hashSyncCheckpoint.ToString().c_str());
Checkpointing code
+ + // ppcoin: initialize synchronized checkpoint + if (!WriteSyncCheckpoint(Params().HashGenesisBlock())) + return error("LoadBlockIndex() : failed to init sync checkpoint");
Checkpointing code
+ // ppcoin: if checkpoint master key changed must reset sync-checkpoint + if (!CheckCheckpointPubKey()) + return error("LoadBlockIndex() : failed to reset checkpoint master pubkey");
Checkpointing code
+ // Checkpoint warning + if (strCheckpointWarning != "") + { + nPriority = 900; + strStatusBar = strCheckpointWarning; + }
Checkpointing code
+ + // ppcoin: if detected invalid checkpoint enter safe mode + if (hashInvalidCheckpoint != 0) + { + nPriority = 3000; + strStatusBar = strRPC = _("WARNING: Inconsistent checkpoint found! Stop enforcing checkpoints and notify developers to resolve the issue."); + }
Checkpointing
+ + // ppcoin: relay sync-checkpoint + { + LOCK(cs_hashSyncCheckpoint); + if (!checkpointMessage.IsNull()) + checkpointMessage.RelayTo(pfrom); + }
Checkpointing
+ + // ppcoin: ask for pending sync-checkpoint if any + if (!IsInitialBlockDownload()) + AskForPendingSyncCheckpoint(pfrom);
Checkpointing
+ else if (strCommand == "checkpoint") // ppcoin synchronized checkpoint + { + CSyncCheckpoint checkpoint; + vRecv >> checkpoint; + + if (checkpoint.ProcessSyncCheckpoint(pfrom)) + { + // Relay + pfrom->hashCheckpointKnown = checkpoint.hashCheckpoint; + LOCK(cs_vNodes); + BOOST_FOREACH(CNode* pnode, vNodes) + checkpoint.RelayTo(pnode); + } + }
Checkpointing