Skip to content

Commit 21138fe

Browse files
committed
Merge bitcoin/bitcoin#26992: refactor: Remove unused CDataStream SerializeMany constructor
fa47b28 refactor: Remove unused CDataStream SerializeMany constructor (MarcoFalke) Pull request description: Seems odd to have an unused method. Moreover, the function is fragile and dangerous, because one could have a `std::vector vec_a` and type `CDataStream{vec_a, 0, 0}.size()` and `CDataStream{0, 0, vec_a}.size()`, assuming they are the same thing, when in fact they are not. (The first takes over the memory as is, the second serializes the vector). So my suggestion would be to remove the unused method and introduce a new method when this functionality is needed. For example: `static DataStream FromMany(Args&&... args)`. ACKs for top commit: stickies-v: ACK fa47b28 Tree-SHA512: 9593a034b997e33a0794f779f76f02425b1097b218cf8cb1facb7f874fa69da328ce567a79138015baeebe004ae7d103dda4f64f83e8ad375b6dae6b66d3d950
2 parents 9dc50a5 + fa47b28 commit 21138fe

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

src/streams.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,6 @@ class CDataStream : public DataStream
358358
nType{nTypeIn},
359359
nVersion{nVersionIn} {}
360360

361-
template <typename... Args>
362-
CDataStream(int nTypeIn, int nVersionIn, Args&&... args)
363-
: nType{nTypeIn},
364-
nVersion{nVersionIn}
365-
{
366-
::SerializeMany(*this, std::forward<Args>(args)...);
367-
}
368-
369361
int GetType() const { return nType; }
370362
void SetVersion(int n) { nVersion = n; }
371363
int GetVersion() const { return nVersion; }

src/test/serialize_tests.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,8 @@ BOOST_AUTO_TEST_CASE(class_methods)
237237
BOOST_CHECK(methodtest2 == methodtest3);
238238
BOOST_CHECK(methodtest3 == methodtest4);
239239

240-
CDataStream ss2(SER_DISK, PROTOCOL_VERSION, intval, boolval, stringval, charstrval, txval);
240+
CDataStream ss2{SER_DISK, PROTOCOL_VERSION};
241+
ss2 << intval << boolval << stringval << charstrval << txval;
241242
ss2 >> methodtest3;
242243
BOOST_CHECK(methodtest3 == methodtest4);
243244
}

0 commit comments

Comments
 (0)