Skip to content

Commit b0b85fa

Browse files
committed
Style.
1 parent 00a478e commit b0b85fa

7 files changed

Lines changed: 138 additions & 277 deletions

File tree

src/chain/block.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void block::assign_data(reader& source, bool witness) NOEXCEPT
139139
auto txs = to_non_const_raw_ptr(txs_);
140140
txs->reserve(count);
141141

142-
for (size_t tx = 0; tx < count; ++tx)
142+
for (size_t tx{}; tx < count; ++tx)
143143
txs->emplace_back(CREATE(transaction, allocator, source, witness));
144144

145145
size_ = serialized_size(*txs_);

src/chain/transaction_sighash.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void transaction::signature_hash_single(writer& sink,
9494
const auto index = input_index(input);
9595
sink.write_variable(add1(index));
9696

97-
for (size_t output = 0; output < index; ++output)
97+
for (size_t output{}; output < index; ++output)
9898
sink.write_bytes(null_output());
9999

100100
// Guarded by unversioned_sighash().

src/chain/witness.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void witness::skip(reader& source, bool prefix) NOEXCEPT
157157
{
158158
const auto count = source.read_size(max_block_weight);
159159

160-
for (size_t element = 0; element < count; ++element)
160+
for (size_t element{}; element < count; ++element)
161161
source.read_bytes(source.read_size(max_block_weight));
162162
}
163163
else
@@ -191,7 +191,7 @@ void witness::assign_data(reader& source, bool prefix) NOEXCEPT
191191
const auto count = source.read_size(max_block_weight);
192192
stack_.reserve(count);
193193

194-
for (size_t element = 0; element < count; ++element)
194+
for (size_t element{}; element < count; ++element)
195195
if (!push_witness())
196196
break;
197197
}

test/chain/block.cpp

Lines changed: 14 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -74,78 +74,20 @@ class accessor
7474
public:
7575
// Use base class constructors.
7676
using block::block;
77-
78-
bool is_empty() const NOEXCEPT
79-
{
80-
return block::is_empty();
81-
}
82-
83-
bool is_oversized() const NOEXCEPT
84-
{
85-
return block::is_oversized();
86-
}
87-
88-
bool is_first_non_coinbase() const NOEXCEPT
89-
{
90-
return block::is_first_non_coinbase();
91-
}
92-
93-
bool is_extra_coinbases() const NOEXCEPT
94-
{
95-
return block::is_extra_coinbases();
96-
}
97-
98-
bool is_forward_reference() const NOEXCEPT
99-
{
100-
return block::is_forward_reference();
101-
}
102-
103-
bool is_internal_double_spend() const NOEXCEPT
104-
{
105-
return block::is_internal_double_spend();
106-
}
107-
108-
bool is_invalid_merkle_root() const NOEXCEPT
109-
{
110-
return block::is_invalid_merkle_root();
111-
}
112-
113-
bool is_overweight() const NOEXCEPT
114-
{
115-
return block::is_overweight();
116-
}
117-
118-
bool is_invalid_coinbase_script(size_t height) const NOEXCEPT
119-
{
120-
return block::is_invalid_coinbase_script(height);
121-
}
122-
123-
bool is_hash_limit_exceeded() const NOEXCEPT
124-
{
125-
return block::is_hash_limit_exceeded();
126-
}
127-
128-
bool is_invalid_witness_commitment() const NOEXCEPT
129-
{
130-
return block::is_invalid_witness_commitment();
131-
}
132-
133-
bool is_overspent(size_t height, uint64_t subsidy_interval,
134-
uint64_t initial_block_subsidy_satoshi, bool bip42) const NOEXCEPT
135-
{
136-
return block::is_overspent(height, subsidy_interval,
137-
initial_block_subsidy_satoshi, bip42);
138-
}
139-
140-
size_t is_signature_operations_limited(bool bip16, bool bip141) const NOEXCEPT
141-
{
142-
return block::is_signature_operations_limited(bip16, bip141);
143-
}
144-
145-
bool is_unspent_coinbase_collision() const NOEXCEPT
146-
{
147-
return block::is_unspent_coinbase_collision();
148-
}
77+
using block::is_empty;
78+
using block::is_oversized;
79+
using block::is_first_non_coinbase;
80+
using block::is_extra_coinbases;
81+
using block::is_forward_reference;
82+
using block::is_extra_coinbases;
83+
using block::is_internal_double_spend;
84+
using block::is_invalid_merkle_root;
85+
using block::is_overweight;
86+
using block::is_invalid_coinbase_script;
87+
using block::is_hash_limit_exceeded;
88+
using block::is_invalid_witness_commitment;
89+
using block::is_overspent;
90+
using block::is_signature_operations_limited;
14991
};
15092

