Test
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "CCfaucet.h"
|
#include "CCfaucet.h"
|
||||||
|
#include "../txmempool.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file implements a simple CC faucet as an example of how to make a new CC contract. It wont have any fancy sybil protection but will serve the purpose of a fully automated faucet.
|
This file implements a simple CC faucet as an example of how to make a new CC contract. It wont have any fancy sybil protection but will serve the purpose of a fully automated faucet.
|
||||||
@@ -65,14 +66,15 @@ bool FaucetExactAmounts(Eval* eval,const CTransaction &tx,int32_t minage,uint64_
|
|||||||
fprintf(stderr,"vini.%d\n",i);
|
fprintf(stderr,"vini.%d\n",i);
|
||||||
if ( IsFaucetInput(tx.vin[i].scriptSig) != 0 )
|
if ( IsFaucetInput(tx.vin[i].scriptSig) != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"vini.%d get Tx\n",i);
|
fprintf(stderr,"vini.%d check mempool\n",i);
|
||||||
if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 )
|
if ( mempool.lookup(hash, vinTx) != 0 )
|
||||||
return eval->Invalid("always should find vin, but didnt");
|
//if ( eval->GetTxUnconfirmed(tx.vin[i].prevout.hash,vinTx,hashBlock) == 0 )
|
||||||
|
return eval->Invalid("cant faucet mempool tx");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr,"vini.%d check hash and vout\n",i);
|
fprintf(stderr,"vini.%d check hash and vout\n",i);
|
||||||
if ( hashBlock == zerohash )
|
//if ( hashBlock == zerohash )
|
||||||
return eval->Invalid("cant faucet from mempool");
|
// return eval->Invalid("cant faucet from mempool");
|
||||||
if ( (assetoshis= IsFaucetvout(vinTx,tx.vin[i].prevout.n)) != 0 )
|
if ( (assetoshis= IsFaucetvout(vinTx,tx.vin[i].prevout.n)) != 0 )
|
||||||
inputs += assetoshis;
|
inputs += assetoshis;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1607,7 +1607,6 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo
|
|||||||
{
|
{
|
||||||
// need a GetTransaction without lock so the validation code for assets can run without deadlock
|
// need a GetTransaction without lock so the validation code for assets can run without deadlock
|
||||||
{
|
{
|
||||||
LOCK(mempool.cs);
|
|
||||||
fprintf(stderr,"check mempool\n");
|
fprintf(stderr,"check mempool\n");
|
||||||
if (mempool.lookup(hash, txOut))
|
if (mempool.lookup(hash, txOut))
|
||||||
{
|
{
|
||||||
@@ -1634,9 +1633,11 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo
|
|||||||
hashBlock = header.GetHash();
|
hashBlock = header.GetHash();
|
||||||
if (txOut.GetHash() != hash)
|
if (txOut.GetHash() != hash)
|
||||||
return error("%s: txid mismatch", __func__);
|
return error("%s: txid mismatch", __func__);
|
||||||
|
fprintf(stderr,"found on disk\n");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fprintf(stderr,"not found\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4116,9 +4117,10 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
|
|||||||
REJECT_INVALID, "bad-cb-multiple");
|
REJECT_INVALID, "bad-cb-multiple");
|
||||||
|
|
||||||
// Check transactions
|
// Check transactions
|
||||||
if ( 0 && ASSETCHAINS_CC != 0 ) // CC contracts might refer to transactions in the current block, from a CC spend within the same block and out of order
|
if ( ASSETCHAINS_CC != 0 ) // CC contracts might refer to transactions in the current block, from a CC spend within the same block and out of order
|
||||||
{
|
{
|
||||||
CValidationState stateDummy;
|
CValidationState stateDummy;
|
||||||
|
fprintf(stderr,"put block's tx into mempool\n");
|
||||||
for (int i = 0; i < block.vtx.size(); i++)
|
for (int i = 0; i < block.vtx.size(); i++)
|
||||||
{
|
{
|
||||||
const CTransaction &tx = block.vtx[i];
|
const CTransaction &tx = block.vtx[i];
|
||||||
@@ -4128,6 +4130,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
|
|||||||
continue;
|
continue;
|
||||||
AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL);
|
AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL);
|
||||||
}
|
}
|
||||||
|
fprintf(stderr,"done putting block's tx into mempool\n");
|
||||||
}
|
}
|
||||||
BOOST_FOREACH(const CTransaction& tx, block.vtx)
|
BOOST_FOREACH(const CTransaction& tx, block.vtx)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user