style: Add {} to if-bodies in node/miner

Can be reviewed with --word-diff-regex=. --ignore-all-space
This commit is contained in:
MarcoFalke
2021-12-01 09:32:36 +01:00
parent 9174bcf7da
commit fa6b7adf96
2 changed files with 30 additions and 21 deletions

View File

@@ -31,12 +31,14 @@ int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParam
int64_t nOldTime = pblock->nTime; int64_t nOldTime = pblock->nTime;
int64_t nNewTime = std::max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime()); int64_t nNewTime = std::max(pindexPrev->GetMedianTimePast() + 1, GetAdjustedTime());
if (nOldTime < nNewTime) if (nOldTime < nNewTime) {
pblock->nTime = nNewTime; pblock->nTime = nNewTime;
}
// Updating time can change work required on testnet: // Updating time can change work required on testnet:
if (consensusParams.fPowAllowMinDifficultyBlocks) if (consensusParams.fPowAllowMinDifficultyBlocks) {
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams); pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams);
}
return nNewTime - nOldTime; return nNewTime - nOldTime;
} }
@@ -53,7 +55,8 @@ void RegenerateCommitments(CBlock& block, ChainstateManager& chainman)
block.hashMerkleRoot = BlockMerkleRoot(block); block.hashMerkleRoot = BlockMerkleRoot(block);
} }
BlockAssembler::Options::Options() { BlockAssembler::Options::Options()
{
blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE); blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE);
nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT; nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
} }
@@ -108,8 +111,9 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
pblocktemplate.reset(new CBlockTemplate()); pblocktemplate.reset(new CBlockTemplate());
if(!pblocktemplate.get()) if (!pblocktemplate.get()) {
return nullptr; return nullptr;
}
CBlock* const pblock = &pblocktemplate->block; // pointer for convenience CBlock* const pblock = &pblocktemplate->block; // pointer for convenience
// Add dummy coinbase tx as first transaction // Add dummy coinbase tx as first transaction
@@ -125,8 +129,9 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
pblock->nVersion = g_versionbitscache.ComputeBlockVersion(pindexPrev, chainparams.GetConsensus()); pblock->nVersion = g_versionbitscache.ComputeBlockVersion(pindexPrev, chainparams.GetConsensus());
// -regtest only: allow overriding block.nVersion with // -regtest only: allow overriding block.nVersion with
// -blockversion=N to test forking scenarios // -blockversion=N to test forking scenarios
if (chainparams.MineBlocksOnDemand()) if (chainparams.MineBlocksOnDemand()) {
pblock->nVersion = gArgs.GetIntArg("-blockversion", pblock->nVersion); pblock->nVersion = gArgs.GetIntArg("-blockversion", pblock->nVersion);
}
pblock->nTime = GetAdjustedTime(); pblock->nTime = GetAdjustedTime();
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
@@ -193,8 +198,7 @@ void BlockAssembler::onlyUnconfirmed(CTxMemPool::setEntries& testSet)
// Only test txs not already in the block // Only test txs not already in the block
if (inBlock.count(*iit)) { if (inBlock.count(*iit)) {
testSet.erase(iit++); testSet.erase(iit++);
} } else {
else {
iit++; iit++;
} }
} }
@@ -203,10 +207,12 @@ void BlockAssembler::onlyUnconfirmed(CTxMemPool::setEntries& testSet)
bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost) const bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost) const
{ {
// TODO: switch to weight-based accounting for packages instead of vsize-based accounting. // TODO: switch to weight-based accounting for packages instead of vsize-based accounting.
if (nBlockWeight + WITNESS_SCALE_FACTOR * packageSize >= nBlockMaxWeight) if (nBlockWeight + WITNESS_SCALE_FACTOR * packageSize >= nBlockMaxWeight) {
return false; return false;
if (nBlockSigOpsCost + packageSigOpsCost >= MAX_BLOCK_SIGOPS_COST) }
if (nBlockSigOpsCost + packageSigOpsCost >= MAX_BLOCK_SIGOPS_COST) {
return false; return false;
}
return true; return true;
} }
@@ -217,11 +223,13 @@ bool BlockAssembler::TestPackage(uint64_t packageSize, int64_t packageSigOpsCost
bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package) const bool BlockAssembler::TestPackageTransactions(const CTxMemPool::setEntries& package) const
{ {
for (CTxMemPool::txiter it : package) { for (CTxMemPool::txiter it : package) {
if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff)) if (!IsFinalTx(it->GetTx(), nHeight, nLockTimeCutoff)) {
return false; return false;
if (!fIncludeWitness && it->GetTx().HasWitness()) }
if (!fIncludeWitness && it->GetTx().HasWitness()) {
return false; return false;
} }
}
return true; return true;
} }
@@ -253,8 +261,9 @@ int BlockAssembler::UpdatePackagesForAdded(const CTxMemPool::setEntries& already
m_mempool.CalculateDescendants(it, descendants); m_mempool.CalculateDescendants(it, descendants);
// Insert all descendants (not yet in block) into the modified set // Insert all descendants (not yet in block) into the modified set
for (CTxMemPool::txiter desc : descendants) { for (CTxMemPool::txiter desc : descendants) {
if (alreadyAdded.count(desc)) if (alreadyAdded.count(desc)) {
continue; continue;
}
++nDescendantsUpdated; ++nDescendantsUpdated;
modtxiter mit = mapModifiedTx.find(desc); modtxiter mit = mapModifiedTx.find(desc);
if (mit == mapModifiedTx.end()) { if (mit == mapModifiedTx.end()) {
@@ -440,8 +449,7 @@ void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned
{ {
// Update nExtraNonce // Update nExtraNonce
static uint256 hashPrevBlock; static uint256 hashPrevBlock;
if (hashPrevBlock != pblock->hashPrevBlock) if (hashPrevBlock != pblock->hashPrevBlock) {
{
nExtraNonce = 0; nExtraNonce = 0;
hashPrevBlock = pblock->hashPrevBlock; hashPrevBlock = pblock->hashPrevBlock;
} }

View File

@@ -82,8 +82,9 @@ struct modifiedentry_iter {
struct CompareTxIterByAncestorCount { struct CompareTxIterByAncestorCount {
bool operator()(const CTxMemPool::txiter& a, const CTxMemPool::txiter& b) const bool operator()(const CTxMemPool::txiter& a, const CTxMemPool::txiter& b) const
{ {
if (a->GetCountWithAncestors() != b->GetCountWithAncestors()) if (a->GetCountWithAncestors() != b->GetCountWithAncestors()) {
return a->GetCountWithAncestors() < b->GetCountWithAncestors(); return a->GetCountWithAncestors() < b->GetCountWithAncestors();
}
return CompareIteratorByHash()(a, b); return CompareIteratorByHash()(a, b);
} }
}; };