Browse Source

Merge pull request #1065 from jl777/FSM

FSM
pull/4/head
jl777 6 years ago
committed by GitHub
parent
commit
d661fc87df
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/cc/dapps/zmigrate.c
  2. 9
      src/cc/dice.cpp
  3. 31
      src/main.cpp

2
src/cc/dapps/zmigrate.c

@ -906,7 +906,7 @@ int32_t main(int32_t argc,char **argv)
zsaddr = clonestr(argv[2]);
printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr);
uint32_t lastopid; char coinaddr[64],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee;
stdamount = 10000 * SATOSHIDEN;
stdamount = 1000 * SATOSHIDEN;
txfee = 10000;
again:
printf("start processing zmigrate\n");

9
src/cc/dice.cpp

@ -427,11 +427,11 @@ void *dicefinish(void *_ptr)
if ( vin0_needed > 0 )
{
num = 0;
//fprintf(stderr,"iter.%d vin0_needed.%d\n",iter,vin0_needed);
//fprintf(stderr,"iter.%d vin0_needed.%d\n",iter,vin0_needed);
utxos = (struct dicefinish_utxo *)calloc(vin0_needed,sizeof(*utxos));
if ( (n= dicefinish_utxosget(num,utxos,vin0_needed,coinaddr)) > 0 )
{
//fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num);
//fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num);
m = 0;
DL_FOREACH_SAFE(DICEFINISH_LIST,ptr,tmp)
{
@ -484,7 +484,8 @@ void *dicefinish(void *_ptr)
//fprintf(stderr,"error ready.%d dicefinish %d of %d process %s %s using need %.8f finish.%s size.%d betspent.%d\n",ptr->bettxid_ready,m,n,iter<0?"loss":"win",ptr->bettxid.GetHex().c_str(),(double)(iter<0 ? 0 : ptr->winamount)/COIN,ptr->txid.GetHex().c_str(),(int32_t)ptr->rawtx.size(),dice_betspent((char *)"dicefinish",ptr->bettxid));
}
}
}
} else if ( system("cc/dapps/sendmany100") != 0 )
fprintf(stderr,"error issing cc/dapps/sendmany100\n");
free(utxos);
}
}
@ -533,7 +534,7 @@ void DiceQueue(int32_t iswin,uint64_t sbits,uint256 fundingtxid,uint256 bettxid,
else
{
//fprintf(stderr,"DiceQueue status bettxid.%s already in list\n",bettxid.GetHex().c_str());
_dicehash_clear(bettxid);
//_dicehash_clear(bettxid);
}
pthread_mutex_unlock(&DICE_MUTEX);
}

31
src/main.cpp

@ -4695,6 +4695,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
mempool.remove(tx, removed, false);
}
// add all the txs in the block to the empty mempool.
// CC validation shouldnt (cant) depend on the state of mempool!
while ( 1 )
{
for (i=0; i<block.vtx.size(); i++)
@ -4764,18 +4765,28 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
{
// here we add back all txs from the temp mempool to the main mempool.
// which removes any tx locally that were invalid after the block arrives.
int invalidtxs = 0;
int numadded,numiters = 0;
CValidationState state; bool fMissingInputs,fOverrideFees = false;
list<CTransaction> removed;
LOCK(mempool.cs);
BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) {
CTransaction tx = e.GetTx();
CValidationState state; bool fMissingInputs,fOverrideFees = false;
if (AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees) == false )
invalidtxs++;
//else fprintf(stderr, "added mempool tx back to mempool\n");
while ( 1 )
{
numiters++;
numadded = 0;
BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx)
{
CTransaction tx = e.GetTx();
if (AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees) == true )
{
numadded++;
tmpmempool.remove(tx, removed, false);
}
}
if ( numadded == 0 )
break;
}
if ( 0 && invalidtxs > 0 )
fprintf(stderr, "number of invalid txs: %d\n",invalidtxs );
if ( 0 && numadded > 0 )
fprintf(stderr, "CC mempool add: numiters.%d numadded.%d remains.%d\n",numiters,numadded,(int32_t)tmpmempool.size());
// empty the temp mempool for next time.
tmpmempool.clear();
}

Loading…
Cancel
Save