Skip to content

Commit 5d559a7

Browse files
authored
Merge pull request #1753 from evoskuil/master
Refactor stream/reader/chain object construction.
2 parents 573bc48 + 7425a45 commit 5d559a7

37 files changed

+383
-225
lines changed

include/bitcoin/system/chain/block.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@ class BC_API block
5454
block(const chain::header::cptr& header,
5555
const transactions_cptr& txs) NOEXCEPT;
5656

57-
block(stream::in::fast&& stream, bool witness) NOEXCEPT;
57+
block(const data_slice& data, bool witness) NOEXCEPT;
5858
block(stream::in::fast& stream, bool witness) NOEXCEPT;
59-
block(std::istream&& stream, bool witness) NOEXCEPT;
6059
block(std::istream& stream, bool witness) NOEXCEPT;
61-
block(reader&& source, bool witness) NOEXCEPT;
6260
block(reader& source, bool witness) NOEXCEPT;
6361

6462
/// Operators.
@@ -150,6 +148,8 @@ class BC_API block
150148
code populate_with_metadata(const context& ctx) const NOEXCEPT;
151149

152150
protected:
151+
block(stream::in::fast&& stream, bool witness) NOEXCEPT;
152+
block(reader&& source, bool witness) NOEXCEPT;
153153
block(const chain::header::cptr& header,
154154
const chain::transactions_cptr& txs, bool valid) NOEXCEPT;
155155

include/bitcoin/system/chain/header.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ class BC_API header
6363
const hash_digest& merkle_root, uint32_t timestamp, uint32_t bits,
6464
uint32_t nonce) NOEXCEPT;
6565

66-
header(stream::in::fast&& stream) NOEXCEPT;
66+
header(const data_slice& data) NOEXCEPT;
6767
header(stream::in::fast& stream) NOEXCEPT;
68-
header(std::istream&& stream) NOEXCEPT;
6968
header(std::istream& stream) NOEXCEPT;
70-
header(reader&& source) NOEXCEPT;
7169
header(reader& source) NOEXCEPT;
7270

7371
/// Operators.
@@ -122,6 +120,8 @@ class BC_API header
122120
code accept(const context& ctx) const NOEXCEPT;
123121

124122
protected:
123+
header(stream::in::fast&& stream) NOEXCEPT;
124+
header(reader&& source) NOEXCEPT;
125125
header(uint32_t version, hash_digest&& previous_block_hash,
126126
hash_digest&& merkle_root, uint32_t timestamp, uint32_t bits,
127127
uint32_t nonce, bool valid) NOEXCEPT;

include/bitcoin/system/chain/input.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <bitcoin/system/chain/prevout.hpp>
2727
#include <bitcoin/system/chain/script.hpp>
2828
#include <bitcoin/system/chain/witness.hpp>
29+
#include <bitcoin/system/data/data.hpp>
2930
#include <bitcoin/system/define.hpp>
3031
#include <bitcoin/system/hash/hash.hpp>
3132
#include <bitcoin/system/stream/stream.hpp>
@@ -66,11 +67,9 @@ class BC_API input
6667
input(const chain::point::cptr& point, const chain::script::cptr& script,
6768
const chain::witness::cptr& witness, uint32_t sequence) NOEXCEPT;
6869

69-
input(stream::in::fast&& stream) NOEXCEPT;
70+
input(const data_slice& data) NOEXCEPT;
7071
input(stream::in::fast& stream) NOEXCEPT;
71-
input(std::istream&& stream) NOEXCEPT;
7272
input(std::istream& stream) NOEXCEPT;
73-
input(reader&& source) NOEXCEPT;
7473
input(reader& source) NOEXCEPT;
7574

7675
/// Operators.
@@ -118,6 +117,8 @@ class BC_API input
118117
uint32_t median_time_past) const NOEXCEPT;
119118

120119
protected:
120+
input(stream::in::fast&& stream) NOEXCEPT;
121+
input(reader&& source) NOEXCEPT;
121122
input(const chain::point::cptr& point, const chain::script::cptr& script,
122123
const chain::witness::cptr& witness, uint32_t sequence,
123124
bool valid) NOEXCEPT;

include/bitcoin/system/chain/operation.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,9 @@ class BC_API operation
105105
operation(const chunk_cptr& push_data, bool minimal) NOEXCEPT;
106106

