Skip to content

Commit dabd940

Browse files
committed
Fix (sizex2) and assert base16 serialize helpers
1 parent 5534ee7 commit dabd940

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/protocols/protocol_explore.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,18 @@ data_chunk to_bin(const Object& object, size_t size, Args&&... args) NOEXCEPT
136136
stream::out::fast sink{ out };
137137
write::bytes::fast writer{ sink };
138138
object.to_data(writer, std::forward<Args>(args)...);
139+
BC_ASSERT(writer);
139140
return out;
140141
}
141142

142143
template <typename Object, typename ...Args>
143144
std::string to_hex(const Object& object, size_t size, Args&&... args) NOEXCEPT
144145
{
145-
std::string out(size, '\0');
146+
std::string out(two * size, '\0');
146147
stream::out::fast sink{ out };
147148
write::base16::fast writer{ sink };
148149
object.to_data(writer, std::forward<Args>(args)...);
150+
BC_ASSERT(writer);
149151
return out;
150152
}
151153

@@ -159,19 +161,21 @@ data_chunk to_bin_array(const Collection& collection, size_t size,
159161
for (const auto& element: collection)
160162
element.to_data(writer, std::forward<Args>(args)...);
161163

164+
BC_ASSERT(writer);
162165
return out;
163166
}
164167

165168
template <typename Collection, typename ...Args>
166169
std::string to_hex_array(const Collection& collection, size_t size,
167170
Args&&... args) NOEXCEPT
168171
{
169-
std::string out(size, '\0');
172+
std::string out(two * size, '\0');
170173
stream::out::fast sink{ out };
171174
write::base16::fast writer{ sink };
172175
for (const auto& element: collection)
173176
element.to_data(writer, std::forward<Args>(args)...);
174177

178+
BC_ASSERT(writer);
175179
return out;
176180
}
177181

@@ -185,19 +189,21 @@ data_chunk to_bin_ptr_array(const Collection& collection, size_t size,
185189
for (const auto& ptr: collection)
186190
ptr->to_data(writer, std::forward<Args>(args)...);
187191

192+
BC_ASSERT(writer);
188193
return out;
189194
}
190195

191196
template <typename Collection, typename ...Args>
192197
std::string to_hex_ptr_array(const Collection& collection, size_t size,
193198
Args&&... args) NOEXCEPT
194199
{
195-
std::string out(size, '\0');
200+
std::string out(two * size, '\0');
196201
stream::out::fast sink{ out };
197202
write::base16::fast writer{ sink };
198203
for (const auto& ptr: collection)
199204
ptr->to_data(writer, std::forward<Args>(args)...);
200205

206+
BC_ASSERT(writer);
201207
return out;
202208
}
203209

0 commit comments

Comments
 (0)