15193
// constructors

test/chain/block_malleable.cpp

Lines changed: 103 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,9 @@ class accessor
4040
{
4141
public:
4242
using block::block;
43-
44-
size_t malleated32_size() const NOEXCEPT
45-
{
46-
return block::malleated32_size();
47-
}
48-
49-
bool is_malleated32_(size_t width) const NOEXCEPT
50-
{
51-
return block::is_malleated32(width);
52-
}
53-
54-
static constexpr bool is_malleable32_(size_t set,
55-
size_t width) NOEXCEPT
56-
{
57-
return block::is_malleable32(set, width);
58-
}
43+
using block::malleated32_size;
44+
using block::is_malleated32;
45+
using block::is_malleable32;
5946
};
6047

6148
struct txs
@@ -155,9 +142,9 @@ BOOST_AUTO_TEST_CASE(block__malleable__empty__false)
155142
BOOST_REQUIRE(!instance.is_malleable());
156143
BOOST_REQUIRE(!instance.is_malleable64());
157144
BOOST_REQUIRE(!instance.is_malleable32());
158-
BOOST_REQUIRE(!instance.is_malleable32_(0, 0));
145+
BOOST_REQUIRE(!instance.is_malleable32(0, 0));
159146
BOOST_REQUIRE(!instance.is_malleated32());
160-
BOOST_REQUIRE(!instance.is_malleated32_(0));
147+
BOOST_REQUIRE(!instance.is_malleated32(0));
161148
}
162149

163150
// is_malleable
@@ -326,108 +313,108 @@ BOOST_AUTO_TEST_CASE(block__is_malleable64__three_64_64_64__true)
326313

327314
BOOST_AUTO_TEST_CASE(block__is_malleable32__overflow__false)
328315
{
329-
BOOST_REQUIRE(!accessor::is_malleable32_(0, 1));
330-
BOOST_REQUIRE(!accessor::is_malleable32_(1, 50));
331-
BOOST_REQUIRE(!accessor::is_malleable32_(2, 100));
316+
BOOST_REQUIRE(!accessor::is_malleable32(0, 1));
317+
BOOST_REQUIRE(!accessor::is_malleable32(1, 50));
318+
BOOST_REQUIRE(!accessor::is_malleable32(2, 100));
332319
}
333320

