Browse Source

We are calling it ramhash not memhash

ramhash
Duke 10 months ago
parent
commit
f335fb539f
  1. 6
      src/hush_globals.h
  2. 44
      src/miner.cpp

6
src/hush_globals.h

@ -81,13 +81,13 @@ std::vector<std::string> ASSETCHAINS_PRICES,ASSETCHAINS_STOCKS;
// this is the offset in the ASSETCHAINS_ALGORITHMS array // this is the offset in the ASSETCHAINS_ALGORITHMS array
#define _ASSETCHAINS_EQUIHASH 0 #define _ASSETCHAINS_EQUIHASH 0
#define _ASSETCHAINS_RANDOMX 1 #define _ASSETCHAINS_RANDOMX 1
#define _ASSETCHAINS_MEMHASH 2 #define _ASSETCHAINS_RAMHASH 2
uint32_t ASSETCHAINS_NUMALGOS = 5; // there are different variants of equihash with different (N,K) uint32_t ASSETCHAINS_NUMALGOS = 5; // there are different variants of equihash with different (N,K)
uint32_t ASSETCHAINS_EQUIHASH = _ASSETCHAINS_EQUIHASH; uint32_t ASSETCHAINS_EQUIHASH = _ASSETCHAINS_EQUIHASH;
uint32_t ASSETCHAINS_RANDOMX = _ASSETCHAINS_RANDOMX; uint32_t ASSETCHAINS_RANDOMX = _ASSETCHAINS_RANDOMX;
uint32_t ASSETCHAINS_MEMHASH = _ASSETCHAINS_MEMHASH; uint32_t ASSETCHAINS_RAMHASH = _ASSETCHAINS_RAMHASH;
const char *ASSETCHAINS_ALGORITHMS[] = {"equihash", "randomx", "memhash"}; const char *ASSETCHAINS_ALGORITHMS[] = {"equihash", "randomx", "ramhash"};
uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff}; uint64_t ASSETCHAINS_NONCEMASK[] = {0xffff};
uint32_t ASSETCHAINS_NONCESHIFT[] = {32}; uint32_t ASSETCHAINS_NONCESHIFT[] = {32};
uint32_t ASSETCHAINS_HASHESPERROUND[] = {1}; uint32_t ASSETCHAINS_HASHESPERROUND[] = {1};

44
src/miner.cpp

