]> Git Repo - VerusCoin.git/commitdiff
Test
authorjl777 <[email protected]>
Mon, 16 Apr 2018 17:16:28 +0000 (20:16 +0300)
committerjl777 <[email protected]>
Mon, 16 Apr 2018 17:16:28 +0000 (20:16 +0300)
src/komodo_bitcoind.h
src/komodo_notary.h
src/main.cpp
src/miner.cpp
src/pow.cpp
src/pow.h
src/rpcmining.cpp
src/txdb.cpp

index 2bc831e1f34e5a33b8cabf5f6009329430f6c817..6af72e2985d8c8035ff4962699626d3c5520354c 100644 (file)
@@ -804,7 +804,7 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
     return(komodo_electednotary(&numnotaries,pubkey33,height,timestamp));
 }*/
 
-int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height)
+int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height)
 {
     int32_t i,j,n,duplicate; CBlock block; CBlockIndex *pindex; uint8_t notarypubs33[64][33];
     memset(mids,-1,sizeof(*mids)*66);
@@ -813,6 +813,7 @@ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *non
     {
         if ( (pindex= komodo_chainactive(height-i)) != 0 )
         {
+            blocktimes[i] = pindex->nTime;
             if ( komodo_blockload(block,pindex) == 0 )
             {
                 komodo_block2pubkey33(pubkeys[i],&block);
@@ -849,7 +850,7 @@ int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width) // depre
     return(-1);
 }
 
-int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t height,uint8_t pubkey33[33],uint32_t tiptime,uint32_t blocktime)
+int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],uint32_t blocktimes[66],int32_t height,uint8_t pubkey33[33],uint32_t tiptime,uint32_t blocktime)
 {
     int32_t i,j,notaryid=0,minerid,limit,nid; uint8_t destpubkey33[33];
     komodo_chosennotary(&notaryid,height,pubkey33,tiptime);
@@ -869,9 +870,9 @@ int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t heigh
                     else break;
                 }
             }
-            if ( blocktime < tiptime+60 )
+            if ( blocktime < blocktimes[1]+60 )
             {
-                fprintf(stderr,"ht.%d n.%d l.%d\n",height,notaryid,blocktime-tiptime);
+                fprintf(stderr,"ht.%d n.%d blocktimes[%u vs %u %u]\n",height,notaryid,blocktime,blocktimes[0],blocktimes[1]);
             } else return(1);
         } else return(0);
     }
index b770a65141f9133f709fb0502e75ab3b3d09b3ed..c2c8d09ef626215d9a99237e2571d17c584ad329 100644 (file)
@@ -127,7 +127,7 @@ const char *Notaries_elected0[][2] =
 };
 
 #define KOMODO_NOTARIES_TIMESTAMP1 1525132800 // May 1st 2018 1530921600 // 7/7/2017
-#define KOMODO_NOTARIES_HEIGHT1 ((820000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP)
+#define KOMODO_NOTARIES_HEIGHT1 ((814000 / KOMODO_ELECTION_GAP) * KOMODO_ELECTION_GAP)
 
 const char *Notaries_elected1[][2] =
 {
index 0057dfb07a458abf973e0cd6cde5ee36f2cf1041..f3719374ca4d6ba82deed76a7635801354e40d67 100644 (file)
@@ -1655,7 +1655,7 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::M
     return true;
 }
 