107107
/// These deserialize operations (with codes), not from push-data.
108-
operation(stream::in::fast&& stream) NOEXCEPT;
108+
operation(const data_slice& data) NOEXCEPT;
109109
operation(stream::in::fast& stream) NOEXCEPT;
110-
operation(std::istream&& stream) NOEXCEPT;
111110
operation(std::istream& stream) NOEXCEPT;
112-
operation(reader&& source) NOEXCEPT;
113111
operation(reader& source) NOEXCEPT;
114112

115113
// TODO: move to config serialization wrapper.
@@ -148,6 +146,8 @@ class BC_API operation
148146
size_t serialized_size() const NOEXCEPT;
149147

150148
protected:
149+
operation(stream::in::fast&& stream) NOEXCEPT;
150+
operation(reader&& source) NOEXCEPT;
151151
operation(opcode code, const chunk_cptr& push_data_ptr,
152152
bool underflow) NOEXCEPT;
153153

include/bitcoin/system/chain/output.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
#include <memory>
2323
#include <bitcoin/system/chain/script.hpp>
24+
#include <bitcoin/system/data/data.hpp>
2425
#include <bitcoin/system/define.hpp>
2526
#include <bitcoin/system/hash/hash.hpp>
2627
#include <bitcoin/system/stream/stream.hpp>
@@ -49,11 +50,9 @@ class BC_API output
4950
output(uint64_t value, const chain::script& script) NOEXCEPT;
5051
output(uint64_t value, const chain::script::cptr& script) NOEXCEPT;
5152

52-
output(stream::in::fast&& stream) NOEXCEPT;
53+
output(const data_slice& data) NOEXCEPT;
5354
output(stream::in::fast& stream) NOEXCEPT;
54-
output(std::istream&& stream) NOEXCEPT;
5555
output(std::istream& stream) NOEXCEPT;
56-
output(reader&& source) NOEXCEPT;
5756
output(reader& source) NOEXCEPT;
5857

5958
/// Operators.
@@ -95,6 +94,8 @@ class BC_API output
9594
const hash_digest& get_hash() const NOEXCEPT;
9695

9796
protected:
97+
output(stream::in::fast&& stream) NOEXCEPT;
98+
output(reader&& source) NOEXCEPT;
9899
output(uint64_t value, const chain::script::cptr& script,
99100
bool valid) NOEXCEPT;
100101

include/bitcoin/system/chain/point.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ class BC_API point
5555
point(hash_digest&& hash, uint32_t index) NOEXCEPT;
5656
point(const hash_digest& hash, uint32_t index) NOEXCEPT;
5757

58-
point(stream::in::fast&& stream) NOEXCEPT;
58+
point(const data_slice& data) NOEXCEPT;
5959
point(stream::in::fast& stream) NOEXCEPT;
60-
point(std::istream&& stream) NOEXCEPT;
6160
point(std::istream& stream) NOEXCEPT;
62-
point(reader&& source) NOEXCEPT;
6361
point(reader& source) NOEXCEPT;
6462

6563
/// Operators.
@@ -87,6 +85,8 @@ class BC_API point
8785
bool is_null() const NOEXCEPT;
8886

8987
protected:
88+
point(stream::in::fast&& stream) NOEXCEPT;
89+
point(reader&& source) NOEXCEPT;
9090
point(hash_digest&& hash, uint32_t index, bool valid) NOEXCEPT;
9191
point(const hash_digest& hash, uint32_t index, bool valid) NOEXCEPT;
9292

include/bitcoin/system/chain/script.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,9 @@ class BC_API script
102102
script(operations&& ops) NOEXCEPT;
103103
script(const operations& ops) NOEXCEPT;
104104

105-
script(stream::in::fast&& stream, bool prefix) NOEXCEPT;
105+
script(const data_slice& data, bool prefix) NOEXCEPT;
106106
script(stream::in::fast& stream, bool prefix) NOEXCEPT;
107-
script(std::istream&& stream, bool prefix) NOEXCEPT;
108107
script(std::istream& stream, bool prefix) NOEXCEPT;
109-
script(reader&& source, bool prefix) NOEXCEPT;
110108
script(reader& source, bool prefix) NOEXCEPT;
111109

112110
// TODO: move to config serialization wrapper.
@@ -167,6 +165,8 @@ class BC_API script
167165
size_t signature_operations(bool accurate) const NOEXCEPT;
168166

