diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 05af4edd8..9dfcf0546 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -45,7 +45,7 @@ struct komodo_state KOMODO_STATES[34]; int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,IS_STAKED_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1; -int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; +int32_t KOMODO_INSYNC,KOMODO_LASTMINED,KOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,NUM_NOTARIES; diff --git a/src/miner.cpp b/src/miner.cpp index 6c25a5007..5aef46148 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -108,11 +108,11 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],NOTARYADDRS[64][36]; extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY; void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len); -extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33]; +extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],NUM_NOTARIES; uint32_t Mining_start,Mining_height; int32_t My_notaryid = -1; int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp); @@ -206,12 +206,14 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) double dPriority = 0; CAmount nTotalIn = 0; bool fMissingInputs = false; + bool fNotarisation = false; if (tx.IsCoinImport()) { CAmount nValueIn = GetCoinImportValue(tx); nTotalIn += nValueIn; dPriority += (double)nValueIn * 1000; // flat multiplier } else { + int numNotaryVins = 0; BOOST_FOREACH(const CTxIn& txin, tx.vin) { // Read prev transaction @@ -250,8 +252,23 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) int nConf = nHeight - coins->nHeight; + if ( NOTARYADDRS[0][0] != 0 && NUM_NOTARIES != 0 ) + { + uint256 hash; CTransaction tx1; CTxDestination address; + if (GetTransaction(txin.prevout.hash,tx1,hash,false)) + { + if (ExtractDestination(tx1.vout[txin.prevout.n].scriptPubKey, address)) { + for (int i = 0; i < NUM_NOTARIES; i++) { + if ( strcmp(NOTARYADDRS[i],CBitcoinAddress(address).ToString().c_str()) == 0 ) + numNotaryVins++; + } + } + } + } dPriority += (double)nValueIn * nConf; } + if ( numNotaryVins > NUM_NOTARIES / 5 ) + fNotarisation = true; nTotalIn += tx.GetJoinSplitValueIn(); } @@ -266,6 +283,9 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize); + if (fNotarisation) + dPriority = 1e16; + if (porphan) { porphan->dPriority = dPriority; diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index cc3869835..b528df512 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -305,7 +305,7 @@ int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) { for (size_t i = 0; i < num_notaries; i++) { - fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); + //fprintf(stderr, "address [%ld]: %s\n",i,NOTARYADDRS[i]); if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { notaryname.assign(notaries_chosen[i][0]); //printf("notary number: %ld\n",i ); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a340ecfae..0133d6895 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1214,7 +1214,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) + if ( !tx.IsCoinBase() && !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { @@ -1240,7 +1240,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if ( CBitcoinAddress(address2).ToString() == NOTARY_ADDRESS ) { // this should be a received tx.. numvoutIsOurs++; - totalvoutvalue = totalvoutvalue + tx.vout[i].nValue; + totalvoutvalue += tx.vout[i].nValue; } } }