fix build for update

This commit is contained in:
Michael Toutonghi
2018-05-25 20:15:38 -07:00
parent 94d96afd89
commit b0e452de2a
4 changed files with 43 additions and 30 deletions

View File

@@ -11,7 +11,6 @@
#include "komodo_defs.h"
#include <assert.h>
#include <unordered_map>
/**
* 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 )

View File

@@ -13,9 +13,13 @@
#include "memusage.h"
#include "serialize.h"
#include "uint256.h"
#include "base58.h"
#include "pubkey.h"
#include <assert.h>
#include <stdint.h>
#include <vector>
#include <unordered_map>
#include <boost/foreach.hpp>
#include <boost/unordered_map.hpp>
@@ -436,31 +440,36 @@ public:
friend class CCoinsViewCache;
};
class CLaunchMap
{
public:
std::unordered_map<std::string, CScript> 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<unsigned char> adr = std::vector<unsigned char>(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<uint256, CScript> launchMap;
CLaunchMap() { }
CLaunchMap(uint256 *whiteList, uint160 pkh, int count)
{
launchMap = unordered_map<uint256, CScript &>();
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:

View File

@@ -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");

View File

@@ -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()();