169167
protected:
168+
script(stream::in::fast&& stream, bool prefix) NOEXCEPT;
169+
script(reader&& source, bool prefix) NOEXCEPT;
170170
script(const operations& ops, bool valid, bool easier, bool failer,
171171
bool roller, size_t size) NOEXCEPT;
172172

include/bitcoin/system/chain/transaction.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <bitcoin/system/chain/input.hpp>
2727
#include <bitcoin/system/chain/output.hpp>
2828
#include <bitcoin/system/chain/point.hpp>
29+
#include <bitcoin/system/data/data.hpp>
2930
#include <bitcoin/system/define.hpp>
3031
#include <bitcoin/system/error/error.hpp>
3132
#include <bitcoin/system/hash/hash.hpp>
@@ -70,11 +71,9 @@ class BC_API transaction
7071
transaction(uint32_t version, const inputs_cptr& inputs,
7172
const outputs_cptr& outputs, uint32_t locktime) NOEXCEPT;
7273

73-
transaction(stream::in::fast&& stream, bool witness) NOEXCEPT;
74+
transaction(const data_slice& data, bool witness) NOEXCEPT;
7475
transaction(stream::in::fast& stream, bool witness) NOEXCEPT;
75-
transaction(std::istream&& stream, bool witness) NOEXCEPT;
7676
transaction(std::istream& stream, bool witness) NOEXCEPT;
77-
transaction(reader&& source, bool witness) NOEXCEPT;
7877
transaction(reader& source, bool witness) NOEXCEPT;
7978

8079
/// Operators.
@@ -173,6 +172,8 @@ class BC_API transaction
173172
code confirm(const context& ctx) const NOEXCEPT;
174173

175174
protected:
175+
transaction(stream::in::fast&& stream, bool witness) NOEXCEPT;
176+
transaction(reader&& source, bool witness) NOEXCEPT;
176177
transaction(uint32_t version, const inputs_cptr& inputs,
177178
const outputs_cptr& outputs, uint32_t locktime, bool segregated,
178179
bool valid) NOEXCEPT;

include/bitcoin/system/chain/witness.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ class BC_API witness
5555
witness(chunk_cptrs&& stack) NOEXCEPT;
5656
witness(const chunk_cptrs& stack) NOEXCEPT;
5757

58-
witness(stream::in::fast&& stream, bool prefix) NOEXCEPT;
58+
witness(const data_slice& data, bool prefix) NOEXCEPT;
5959
witness(stream::in::fast& stream, bool prefix) NOEXCEPT;
60-
witness(std::istream&& stream, bool prefix) NOEXCEPT;
6160
witness(std::istream& stream, bool prefix) NOEXCEPT;
62-
witness(reader&& source, bool prefix) NOEXCEPT;
6361
witness(reader& source, bool prefix) NOEXCEPT;
6462

6563
// TODO: move to config serialization wrapper.
@@ -120,6 +118,8 @@ class BC_API witness
120118
chunk_cptrs_ptr& out_stack, const script& program_script) const NOEXCEPT;
121119

122120
protected:
121+
witness(stream::in::fast&& stream, bool prefix) NOEXCEPT;
122+
witness(reader&& source, bool prefix) NOEXCEPT;
123123
witness(chunk_cptrs&& stack, bool valid) NOEXCEPT;
124124
witness(const chunk_cptrs& stack, bool valid) NOEXCEPT;
125125
witness(const chunk_cptrs& stack, bool valid, size_t size) NOEXCEPT;

include/bitcoin/system/impl/stream/iostream/iostream.ipp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define LIBBITCOIN_SYSTEM_STREAM_IOSTREAM_IOSTREAM_IPP
2121

2222
#include <algorithm>
23+
#include <bitcoin/system/data/data.hpp>
2324
#include <bitcoin/system/define.hpp>
2425
#include <bitcoin/system/math/math.hpp>
2526

@@ -30,8 +31,7 @@ namespace system {
3031
BC_PUSH_WARNING(NO_POINTER_ARITHMETIC)
3132

3233
template <typename Character>
33-
template <typename Buffer>
34-
iostream<Character>::iostream(Buffer& buffer) NOEXCEPT
34+
iostream<Character>::iostream(const data_slab& buffer) NOEXCEPT
3535
: position_(buffer.data()),
3636
begin_(position_),
3737
end_(begin_ + buffer.size()),

0 commit comments

Comments
 (0)