-bool ReadBlockFromDisk(CBlockIndex *pprev,int32_t height,CBlock& block, const CDiskBlockPos& pos)
+bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos)
 {
     uint8_t pubkey33[33];
     block.SetNull();
@@ -1678,7 +1678,7 @@ bool ReadBlockFromDisk(CBlockIndex *pprev,int32_t height,CBlock& block, const CD
     }
     // Check the header
     komodo_block2pubkey33(pubkey33,(CBlock *)&block);
-    if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime,pprev!=0?pprev->nTime:0)))
+    if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime)))
     {
         int32_t i; for (i=0; i<33; i++)
             fprintf(stderr,"%02x",pubkey33[i]);
@@ -1693,7 +1693,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
 {
     if ( pindex == 0 )
         return false;
-    if (!ReadBlockFromDisk(pindex->pprev,pindex->nHeight,block, pindex->GetBlockPos()))
+    if (!ReadBlockFromDisk(pindex->nHeight,block, pindex->GetBlockPos()))
         return false;
     if (block.GetHash() != pindex->GetBlockHash())
         return error("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
@@ -3808,7 +3808,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat
     if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) )
         return state.DoS(100, error("CheckBlock(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
     komodo_block2pubkey33(pubkey33,(CBlock *)&block);
-    if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime,pindex->pprev!=0?pindex->pprev->nTime:0) )
+    if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus(),block.nTime) )
         return state.DoS(1, error("CheckBlock(): proof of work failed"),REJECT_INVALID, "high-hash");
     // Check the merkle root.
     if (fCheckMerkleRoot) {
index 45a405d081429c6c9802bbab0bd9ada0b34eb040..9a8a75411966cbae3f23ffd54f016dd5767ddea7 100644 (file)
@@ -657,7 +657,7 @@ static bool ProcessBlockFound(CBlock* pblock)
 }
 
 int32_t komodo_baseid(char *origbase);
-int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height);
+int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t *blocktimes,int32_t *nonzpkeysp,int32_t height);
 arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t height,int32_t goalperc);
 int32_t FOUND_BLOCK,KOMODO_MAYBEMINED;
 extern int32_t KOMODO_LASTMINED;
@@ -802,7 +802,7 @@ void static BitcoinMiner()
             //
             // Search
             //
-            uint8_t pubkeys[66][33]; int mids[256],gpucount,nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime();
+            uint8_t pubkeys[66][33]; uint32_t blocktimes[66]; int mids[256],gpucount,nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime();
             savebits = pblock->nBits;
             HASHTarget = arith_uint256().SetCompact(pblock->nBits);
             roundrobin_delay = ROUNDROBIN_DELAY;
@@ -811,7 +811,7 @@ void static BitcoinMiner()
                 j = 65;
                 if ( (Mining_height >= 235300 && Mining_height < 236000) || (Mining_height % KOMODO_ELECTION_GAP) > 64 || (Mining_height % KOMODO_ELECTION_GAP) == 0 )
                 {
-                    komodo_eligiblenotary(pubkeys,mids,&nonzpkeys,pindexPrev->nHeight);
+                    komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,pindexPrev->nHeight);
                     if ( nonzpkeys > 0 )
                     {
                         for (i=0; i<33; i++)
index 8bda92e45e0f1a505821b2b23ffca4be899a86e5..ed1f4ee0877ea255fa31c73fe8b1bc3c3bad7f40 100644 (file)
@@ -117,7 +117,7 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
 }
 
 int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
-int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t height,uint8_t pubkey33[33],uint32_t tiptime,uint32_t blocktime);
+int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],uint32_t blocktimes[66],int32_t height,uint8_t pubkey33[33],uint32_t tiptime,uint32_t blocktime);
 int32_t komodo_currentheight();
 CBlockIndex *komodo_chainactive(int32_t height);
 void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height);
@@ -126,21 +126,19 @@ extern uint64_t ASSETCHAINS_STAKED;
 extern char ASSETCHAINS_SYMBOL[];
 #define KOMODO_ELECTION_GAP 2000
 
-int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,int32_t *nonzpkeysp,int32_t height);
+int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blocktimes[66],int32_t *nonzpkeysp,int32_t height);
 int32_t KOMODO_LOADINGBLOCKS = 1;
 
 extern std::string NOTARY_PUBKEY;
 
-bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash,unsigned int nBits,const Consensus::Params& params,uint32_t blocktime,uint32_t tiptime)
+bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash,unsigned int nBits,const Consensus::Params& params,uint32_t blocktime)
 {
     extern int32_t KOMODO_REWIND;
-    bool fNegative,fOverflow; uint8_t origpubkey33[33]; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,flag = 0, mids[66]; uint32_t tiptime = 0;
+    bool fNegative,fOverflow; uint8_t origpubkey33[33]; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,flag = 0, mids[66]; uint32_t tiptime,blocktimes[66] = 0;
     arith_uint256 bnTarget; uint8_t pubkeys[66][33];
     memcpy(origpubkey33,pubkey33,33);
-    //tiptime = komodo_chainactive_timestamp();
+    tiptime = komodo_chainactive_timestamp();
     bnTarget.SetCompact(nBits, &fNegative, &fOverflow);
-    if ( blocktime == 0 || tiptime == 0 )
-        fprintf(stderr,"nul blocktime.%u or tiptime.%u\n",blocktime,tiptime);
     if ( height == 0 )
     {
         height = komodo_currentheight() + 1;
@@ -159,8 +157,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash,unsigned int
             //fprintf(stderr,"ht.%d null pubkey checkproof return\n",height);
             return(true); // will come back via different path with pubkey set
         }
-        flag = komodo_eligiblenotary(pubkeys,mids,&nonzpkeys,height);
-        special2 = komodo_is_special(pubkeys,mids,height,pubkey33,tiptime,blocktime);
+        flag = komodo_eligiblenotary(pubkeys,mids,blocktimes,&nonzpkeys,height);
+        special2 = komodo_is_special(pubkeys,mids,blocktimes,height,pubkey33,tiptime,blocktime);
         if ( notaryid >= 0 )
         {
             if ( height > 10000 && height < 80000 && (special != 0 || special2 > 0) )
index f546318e9d71ac7d1389f1825da15925b57081a7..213fe228d70d1f5c114f93258920dc7101a4fcd5 100644 (file)
--- a/src/pow.h
+++ b/src/pow.h
@@ -25,7 +25,7 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
 bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams&);
 
 /** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
-bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params&,uint32_t blocktime,uint32_t tiptime);
+bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params&,uint32_t blocktime);
 arith_uint256 GetBlockProof(const CBlockIndex& block);
 
 /** Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds. */
index d423fc70f83de9eda354aa1a76e0647c48de2df9..d141c42c49cb2699f733cfbd3dca9feecab8f84e 100644 (file)
@@ -257,7 +257,7 @@ UniValue generate(const UniValue& params, bool fHelp)
                 LOCK(cs_main);
                 pblock->nSolution = soln;
                 solutionTargetChecks.increment();
-                return CheckProofOfWork(chainActive.Height(),NOTARY_PUBKEY33,pblock->GetHash(), pblock->nBits, Params().GetConsensus(),pblock->nTime,chainActive.Tip()->nTime);
+                return CheckProofOfWork(chainActive.Height(),NOTARY_PUBKEY33,pblock->GetHash(), pblock->nBits, Params().GetConsensus(),pblock->nTime);
             };
             bool found = EhBasicSolveUncancellable(n, k, curr_state, validBlock);
             ehSolverRuns.increment();
index 7415c75ada61c9d9cc1d7d6bd8329d3c449c6a68..c338169522125e15b4db846c4bdc5c40b4ad13cf 100644 (file)
@@ -530,7 +530,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
                                  diskindex.ToString(),  pindexNew->ToString());
                 uint8_t pubkey33[33];
                 komodo_index2pubkey33(pubkey33,pindexNew,pindexNew->nHeight);
-                if (!CheckProofOfWork(pindexNew->nHeight,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus(),pindexNew->nTime,pindexNew->pprev!=0?pindexNew->pprev->nTime:0))
+                if (!CheckProofOfWork(pindexNew->nHeight,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus(),pindexNew->nTime))
                     return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
                 pcursor->Next();
             } else {
This page took 0.054838 seconds and 4 git commands to generate.