From b0e452de2af57b136c0b28c592f3853213d87323 Mon Sep 17 00:00:00 2001 From: Michael Toutonghi Date: Fri, 25 May 2018 20:15:38 -0700 Subject: [PATCH] fix build for update --- src/coins.cpp | 19 +++++++++++-------- src/coins.h | 50 ++++++++++++++++++++++++++++++-------------------- src/main.cpp | 2 +- src/main.h | 2 +- 4 files changed, 43 insertions(+), 30 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index b8c34924a..0a323d990 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -11,7 +11,6 @@ #include "komodo_defs.h" #include -#include /** * calculate number of bytes for the bitmask, and its number of non-zero bytes @@ -380,12 +379,20 @@ const CTxOut &CCoinsViewCache::GetOutputFor(const CTxIn& input) const return coins->vout[input.prevout.n]; } -const CScript &CCoinsViewCache::GetSpendFor(const CCoins *coins, const CTxIn& input) const +//uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime); +uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight); +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; + +const CScript &CCoinsViewCache::GetSpendFor(const CCoins *coins, const CTxIn& input) { assert(coins); - if (launchMap.launchMap.count(input.prevout.hash)) + if (coins->nHeight < 6400 && !strcmp(ASSETCHAINS_SYMBOL, "VRSC")) { - return launchMap.launchMap[input.prevout.hash]; + std::string hc = input.prevout.hash.ToString(); + if (LaunchMap().lmap.count(hc)) + { + return LaunchMap().lmap[hc]; + } } else return coins->vout[input.prevout.n].scriptPubKey; } @@ -396,10 +403,6 @@ const CScript &CCoinsViewCache::GetSpendFor(const CTxIn& input) const return GetSpendFor(coins, input); } -//uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uint32_t tiptime); -uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight); -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; - CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTransaction& tx,uint32_t tiptime) const { if ( interestp != 0 ) diff --git a/src/coins.h b/src/coins.h index 0dab6d3e2..f010af198 100644 --- a/src/coins.h +++ b/src/coins.h @@ -13,9 +13,13 @@ #include "memusage.h" #include "serialize.h" #include "uint256.h" +#include "base58.h" +#include "pubkey.h" #include #include +#include +#include #include #include @@ -436,31 +440,36 @@ public: friend class CCoinsViewCache; }; +class CLaunchMap +{ + public: + std::unordered_map lmap; + CLaunchMap() : lmap() { } + CLaunchMap(std::string *whiteList, std::string *pkh, int count) : lmap() + { + for (int i = 0; i < count; i++) + { + CBitcoinAddress address(pkh[i].c_str()); + CKeyID key; + if (address.IsValid() && address.GetKeyID(key)) + { + std::vector adr = std::vector(key.begin(), key.end()); + std::string hash = uint256S(whiteList[i]).ToString(); + lmap[hash] = CScript(); + lmap[hash] << OP_DUP << OP_HASH160 << adr << OP_EQUALVERIFY << OP_CHECKSIG; + } + } + } +}; +static CLaunchMap launchMap = CLaunchMap(); + /** CCoinsView that adds a memory cache for transactions to another CCoinsView */ class CCoinsViewCache : public CCoinsViewBacked { protected: - class CLaunchMap - { - public: - unordered_map launchMap; - CLaunchMap() { } - CLaunchMap(uint256 *whiteList, uint160 pkh, int count) - { - launchMap = unordered_map(); - for (int i = 0; i < count; i++) - { - launchMap[whiteList[i]] = CScript(); - launchMap[whiteList[i]] << OP_DUP << OP_HASH160 << pkh << OP_EQUALVERIFY << OP_CHECKSIG; - } - } - }; - static CLaunchMap launchMap(); - /* Whether this cache has an active modifier. */ bool hasModifier; - /** * Make mutable so that we can "fill the cache" even from Get-methods * declared as "const". @@ -474,13 +483,12 @@ protected: /* Cached dynamic memory usage for the inner CCoins objects. */ mutable size_t cachedCoinsUsage; - const CScript &GetSpendFor(const CCoins *coins, const CTxIn& input) const; - public: CCoinsViewCache(CCoinsView *baseIn); ~CCoinsViewCache(); // Standard CCoinsView methods + static CLaunchMap &LaunchMap() { return launchMap; } bool GetAnchorAt(const uint256 &rt, ZCIncrementalMerkleTree &tree) const; bool GetNullifier(const uint256 &nullifier) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; @@ -554,6 +562,8 @@ public: const CTxOut &GetOutputFor(const CTxIn& input) const; const CScript &GetSpendFor(const CTxIn& input) const; + static const CScript &GetSpendFor(const CCoins *coins, const CTxIn& input); + friend class CCoinsModifier; private: diff --git a/src/main.cpp b/src/main.cpp index dc5436464..33204bad1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2069,7 +2069,7 @@ namespace Consensus { if (fCoinbaseEnforcedProtectionEnabled && consensusParams.fCoinbaseMustBeProtected && !tx.vout.empty() && - (strcmp(ASSETCHAINS_SYMBOL, "VRSC", 4) != 0 || nSpendHeight >= 10080)) { + (strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0 || nSpendHeight >= 10080)) { return state.Invalid( error("CheckInputs(): tried to spend coinbase with transparent outputs"), REJECT_INVALID, "bad-txns-coinbase-spend-has-transparent-outputs"); diff --git a/src/main.h b/src/main.h index 73714408f..99babb874 100644 --- a/src/main.h +++ b/src/main.h @@ -751,7 +751,7 @@ private: public: CScriptCheck(): amount(0), ptxTo(0), nIn(0), nFlags(0), cacheStore(false), consensusBranchId(0), error(SCRIPT_ERR_UNKNOWN_ERROR) {} CScriptCheck(const CCoins& txFromIn, const CTransaction& txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn, uint32_t consensusBranchIdIn, PrecomputedTransactionData* txdataIn) : - scriptPubKey(txFromIn.GetSpendFor(txToIn.vin[nInIn])), amount(txFromIn.vout[txToIn.vin[nInIn].prevout.n].nValue), + scriptPubKey(CCoinsViewCache::GetSpendFor(&txFromIn, txToIn.vin[nInIn])), amount(txFromIn.vout[txToIn.vin[nInIn].prevout.n].nValue), ptxTo(&txToIn), nIn(nInIn), nFlags(nFlagsIn), cacheStore(cacheIn), consensusBranchId(consensusBranchIdIn), error(SCRIPT_ERR_UNKNOWN_ERROR), txdata(txdataIn) { } bool operator()();