ptx = ptxIn;
dPriority = dFeePerKb = 0;
}
-
- void print() const
- {
- printf("COrphan(hash=%s, dPriority=%.1f, dFeePerKb=%.1f)\n",
- ptx->GetHash().ToString().substr(0,10).c_str(), dPriority, dFeePerKb);
- BOOST_FOREACH(uint256 hash, setDependsOn)
- printf(" setDependsOn %s\n", hash.ToString().substr(0,10).c_str());
- }
};
};
// CreateNewBlock: create new block (without proof-of-work/with provided coinstake)
-CBlock* CreateNewBlock(CWallet* pwallet, CTransaction *txCoinStake)
+std::shared_ptr<CBlock> CreateNewBlock(CWallet* pwallet, CTransaction *txCoinStake)
{
bool fProofOfStake = txCoinStake != NULL;
// Create new block
- auto_ptr<CBlock> pblock(new CBlock());
+ shared_ptr<CBlock> pblock(new CBlock());
if (!pblock.get())
return NULL;
}
// Largest block you're willing to create:
- unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2);
+ unsigned int nBlockMaxSize = GetArgUInt("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2);
// Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity:
- nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize));
+ nBlockMaxSize = std::max(1000u, std::min(MAX_BLOCK_SIZE-1000u, nBlockMaxSize));
// How much of the block should be dedicated to high-priority transactions,
// included regardless of the fees they pay
- unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", 27000);
+ unsigned int nBlockPrioritySize = GetArgUInt("-blockprioritysize", 27000);
nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize);
// Minimum block size you want to create; block will be filled with free transactions
// until there are no more or the block reaches this size:
- unsigned int nBlockMinSize = GetArg("-blockminsize", 0);
+ unsigned int nBlockMinSize = GetArgUInt("-blockminsize", 0);
nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize);
// Fee-per-kilobyte amount considered the same as "free"
pblock->nNonce = 0;
}
- return pblock.release();
+ return pblock;
}
-void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
+void IncrementExtraNonce(shared_ptr<CBlock>& pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce)
{
// Update nExtraNonce
static uint256 hashPrevBlock;
}
-void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1)
+void FormatHashBuffers(const shared_ptr<CBlock>& pblock, char* pmidstate, char* pdata, char* phash1)
{
//
// Pre-build hash buffers
}
-bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
+bool CheckWork(const std::shared_ptr<CBlock>& pblock, CWallet& wallet, CReserveKey& reservekey)
{
uint256 hashBlock = pblock->GetHash();
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
}
// Process this block the same as if we had received it from another node
- if (!ProcessBlock(NULL, pblock))
+ if (!ProcessBlock(NULL, pblock.get()))
return error("CheckWork() : ProcessBlock, block not accepted");
}
return true;
}
-bool CheckStake(CBlock* pblock, CWallet& wallet)
+bool CheckStake(const std::shared_ptr<CBlock>& pblock, CWallet& wallet)
{
uint256 proofHash = 0, hashTarget = 0;
uint256 hashBlock = pblock->GetHash();
}
// Process this block the same as if we had received it from another node
- if (!ProcessBlock(NULL, pblock))
+ if (!ProcessBlock(NULL, pblock.get()))
return error("CheckStake() : ProcessBlock, block not accepted");
}
}
// Now we have new coinstake, it's time to create the block ...
- CBlock* pblock;
- pblock = CreateNewBlock(pwallet, &txCoinStake);
+ std::shared_ptr<CBlock> pblock = CreateNewBlock(pwallet, &txCoinStake);
if (!pblock)
{
string strMessage = _("Warning: Unable to allocate memory for the new block object. Mining thread has been stopped.");