]> Git Repo - VerusCoin.git/blobdiff - src/cc/eval.cpp
Support for identities, identity APIs and new signing model - breaking change with...
[VerusCoin.git] / src / cc / eval.cpp
index 0fa2723f3e8ad6659c6cd8afa7d58992d2f65b16..cc7b230ca1ab3d8f5955e2721f2a7c0bcefde87d 100644 (file)
 
 Eval* EVAL_TEST = 0;
 struct CCcontract_info CCinfos[0x100];
+extern pthread_mutex_t KOMODO_CC_mutex;
 
 bool RunCCEval(const CC *cond, const CTransaction &tx, unsigned int nIn)
 {
-    // DISABLE CRYPTO CONDITIONS FOR NOW
-    return false;
-
     EvalRef eval;
+    pthread_mutex_lock(&KOMODO_CC_mutex);
     bool out = eval->Dispatch(cond, tx, nIn);
+    pthread_mutex_unlock(&KOMODO_CC_mutex);
     //fprintf(stderr,"out %d vs %d isValid\n",(int32_t)out,(int32_t)eval->state.IsValid());
     assert(eval->state.IsValid() == out);
 
@@ -73,16 +73,39 @@ bool Eval::Dispatch(const CC *cond, const CTransaction &txTo, unsigned int nIn)
     std::vector<uint8_t> vparams(cond->code+1, cond->code+cond->codeLength);
     switch ( ecode )
     {
+        case EVAL_PBAASDEFINITION:
+        case EVAL_SERVICEREWARD:
+        case EVAL_EARNEDNOTARIZATION:
+        case EVAL_ACCEPTEDNOTARIZATION:
+        case EVAL_FINALIZENOTARIZATION:
+        case EVAL_RESERVE_OUTPUT:
+        case EVAL_RESERVE_EXCHANGE:
+        case EVAL_RESERVE_TRANSFER:
+        case EVAL_RESERVE_DEPOSIT:
+        case EVAL_CROSSCHAIN_EXPORT:
+        case EVAL_CROSSCHAIN_IMPORT:
+        case EVAL_CURRENCYSTATE:
+        //case EVAL_IDENTITY_PRIMARY:
+        //case EVAL_IDENTITY_REVOKE:
+        //case EVAL_IDENTITY_RECOVER:
+        //case EVAL_IDENTITY_COMMITMENT:
+        //case EVAL_IDENTITY_RESERVATION:
+            if (!chainActive.LastTip() || CConstVerusSolutionVector::activationHeight.ActiveVersion(chainActive.LastTip()->GetHeight() + 1) < CActivationHeight::SOLUTION_VERUSV3)
+            {
+                // if chain is not able to process this yet, don't drop through to do so
+                break;
+            }
+
+        case EVAL_STAKEGUARD:
+            return(ProcessCC(cp,this, vparams, txTo, nIn));
+            break;
+
         case EVAL_IMPORTPAYOUT:
-            return ImportPayout(vparams, txTo, nIn);
+            //return ImportPayout(vparams, txTo, nIn);
             break;
             
         case EVAL_IMPORTCOIN:
-            return ImportCoin(vparams, txTo, nIn);
-            break;
-            
-        default:
-            return(ProcessCC(cp,this, vparams, txTo, nIn));
+            //return ImportCoin(vparams, txTo, nIn);
             break;
     }
     return Invalid("invalid-code, dont forget to add EVAL_NEWCC to Eval::Dispatch");
@@ -98,7 +121,6 @@ bool Eval::GetSpendsConfirmed(uint256 hash, std::vector<CTransaction> &spends) c
 
 bool Eval::GetTxUnconfirmed(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock) const
 {
-    bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock);
     // there is a LOCK(cs_main) in the normal GetTransaction(), which leads to deadlocks
     //bool fAllowSlow = false; // Don't allow slow
     //return GetTransaction(hash, txOut, hashBlock, fAllowSlow);
@@ -159,7 +181,8 @@ bool Eval::CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t t
         if (tx.vout.size() < txIn.prevout.n) return false;
         CScript spk = tx.vout[txIn.prevout.n].scriptPubKey;
         if (spk.size() != 35) return false;
-        const unsigned char *pk = spk.data();
+        std::vector<unsigned char> scriptVec = std::vector<unsigned char>(spk.begin(),spk.end());
+        const unsigned char *pk = scriptVec.data();
         if (pk++[0] != 33) return false;
         if (pk[33] != OP_CHECKSIG) return false;
 
@@ -188,7 +211,7 @@ bool Eval::GetNotarisationData(const uint256 notaryHash, NotarisationData &data)
     CTransaction notarisationTx;
     CBlockIndex block;
     if (!GetTxConfirmed(notaryHash, notarisationTx, block)) return false;
-    if (!CheckNotaryInputs(notarisationTx, block.nHeight, block.nTime)) return false;
+    if (!CheckNotaryInputs(notarisationTx, block.GetHeight(), block.nTime)) return false;
     if (!ParseNotarisationOpReturn(notarisationTx, data)) return false;
     return true;
 }
This page took 0.04158 seconds and 4 git commands to generate.