334321
BOOST_AUTO_TEST_CASE(block__is_malleable32__various__expected)
335322
{
336-
BOOST_REQUIRE(!accessor::is_malleable32_(1, 1));
337-
338-
BOOST_REQUIRE(!accessor::is_malleable32_(2, 1));
339-
BOOST_REQUIRE(!accessor::is_malleable32_(2, 2));
340-
341-
BOOST_REQUIRE( accessor::is_malleable32_(3, 1)); // 4:1
342-
BOOST_REQUIRE(!accessor::is_malleable32_(3, 2));
343-
BOOST_REQUIRE(!accessor::is_malleable32_(3, 3));
344-
345-
BOOST_REQUIRE(!accessor::is_malleable32_(4, 1));
346-
BOOST_REQUIRE(!accessor::is_malleable32_(4, 2));
347-
BOOST_REQUIRE(!accessor::is_malleable32_(4, 3));
348-
BOOST_REQUIRE(!accessor::is_malleable32_(4, 4));
349-
350-
BOOST_REQUIRE( accessor::is_malleable32_(5, 1)); // 6:1
351-
BOOST_REQUIRE(!accessor::is_malleable32_(5, 2));
352-
BOOST_REQUIRE(!accessor::is_malleable32_(5, 3));
353-
BOOST_REQUIRE(!accessor::is_malleable32_(5, 4));
354-
BOOST_REQUIRE(!accessor::is_malleable32_(5, 5));
355-
356-
BOOST_REQUIRE(!accessor::is_malleable32_(6, 1));
357-
BOOST_REQUIRE( accessor::is_malleable32_(6, 2)); // 8:2
358-
BOOST_REQUIRE(!accessor::is_malleable32_(6, 3));
359-
BOOST_REQUIRE(!accessor::is_malleable32_(6, 4));
360-
BOOST_REQUIRE(!accessor::is_malleable32_(6, 5));
361-
BOOST_REQUIRE(!accessor::is_malleable32_(6, 6));
362-
363-
BOOST_REQUIRE( accessor::is_malleable32_(7, 1)); // 8:1
364-
BOOST_REQUIRE(!accessor::is_malleable32_(7, 2));
365-
BOOST_REQUIRE(!accessor::is_malleable32_(7, 3));
366-
BOOST_REQUIRE(!accessor::is_malleable32_(7, 4));
367-
BOOST_REQUIRE(!accessor::is_malleable32_(7, 5));
368-
BOOST_REQUIRE(!accessor::is_malleable32_(7, 6));
369-
BOOST_REQUIRE(!accessor::is_malleable32_(7, 7));
370-
371-
BOOST_REQUIRE(!accessor::is_malleable32_(8, 1));
372-
BOOST_REQUIRE(!accessor::is_malleable32_(8, 2));
373-
BOOST_REQUIRE(!accessor::is_malleable32_(8, 3));
374-
BOOST_REQUIRE(!accessor::is_malleable32_(8, 4));
375-
BOOST_REQUIRE(!accessor::is_malleable32_(8, 5));
376-
BOOST_REQUIRE(!accessor::is_malleable32_(8, 6));
377-
BOOST_REQUIRE(!accessor::is_malleable32_(8, 7));
378-
BOOST_REQUIRE(!accessor::is_malleable32_(8, 8));
379-
380-
BOOST_REQUIRE( accessor::is_malleable32_(9, 1)); // 10:1
381-
BOOST_REQUIRE(!accessor::is_malleable32_(9, 2));
382-
BOOST_REQUIRE(!accessor::is_malleable32_(9, 3));
383-
BOOST_REQUIRE(!accessor::is_malleable32_(9, 4));
384-
BOOST_REQUIRE(!accessor::is_malleable32_(9, 5));
385-
BOOST_REQUIRE(!accessor::is_malleable32_(9, 6));
386-
BOOST_REQUIRE(!accessor::is_malleable32_(9, 7));
387-
BOOST_REQUIRE(!accessor::is_malleable32_(9, 8));
388-
BOOST_REQUIRE(!accessor::is_malleable32_(9, 9));
389-
390-
BOOST_REQUIRE(!accessor::is_malleable32_(10, 1));
391-
BOOST_REQUIRE( accessor::is_malleable32_(10, 2)); // 12:2
392-
BOOST_REQUIRE(!accessor::is_malleable32_(10, 3));
393-
BOOST_REQUIRE( accessor::is_malleable32_(11, 1)); // 12:1
394-
BOOST_REQUIRE(!accessor::is_malleable32_(11, 2));
395-
BOOST_REQUIRE(!accessor::is_malleable32_(12, 1));
396-
BOOST_REQUIRE(!accessor::is_malleable32_(12, 2));
397-
BOOST_REQUIRE(!accessor::is_malleable32_(12, 3));
398-
BOOST_REQUIRE( accessor::is_malleable32_(12, 4)); // 16:4
399-
BOOST_REQUIRE( accessor::is_malleable32_(13, 1)); // 14:1
400-
BOOST_REQUIRE(!accessor::is_malleable32_(13, 2));
401-
BOOST_REQUIRE(!accessor::is_malleable32_(14, 1));
402-
BOOST_REQUIRE( accessor::is_malleable32_(14, 2)); // 16:2
403-
BOOST_REQUIRE(!accessor::is_malleable32_(14, 3));
404-
BOOST_REQUIRE( accessor::is_malleable32_(15, 1)); // 16:1
405-
BOOST_REQUIRE(!accessor::is_malleable32_(16, 1));
406-
BOOST_REQUIRE( accessor::is_malleable32_(17, 1)); // 18:1
407-
BOOST_REQUIRE(!accessor::is_malleable32_(18, 1));
408-
BOOST_REQUIRE( accessor::is_malleable32_(18, 2)); // 20:2
409-
BOOST_REQUIRE( accessor::is_malleable32_(19, 1)); // 20:1
410-
BOOST_REQUIRE(!accessor::is_malleable32_(20, 1));
411-
BOOST_REQUIRE(!accessor::is_malleable32_(20, 2));
412-
BOOST_REQUIRE(!accessor::is_malleable32_(20, 3));
413-
BOOST_REQUIRE( accessor::is_malleable32_(20, 4)); // 24:4
414-
BOOST_REQUIRE( accessor::is_malleable32_(21, 1)); // 22:1
415-
BOOST_REQUIRE(!accessor::is_malleable32_(22, 1));
416-
BOOST_REQUIRE( accessor::is_malleable32_(22, 2)); // 24:2
417-
BOOST_REQUIRE( accessor::is_malleable32_(23, 1)); // 24:1
418-
BOOST_REQUIRE(!accessor::is_malleable32_(24, 1));
419-
BOOST_REQUIRE( accessor::is_malleable32_(25, 1)); // 26:1
420-
BOOST_REQUIRE(!accessor::is_malleable32_(26, 1));
421-
BOOST_REQUIRE( accessor::is_malleable32_(26, 2)); // 28:2
422-
BOOST_REQUIRE( accessor::is_malleable32_(27, 1)); // 28:1
423-
BOOST_REQUIRE(!accessor::is_malleable32_(28, 1));
424-
BOOST_REQUIRE(!accessor::is_malleable32_(28, 2));
425-
BOOST_REQUIRE(!accessor::is_malleable32_(28, 3));
426-
BOOST_REQUIRE( accessor::is_malleable32_(28, 4)); // 32:4
427-
BOOST_REQUIRE( accessor::is_malleable32_(29, 1)); // 30:1
428-
BOOST_REQUIRE(!accessor::is_malleable32_(30, 1));
429-
BOOST_REQUIRE( accessor::is_malleable32_(30, 2)); // 32:2
430-
BOOST_REQUIRE( accessor::is_malleable32_(31, 1)); // 32:1
323+
BOOST_REQUIRE(!accessor::is_malleable32(1, 1));
324+
325+
BOOST_REQUIRE(!accessor::is_malleable32(2, 1));
326+
BOOST_REQUIRE(!accessor::is_malleable32(2, 2));
327+
328+
BOOST_REQUIRE( accessor::is_malleable32(3, 1)); // 4:1
329+
BOOST_REQUIRE(!accessor::is_malleable32(3, 2));
330+
BOOST_REQUIRE(!accessor::is_malleable32(3, 3));
331+
332+
BOOST_REQUIRE(!accessor::is_malleable32(4, 1));
333+
BOOST_REQUIRE(!accessor::is_malleable32(4, 2));
334+
BOOST_REQUIRE(!accessor::is_malleable32(4, 3));
335+
BOOST_REQUIRE(!accessor::is_malleable32(4, 4));
336+
337+
BOOST_REQUIRE( accessor::is_malleable32(5, 1)); // 6:1
338+
BOOST_REQUIRE(!accessor::is_malleable32(5, 2));
339+
BOOST_REQUIRE(!accessor::is_malleable32(5, 3));
340+
BOOST_REQUIRE(!accessor::is_malleable32(5, 4));
341+
BOOST_REQUIRE(!accessor::is_malleable32(5, 5));
342+
343+
BOOST_REQUIRE(!accessor::is_malleable32(6, 1));
344+
BOOST_REQUIRE( accessor::is_malleable32(6, 2)); // 8:2
345+
BOOST_REQUIRE(!accessor::is_malleable32(6, 3));
346+
BOOST_REQUIRE(!accessor::is_malleable32(6, 4));
347+
BOOST_REQUIRE(!accessor::is_malleable32(6, 5));
348+
BOOST_REQUIRE(!accessor::is_malleable32(6, 6));
349+
350+
BOOST_REQUIRE( accessor::is_malleable32(7, 1)); // 8:1
351+
BOOST_REQUIRE(!accessor::is_malleable32(7, 2));
352+
BOOST_REQUIRE(!accessor::is_malleable32(7, 3));
353+
BOOST_REQUIRE(!accessor::is_malleable32(7, 4));
354+
BOOST_REQUIRE(!accessor::is_malleable32(7, 5));
355+
BOOST_REQUIRE(!accessor::is_malleable32(7, 6));
356+
BOOST_REQUIRE(!accessor::is_malleable32(7, 7));
357+
358+
BOOST_REQUIRE(!accessor::is_malleable32(8, 1));
359+
BOOST_REQUIRE(!accessor::is_malleable32(8, 2));
360+
BOOST_REQUIRE(!accessor::is_malleable32(8, 3));
361+
BOOST_REQUIRE(!accessor::is_malleable32(8, 4));
362+
BOOST_REQUIRE(!accessor::is_malleable32(8, 5));
363+
BOOST_REQUIRE(!accessor::is_malleable32(8, 6));
364+
BOOST_REQUIRE(!accessor::is_malleable32(8, 7));
365+
BOOST_REQUIRE(!accessor::is_malleable32(8, 8));
366+
367+
BOOST_REQUIRE( accessor::is_malleable32(9, 1)); // 10:1
368+
BOOST_REQUIRE(!accessor::is_malleable32(9, 2));
369+
BOOST_REQUIRE(!accessor::is_malleable32(9, 3));
370+
BOOST_REQUIRE(!accessor::is_malleable32(9, 4));
371+
BOOST_REQUIRE(!accessor::is_malleable32(9, 5));
372+
BOOST_REQUIRE(!accessor::is_malleable32(9, 6));
373+
BOOST_REQUIRE(!accessor::is_malleable32(9, 7));
374+
BOOST_REQUIRE(!accessor::is_malleable32(9, 8));
375+
BOOST_REQUIRE(!accessor::is_malleable32(9, 9));
376+
377+
BOOST_REQUIRE(!accessor::is_malleable32(10, 1));
378+
BOOST_REQUIRE( accessor::is_malleable32(10, 2)); // 12:2
379+
BOOST_REQUIRE(!accessor::is_malleable32(10, 3));
380+
BOOST_REQUIRE( accessor::is_malleable32(11, 1)); // 12:1
381+
BOOST_REQUIRE(!accessor::is_malleable32(11, 2));
382+
BOOST_REQUIRE(!accessor::is_malleable32(12, 1));
383+
BOOST_REQUIRE(!accessor::is_malleable32(12, 2));
384+
BOOST_REQUIRE(!accessor::is_malleable32(12, 3));
385+
BOOST_REQUIRE( accessor::is_malleable32(12, 4)); // 16:4
386+
BOOST_REQUIRE( accessor::is_malleable32(13, 1)); // 14:1
387+
BOOST_REQUIRE(!accessor::is_malleable32(13, 2));
388+
BOOST_REQUIRE(!accessor::is_malleable32(14, 1));
389+
BOOST_REQUIRE( accessor::is_malleable32(14, 2)); // 16:2
390+
BOOST_REQUIRE(!accessor::is_malleable32(14, 3));
391+
BOOST_REQUIRE( accessor::is_malleable32(15, 1)); // 16:1
392+
BOOST_REQUIRE(!accessor::is_malleable32(16, 1));
393+
BOOST_REQUIRE( accessor::is_malleable32(17, 1)); // 18:1
394+
BOOST_REQUIRE(!accessor::is_malleable32(18, 1));
395+
BOOST_REQUIRE( accessor::is_malleable32(18, 2)); // 20:2
396+
BOOST_REQUIRE( accessor::is_malleable32(19, 1)); // 20:1
397+
BOOST_REQUIRE(!accessor::is_malleable32(20, 1));
398+
BOOST_REQUIRE(!accessor::is_malleable32(20, 2));
399+
BOOST_REQUIRE(!accessor::is_malleable32(20, 3));
400+
BOOST_REQUIRE( accessor::is_malleable32(20, 4)); // 24:4
401+
BOOST_REQUIRE( accessor::is_malleable32(21, 1)); // 22:1
402+
BOOST_REQUIRE(!accessor::is_malleable32(22, 1));
403+
BOOST_REQUIRE( accessor::is_malleable32(22, 2)); // 24:2
404+
BOOST_REQUIRE( accessor::is_malleable32(23, 1)); // 24:1
405+
BOOST_REQUIRE(!accessor::is_malleable32(24, 1));
406+
BOOST_REQUIRE( accessor::is_malleable32(25, 1)); // 26:1
407+
BOOST_REQUIRE(!accessor::is_malleable32(26, 1));
408+
BOOST_REQUIRE( accessor::is_malleable32(26, 2)); // 28:2
409+
BOOST_REQUIRE( accessor::is_malleable32(27, 1)); // 28:1
410+
BOOST_REQUIRE(!accessor::is_malleable32(28, 1));
411+
BOOST_REQUIRE(!accessor::is_malleable32(28, 2));
412+
BOOST_REQUIRE(!accessor::is_malleable32(28, 3));
413+
BOOST_REQUIRE( accessor::is_malleable32(28, 4)); // 32:4
414+
BOOST_REQUIRE( accessor::is_malleable32(29, 1)); // 30:1
415+
BOOST_REQUIRE(!accessor::is_malleable32(30, 1));
416+
BOOST_REQUIRE( accessor::is_malleable32(30, 2)); // 32:2
417+
BOOST_REQUIRE( accessor::is_malleable32(31, 1)); // 32:1
431418
}
432419

433420
BOOST_AUTO_TEST_SUITE_END()

test/chain/header.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,8 @@ class accessor
4343
public:
4444
// Use base class constructors.
4545
using header::header;
46-
47-
bool is_invalid_proof_of_work(uint32_t proof_of_work_limit,
48-
bool scrypt=false) const
49-
{
50-
return header::is_invalid_proof_of_work(proof_of_work_limit, scrypt);
51-
}
52-
53-
bool is_futuristic_timestamp(uint32_t timestamp_limit_seconds) const
54-
{
55-
return header::is_futuristic_timestamp(timestamp_limit_seconds);
56-
}
46+
using header::is_invalid_proof_of_work;
47+
using header::is_futuristic_timestamp;
5748
};
5849

5950
static_assert(header::serialized_size() == 80_size);

0 commit comments

Comments
 (0)