[Dev] Documenting Feathercoin Specific Software settings - Part 2
-
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
-
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.h
ACP and neoscrypt commit. 2nd commit
+#include "neoscrypt.h" + /* Maturity threshold for PoW base transactions, in blocks (confirmations) */ + extern int nBaseMaturity; + static const int BASE_MATURITY = 100; +
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; + // The 4th hard fork + const int nForkFour = 432000; + + static const int nTestnetFork = 600; + + static const unsigned int nSwitchV2 = 1413936000; // Wed, 22 Oct 2014 00:00:00 GMT + static const unsigned int nTestnetSwitchV2 = 1406473140; // Sun, 27 Jul 2014 14:59:00 GMT + +
Additional code
+ extern int nBestHeight; + extern uint256 nBestChainWork; + extern uint256 nBestInvalidWork; + extern uint256 hashBestChain; + extern CBlockIndex* pindexBest; + extern unsigned int nTransactionsUpdated; +extern std::map<uint256, CBlock*> mapOrphanBlocksA; //for checkpointsync.cpp
Additional code
+/** Connect/disconnect blocks until pindexNew is the new tip of the active block chain */ +bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew);
Additional code
+ // (memory only) pointer to the index of the *active* successor of this block + CBlockIndex* pnext; +
Additional code
+ pnext = NULL; + pnext = NULL; + + bool IsInMainChain() const + { + return (pnext || this == pindexBest); + }
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/miner.cpp
ACP and neoscrypt commit.
+ unsigned int profile = fNeoScrypt ? 0x0 : 0x3;
Additional code
- char scratchpad[SCRYPT_SCRATCHPAD_SIZE];
Bitcoin code removed
- scrypt_1024_1_1_256_sp(BEGIN(pblock->nVersion), BEGIN(thash), scratchpad);
Bitcoin code replaced
+ //scrypt_1024_1_1_256_sp(BEGIN(pblock->nVersion), BEGIN(thash), scratchpad); + neoscrypt((unsigned char *) &pblock->nVersion, (unsigned char *) &hash, profile);
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/neoscrypt.c
ACP and neoscrypt commit. Large New file
/* * Copyright (c) 2009 Colin Percival, 2011 ArtForz * Copyright (c) 2012 Andrew Moon (floodyberry) * Copyright (c) 2012 Samuel Neves <sneves@dei.uc.pt> * Copyright (c) 2014 John Doering <ghostlander@phoenixcoin.org> * All rights reserved. #include <stdlib.h> #include <stdint.h> #include <string.h> #include "neoscrypt.h"
Start of neoscrypt 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/neoscrypt.h
ACP and neoscrypt commit. Large New file
+ #if (__cplusplus) + extern "C" { + #endif + + void neoscrypt(const unsigned char *input, unsigned char *output, unsigned int profile); + + #if (__cplusplus) + } + #else + + #define SCRYPT_BLOCK_SIZE 64 + #define SCRYPT_HASH_BLOCK_SIZE 64 + #define SCRYPT_HASH_DIGEST_SIZE 32 + + typedef uint8_t hash_digest[SCRYPT_HASH_DIGEST_SIZE];
Start of new 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/neoscrypt_asm.S
ACP and neoscrypt commit. Large New file
#if (ASM) && (__x86_64__) /* neoscrypt_blkcpy(dst, src, len) = SSE2 based block memcpy(); * len must be a multiple of 64 bytes aligned properly */ .globl neoscrypt_blkcpy neoscrypt_blkcpy: #if (WIN64) movq %rdi, %r10 movq %rsi, %r11 movq %rcx, %rdi movq %rdx, %rsi movq %r8, %rdx #endif
Start of code full file. 735 lines
-
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/net.cpp
ACP and neoscrypt commit.
+ void CNode::PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd) + { + // main.h:PushGetBlocks(CNode* pnode, CBlockIndex* pindexBegin, uint256 hashEnd); + // Filter out duplicate requests + /*if (pindexBegin == pindexLastGetBlocksBegin && hashEnd == hashLastGetBlocksEnd) + return; + pindexLastGetBlocksBegin = pindexBegin; + hashLastGetBlocksEnd = hashEnd; + + PushMessage("getblocks", CBlockLocator(pindexBegin), hashEnd);*/ //'CBlockIndex*' to 'const CBlockLocator&' + } +
pindex code addition
+ for (int nHost = 1; nHost <= 2; nHost++)
Bitcoin Code replaced (seen this before?)
+ else if (nHost == 2) + { + addrConnect = CService("74.208.43.192", 80); // www.showmyip.com + + if (nLookup == 1) + { + CService addrIP("www.showmyip.com", 80, true); + if (addrIP.IsValid()) + addrConnect = addrIP; + } + + pszGet = "GET /simple/ HTTP/1.1\r\n" + "Host: www.showmyip.com\r\n" + "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n" + "Connection: close\r\n" + "\r\n"; + + pszKeyword = NULL; // Returns just IP address + }
Needs review. ACP site?
-
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/net.h
ACP and neoscrypt commit.
+ /** The maximum number of entries in mapAskFor */ + static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
Additional code
+ struct LocalServiceInfo { + int nScore; + int nPort; + }; + + extern CCriticalSection cs_mapLocalHost; + extern map<CNetAddr, LocalServiceInfo> mapLocalHost;
Additional code
- std::set<CAddress> setAddrKnown; + mruset<CAddress> setAddrKnown;
Bitcoin code replaced
+ uint256 hashCheckpointKnown; //ppcoin: known sent sync-checkpoint
Additional checkpoint code
- CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : ssSend(SER_NETWORK, INIT_PROTO_VERSION) + CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : ssSend(SER_NETWORK, INIT_PROTO_VERSION), setAddrKnown(5000)
Bitcoin code replaced
+ if (mapAskFor.size() > MAPASKFOR_MAX_SZ) + return; + + + void PushGetBlocks(CBlockIndex* pindexBegin, uint256 hashEnd);
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/qt/Makefile.am
ACP and neoscrypt commit.
+ forms/transactiondescdialog.ui \ + forms/merchantlist.ui
BBitcoin code replaced, new line.
+ moc_walletview.cpp \ + moc_reportview.cpp \ + moc_merchantlist.cpp
Directory positioning changed? Additional code
+ merchantlist.moc \
Additional code
+ winshutdownmonitor.h \ + reportview.h \ + merchantlist.h
Directory positioning changed? Additional code
+ res/icons/tx_mined.png \ + res/icons/merchantList.png \ + res/icons/openurl.png \ + res/icons/account-report.png
Directory positioning changed? Additional code
+ walletview.cpp \ + reportview.cpp \ + merchantlist.cpp
Directory positioning changed? Additional code
+ res/images/splash_testnet.png \ + res/images/LOGO.png \ + res/images/mainbg.png \ + res/images/about_bitcoin.png \ + res/images/about.png \ + res/images/feathercoinmap.png \ + res/images/bitcoinbazaar.co.uk.png \ + res/images/pockio.png \ + res/images/btc-e.png \ + res/images/bter.png \ + res/images/cm.png \ + res/images/cryptsy.png \ + res/images/ct.png \ + res/images/mc.png
Bitcoin Directory positioning changed? 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/rpcserver.cpp
ACP and neoscrypt commit.
+ if (dAmount <= 0.0 || dAmount > 21000000*16)
Bitcoin code replaced
+ /* Wallet-ACP */ + { "getcheckpoint", &getcheckpoint, true, false, true }, + { "sendcheckpoint", &sendcheckpoint, true, false, true }, + { "enforcecheckpoint", &enforcecheckpoint, true, false, true },
Additional code 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/rpcserver.h
ACP and neoscrypt commit.
+ extern json_spirit::Value getcheckpoint(const json_spirit::Array& params, bool fHelp); // in checkpointsync.cpp + extern json_spirit::Value sendcheckpoint(const json_spirit::Array& params, bool fHelp); + extern json_spirit::Value enforcecheckpoint(const json_spirit::Array& params, bool fHelp);
Add checkpoint code
+ extern json_spirit::Value getblockchaininfo(const json_spirit::Array& params, bool fHelp); + extern json_spirit::Value getnetworkinfo(const json_spirit::Array& params, bool fHelp);
-
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/txdb.cpp
ACP and neoscrypt commit.
+ return error("%s : Deserialize or I/O error - %s", __func__, e.what());
Bitcoin code replaced
+ return error("%s : Deserialize or I/O error - %s", __func__, e.what());
Bitcoin code replaced
+ + bool CBlockTreeDB::ReadSyncCheckpoint(uint256& hashCheckpoint) + { + return Read(string("hashSyncCheckpoint"), hashCheckpoint); + } + + bool CBlockTreeDB::WriteSyncCheckpoint(uint256 hashCheckpoint) + { + return Write(string("hashSyncCheckpoint"), hashCheckpoint); + } + + bool CBlockTreeDB::ReadCheckpointPubKey(string& strPubKey) + { + return Read(string("strCheckpointPubKey"), strPubKey); + } + + bool CBlockTreeDB::WriteCheckpointPubKey(const string& strPubKey) + { + return Write(string("strCheckpointPubKey"), strPubKey); + }
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/txdb.h
ACP and neoscrypt commit.
+ + // ppcoin sync checkpoint related data + bool ReadSyncCheckpoint(uint256& hashCheckpoint); + bool WriteSyncCheckpoint(uint256 hashCheckpoint); + bool ReadCheckpointPubKey(std::string& strPubKey); + bool WriteCheckpointPubKey(const std::string& strPubKey);
-
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/uint256.h
ACP and neoscrypt commit.
+ typedef long long int64; + typedef unsigned long long uint64; +
Additional variables.
-
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/util.cpp
ACP and neoscrypt commit.
+bool fNeoScrypt = false;
Addition neoscrypt variable.
-
Add Implemented ACP and neoscrypt commit
https://github.com/FeatherCoin/Feathercoin/commit/c8ca4c906144910c62acd34e23a4ed624c0fbf7dsrc/util.h
ACP and neoscrypt commit.
+extern bool fNeoScrypt;
Addition neoscrypt variable.