@ -118,7 +118,7 @@ public:
}; };
extern int8_t ASSETCHAINS_ADAPTIVEPOW; extern int8_t ASSETCHAINS_ADAPTIVEPOW;
extern uint32_t ASSETCHAINS_RANDOMX, ASSETCHAINS_MEMHASH; extern uint32_t ASSETCHAINS_RANDOMX, ASSETCHAINS_RAMHASH;
extern bool fRandomXDebug; extern bool fRandomXDebug;
void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev) void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev)
@ -1413,14 +1413,14 @@ void static RandomXMiner()
} }
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
void static MemhashMiner(CWallet *pwallet) void static RamhashMiner(CWallet *pwallet)
#else #else
void static MemhashMiner() void static RamhashMiner()
#endif #endif
{ {
LogPrintf("HushMemhashMiner started\n"); LogPrintf("HushRamhashMiner started\n");
SetThreadPriority(THREAD_PRIORITY_LOWEST); SetThreadPriority(THREAD_PRIORITY_LOWEST);
RenameThread("hush-memhash"); RenameThread("hush-ramhash");
const CChainParams& chainparams = Params(); const CChainParams& chainparams = Params();
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
@ -1448,11 +1448,11 @@ void static MemhashMiner()
); );
miningTimer.start(); miningTimer.start();
// TODO: Start actual memhash stuff // TODO: Start actual ramhash stuff
try { try {
fprintf(stderr,"MemhashMiner: mining %s with memhash\n",SMART_CHAIN_SYMBOL); fprintf(stderr,"RamhashMiner: mining %s with ramhash\n",SMART_CHAIN_SYMBOL);
while(true) { while(true) {
fprintf(stderr,"MemhashMiner: beginning mining loop on %s with nExtraNonce=%u\n",SMART_CHAIN_SYMBOL, nExtraNonce); fprintf(stderr,"RamhashMiner: beginning mining loop on %s with nExtraNonce=%u\n",SMART_CHAIN_SYMBOL, nExtraNonce);
if (chainparams.MiningRequiresPeers()) { if (chainparams.MiningRequiresPeers()) {
miningTimer.stop(); miningTimer.stop();
do { do {
@ -1496,12 +1496,12 @@ void static MemhashMiner()
{ {
miningTimer.stop(); miningTimer.stop();
c.disconnect(); c.disconnect();
LogPrintf("HushMemhashMiner terminated\n"); LogPrintf("HushRamhashMiner terminated\n");
return; return;
} }
static uint32_t counter; static uint32_t counter;
if ( counter++ < 10 ) if ( counter++ < 10 )
fprintf(stderr,"MemhashMiner: created illegal blockB, retry with counter=%u\n", counter); fprintf(stderr,"RamhashMiner: created illegal blockB, retry with counter=%u\n", counter);
sleep(1); sleep(1);
continue; continue;
} }
@ -1510,10 +1510,10 @@ void static MemhashMiner()
if (!pblocktemplate.get()) if (!pblocktemplate.get())
{ {
if (GetArg("-mineraddress", "").empty()) { if (GetArg("-mineraddress", "").empty()) {
LogPrintf("Error in HushMemhashMiner: Keypool ran out, please call keypoolrefill before restarting the mining thread\n"); LogPrintf("Error in HushRamhashMiner: Keypool ran out, please call keypoolrefill before restarting the mining thread\n");
} else { } else {
// Should never reach here, because -mineraddress validity is checked in init.cpp // Should never reach here, because -mineraddress validity is checked in init.cpp
LogPrintf("Error in HushMemhashMiner: Invalid -mineraddress\n"); LogPrintf("Error in HushRamhashMiner: Invalid -mineraddress\n");
} }
return; return;
} }
@ -1531,7 +1531,7 @@ void static MemhashMiner()
} }
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
LogPrintf("Running HushMemhashMiner with %u transactions in block (%u bytes)\n",pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); LogPrintf("Running HushRamhashMiner with %u transactions in block (%u bytes)\n",pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
// Search // Search
uint8_t pubkeys[66][33]; arith_uint256 bnMaxPoSdiff; uint32_t blocktimes[66]; int mids[256],nonzpkeys,i,j,externalflag; uint8_t pubkeys[66][33]; arith_uint256 bnMaxPoSdiff; uint32_t blocktimes[66]; int mids[256],nonzpkeys,i,j,externalflag;
@ -1547,19 +1547,19 @@ void static MemhashMiner()
while (true) while (true)
{ {
if ( gotinvalid != 0 ) { if ( gotinvalid != 0 ) {
fprintf(stderr,"HushMemhashMiner: gotinvalid=%d\n",gotinvalid); fprintf(stderr,"HushRamhashMiner: gotinvalid=%d\n",gotinvalid);
break; break;
} }
hush_longestchain(); hush_longestchain();
fprintf(stderr,"HushMemhashMiner: solving with nNonce = %s\n",pblock->nNonce.ToString().c_str()); fprintf(stderr,"HushRamhashMiner: solving with nNonce = %s\n",pblock->nNonce.ToString().c_str());
arith_uint256 hashTarget; arith_uint256 hashTarget;
hashTarget = HASHTarget; hashTarget = HASHTarget;
CDataStream memhashInput(SER_NETWORK, PROTOCOL_VERSION); CDataStream ramhashInput(SER_NETWORK, PROTOCOL_VERSION);
// Use the current block as input // Use the current block as input
memhashInput << pblocktemplate->block; ramhashInput << pblocktemplate->block;
//TODO: calculate actual memhash hash with input //TODO: calculate actual ramhash hash with input
//TODO: Use hash to build a valid block //TODO: Use hash to build a valid block
} }
} }
@ -2035,16 +2035,16 @@ void static BitcoinMiner()
minerThreads->create_thread(boost::bind(&BitcoinMiner, pwallet)); minerThreads->create_thread(boost::bind(&BitcoinMiner, pwallet));
} else if (ASSETCHAINS_ALGO == ASSETCHAINS_RANDOMX ) { } else if (ASSETCHAINS_ALGO == ASSETCHAINS_RANDOMX ) {
minerThreads->create_thread(boost::bind(&RandomXMiner, pwallet)); minerThreads->create_thread(boost::bind(&RandomXMiner, pwallet));
} else if (ASSETCHAINS_ALGO == ASSETCHAINS_MEMHASH ) { } else if (ASSETCHAINS_ALGO == ASSETCHAINS_RAMHASH ) {
minerThreads->create_thread(boost::bind(&MemhashMiner, pwallet)); minerThreads->create_thread(boost::bind(&RamhashMiner, pwallet));
} }
#else #else
if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH ) { if (ASSETCHAINS_ALGO == ASSETCHAINS_EQUIHASH ) {
minerThreads->create_thread(&BitcoinMiner); minerThreads->create_thread(&BitcoinMiner);
} else if (ASSETCHAINS_ALGO == ASSETCHAINS_RANDOMX) { } else if (ASSETCHAINS_ALGO == ASSETCHAINS_RANDOMX) {
minerThreads->create_thread(&RandomXMiner); minerThreads->create_thread(&RandomXMiner);
} else if (ASSETCHAINS_ALGO == ASSETCHAINS_MEMHASH ) { } else if (ASSETCHAINS_ALGO == ASSETCHAINS_RAMHASH ) {
minerThreads->create_thread(boost::bind(&MemhashMiner)); minerThreads->create_thread(boost::bind(&RamhashMiner));
} }
#endif #endif
} }

Loading…
Cancel
Save