Skip to content

Commit 303c171

Browse files
committed
Merge #10553: Simplify "bool x = y ? true : false". Remove unused function and trailing semicolon.
67ca816 Simplify "bool x = y ? true : false" to "bool x = y" (practicalswift) 9f841a6 [tests] Remove accidental trailing semicolon (practicalswift) 30c2d9d [tests] Remove unused function InsecureRandBytes(size_t len) (practicalswift) Tree-SHA512: ae62c255c88133cad12084b6011c105bb96b729c8103330350683d9c20020c5d7617693795df4dff6cc305f2405cb2e4e2ece182d6e6d7c3c8db82aa2f882c41
2 parents 8d9f45e + 67ca816 commit 303c171

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

src/blockencodings.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ ReadStatus PartiallyDownloadedBlock::InitData(const CBlockHeaderAndShortTxIDs& c
172172
bool PartiallyDownloadedBlock::IsTxAvailable(size_t index) const {
173173
assert(!header.IsNull());
174174
assert(index < txn_available.size());
175-
return txn_available[index] ? true : false;
175+
return txn_available[index] != nullptr;
176176
}
177177

178178
ReadStatus PartiallyDownloadedBlock::FillBlock(CBlock& block, const std::vector<CTransactionRef>& vtx_missing) {

src/rpc/misc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,8 @@ UniValue validateaddress(const JSONRPCRequest& request)
210210

211211
#ifdef ENABLE_WALLET
212212
isminetype mine = pwallet ? IsMine(*pwallet, dest) : ISMINE_NO;
213-
ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
214-
ret.push_back(Pair("iswatchonly", (mine & ISMINE_WATCH_ONLY) ? true: false));
213+
ret.push_back(Pair("ismine", bool(mine & ISMINE_SPENDABLE)));
214+
ret.push_back(Pair("iswatchonly", bool(mine & ISMINE_WATCH_ONLY)));
215215
UniValue detail = boost::apply_visitor(DescribeAddressVisitor(pwallet), dest);
216216
ret.pushKVs(detail);
217217
if (pwallet && pwallet->mapAddressBook.count(dest)) {

src/test/miner_tests.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
260260
{
261261
tx.vout[0].nValue -= LOWFEE;
262262
hash = tx.GetHash();
263-
bool spendsCoinbase = (i == 0) ? true : false; // only first tx spends coinbase
263+
bool spendsCoinbase = i == 0; // only first tx spends coinbase
264264
// If we don't set the # of sig ops in the CTxMemPoolEntry, template creation fails
265265
mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
266266
tx.vin[0].prevout.hash = hash;
@@ -274,7 +274,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
274274
{
275275
tx.vout[0].nValue -= LOWFEE;
276276
hash = tx.GetHash();
277-
bool spendsCoinbase = (i == 0) ? true : false; // only first tx spends coinbase
277+
bool spendsCoinbase = i == 0; // only first tx spends coinbase
278278
// If we do set the # of sig ops in the CTxMemPoolEntry, template creation passes
279279
mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).SigOpsCost(80).FromTx(tx));
280280
tx.vin[0].prevout.hash = hash;
@@ -295,7 +295,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
295295
{
296296
tx.vout[0].nValue -= LOWFEE;
297297
hash = tx.GetHash();
298-
bool spendsCoinbase = (i == 0) ? true : false; // only first tx spends coinbase
298+
bool spendsCoinbase = i == 0; // only first tx spends coinbase
299299
mempool.addUnchecked(hash, entry.Fee(LOWFEE).Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
300300
tx.vin[0].prevout.hash = hash;
301301
}

src/test/test_bitcoin.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ static inline uint256 InsecureRand256() { return insecure_rand_ctx.rand256(); }
3333
static inline uint64_t InsecureRandBits(int bits) { return insecure_rand_ctx.randbits(bits); }
3434
static inline uint64_t InsecureRandRange(uint64_t range) { return insecure_rand_ctx.randrange(range); }
3535
static inline bool InsecureRandBool() { return insecure_rand_ctx.randbool(); }
36-
static inline std::vector<unsigned char> InsecureRandBytes(size_t len) { return insecure_rand_ctx.randbytes(len); }
3736

3837
/** Basic testing setup.
3938
* This just configures logging and chain parameters.

test/functional/replace-by-fee.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ def test_prioritised_transactions(self):
521521

522522
def test_rpc(self):
523523
us0 = self.nodes[0].listunspent()[0]
524-
ins = [us0];
524+
ins = [us0]
525525
outs = {self.nodes[0].getnewaddress() : Decimal(1.0000000)}
526526
rawtx0 = self.nodes[0].createrawtransaction(ins, outs, 0, True)
527527
rawtx1 = self.nodes[0].createrawtransaction(ins, outs, 0, False)

0 commit comments

Comments
 (0)