test
This commit is contained in:
@@ -27,7 +27,7 @@ struct pax_transaction
|
||||
|
||||
uint64_t komodo_paxtotal()
|
||||
{
|
||||
struct pax_transaction *pax,*tmp; int32_t n = 0; uint64_t total = 0;
|
||||
struct pax_transaction *pax,*tmp; uint64_t total = 0;
|
||||
/*pthread_mutex_lock(&komodo_mutex);
|
||||
tmp = 0;
|
||||
if ( PAX != 0 )
|
||||
@@ -167,41 +167,33 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *
|
||||
else opcode = 'X';
|
||||
HASH_ITER(hh,PAX,pax,tmp)
|
||||
{
|
||||
//if ( PAX == 0 )
|
||||
// return;
|
||||
tmp = 0;
|
||||
//pax = (struct pax_transaction *)PAX->hh.next;
|
||||
//while ( pax != 0 && pax != tmp )
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("pax.%p marked.%d %.8f -> %.8f\n",pax,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
|
||||
if ( pax->marked != 0 )
|
||||
continue;
|
||||
txNew->vout.resize(numvouts+1);
|
||||
txNew->vout[numvouts].nValue = pax->fiatoshis;
|
||||
txNew->vout[numvouts].scriptPubKey.resize(25);
|
||||
script = (uint8_t *)&txNew->vout[numvouts].scriptPubKey[0];
|
||||
*script++ = 0x76;
|
||||
*script++ = 0xa9;
|
||||
*script++ = 20;
|
||||
memcpy(script,pax->rmd160,20), script += 20;
|
||||
*script++ = 0x88;
|
||||
*script++ = 0xac;
|
||||
for (i=0; i<32; i++)
|
||||
{
|
||||
printf("%02x",((uint8_t *)&pax->txid)[i]);
|
||||
data[len++] = ((uint8_t *)&pax->txid)[i];
|
||||
}
|
||||
data[len++] = pax->vout & 0xff;
|
||||
data[len++] = (pax->vout >> 8) & 0xff;
|
||||
if ( strcmp(symbol,"KMD") != 0 )
|
||||
PENDING_KOMODO_TX += pax->fiatoshis;
|
||||
else PENDING_KOMODO_TX += pax->komodoshis;
|
||||
printf(" vout.%u DEPOSIT %.8f <- paxdeposit.%s pending %.8f\n",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX));
|
||||
if ( numvouts++ >= 64 )
|
||||
break;
|
||||
//tmp = pax;
|
||||
//pax = (struct pax_transaction *)pax->hh.next;
|
||||
if ( pax->marked != 0 )
|
||||
continue;
|
||||
txNew->vout.resize(numvouts+1);
|
||||
txNew->vout[numvouts].nValue = pax->fiatoshis;
|
||||
txNew->vout[numvouts].scriptPubKey.resize(25);
|
||||
script = (uint8_t *)&txNew->vout[numvouts].scriptPubKey[0];
|
||||
*script++ = 0x76;
|
||||
*script++ = 0xa9;
|
||||
*script++ = 20;
|
||||
memcpy(script,pax->rmd160,20), script += 20;
|
||||
*script++ = 0x88;
|
||||
*script++ = 0xac;
|
||||
for (i=0; i<32; i++)
|
||||
{
|
||||
printf("%02x",((uint8_t *)&pax->txid)[i]);
|
||||
data[len++] = ((uint8_t *)&pax->txid)[i];
|
||||
}
|
||||
data[len++] = pax->vout & 0xff;
|
||||
data[len++] = (pax->vout >> 8) & 0xff;
|
||||
if ( strcmp(symbol,"KMD") != 0 )
|
||||
PENDING_KOMODO_TX += pax->fiatoshis;
|
||||
else PENDING_KOMODO_TX += pax->komodoshis;
|
||||
printf(" vout.%u DEPOSIT %.8f <- paxdeposit.%s pending %.8f\n",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX));
|
||||
if ( numvouts++ >= 64 )
|
||||
break;
|
||||
}
|
||||
if ( numvouts > 1 )
|
||||
{
|
||||
|
||||
@@ -114,7 +114,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
if(!pblocktemplate.get())
|
||||
return NULL;
|
||||
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
||||
fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize());
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize());
|
||||
while ( chainActive.Tip()->nHeight > ASSETCHAINS_MINHEIGHT && mempool.GetTotalTxSize() <= 0 )
|
||||
{
|
||||
deposits = komodo_paxtotal();
|
||||
@@ -578,8 +579,8 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
}
|
||||
CBlock *pblock = &pblocktemplate->block;
|
||||
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce);
|
||||
LogPrintf("Running ZcashMiner.%s with %u transactions in block (%u bytes)\n", solver.c_str(),pblock->vtx.size(),
|
||||
::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
|
||||
LogPrintf("Running ZcashMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
||||
frintf(stderr,"Running ZcashMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION));
|
||||
|
||||
//
|
||||
// Search
|
||||
@@ -594,9 +595,9 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1);
|
||||
} else Mining_start = 0;
|
||||
Mining_height = pindexPrev->nHeight+1;
|
||||
//fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL);
|
||||
while (true)
|
||||
{
|
||||
fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL);
|
||||
// Hash state
|
||||
crypto_generichash_blake2b_state state;
|
||||
EhInitialiseState(n, k, state);
|
||||
@@ -610,19 +611,22 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
crypto_generichash_blake2b_state curr_state;
|
||||
curr_state = state;
|
||||
crypto_generichash_blake2b_update(&curr_state,pblock->nNonce.begin(),pblock->nNonce.size());
|
||||
|
||||
// (x_1, x_2, ...) = A(I, V, n, k)
|
||||
LogPrint("pow", "Running Equihash solver \"%s\" with nNonce = %s\n",solver, pblock->nNonce.ToString());
|
||||
|
||||
std::function<bool(std::vector<unsigned char>)> validBlock =
|
||||
[&pblock, &hashTarget, &pwallet, &reservekey, &m_cs, &cancelSolver, &chainparams]
|
||||
(std::vector<unsigned char> soln) {
|
||||
(std::vector<unsigned char> soln)
|
||||
{
|
||||
// Write the solution to the hash and compute the result.
|
||||
LogPrint("pow", "- Checking solution against target\n");
|
||||
pblock->nSolution = soln;
|
||||
solutionTargetChecks.increment();
|
||||
if ( UintToArith256(pblock->GetHash()) > hashTarget )
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("missed target\n");
|
||||
return false;
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+20 )
|
||||
{
|
||||
printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+20-time(NULL)));
|
||||
@@ -707,14 +711,29 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
boost::this_thread::interruption_point();
|
||||
// Regtest mode doesn't require peers
|
||||
if (vNodes.empty() && chainparams.MiningRequiresPeers())
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("no nodes, break\n");
|
||||
break;
|
||||
}
|
||||
if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff)
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("0xffff, break\n");
|
||||
break;
|
||||
}
|
||||
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("timeout, break\n");
|
||||
break;
|
||||
if (pindexPrev != chainActive.Tip())
|
||||
}
|
||||
if ( pindexPrev != chainActive.Tip() )
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("Tip advanced, break\n");
|
||||
break;
|
||||
|
||||
}
|
||||
// Update nNonce and nTime
|
||||
pblock->nNonce = ArithToUint256(UintToArith256(pblock->nNonce) + 1);
|
||||
pblock->nBits = savebits;
|
||||
|
||||
Reference in New Issue
Block a user