mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#20464: Treat CDataStream bytes as uint8_t
This commit is contained in:
parent
65ff12c303
commit
dba0dc9501
@ -79,7 +79,7 @@ static void PrevectorDeserialize(benchmark::Bench& bench)
|
||||
for (auto x = 0; x < 1000; ++x) {
|
||||
s0 >> t1;
|
||||
}
|
||||
s0.Init(SER_NETWORK, 0);
|
||||
s0.Rewind();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,10 @@
|
||||
#include <clientversion.h>
|
||||
#include <fs.h>
|
||||
#include <serialize.h>
|
||||
#include <span.h>
|
||||
#include <streams.h>
|
||||
#include <util/system.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
|
||||
#include <typeindex>
|
||||
|
||||
@ -82,12 +83,12 @@ public:
|
||||
template <typename V>
|
||||
void Write(const CDataStream& _ssKey, const V& value)
|
||||
{
|
||||
leveldb::Slice slKey(_ssKey.data(), _ssKey.size());
|
||||
leveldb::Slice slKey((const char*)_ssKey.data(), _ssKey.size());
|
||||
|
||||
ssValue.reserve(DBWRAPPER_PREALLOC_VALUE_SIZE);
|
||||
ssValue << value;
|
||||
ssValue.Xor(dbwrapper_private::GetObfuscateKey(parent));
|
||||
leveldb::Slice slValue(ssValue.data(), ssValue.size());
|
||||
leveldb::Slice slValue((const char*)ssValue.data(), ssValue.size());
|
||||
|
||||
batch.Put(slKey, slValue);
|
||||
// - varint: key length (1 byte up to 127B, 2 bytes up to 16383B, ...)
|
||||
@ -109,7 +110,7 @@ public:
|
||||
}
|
||||
|
||||
void Erase(const CDataStream& _ssKey) {
|
||||
leveldb::Slice slKey(_ssKey.data(), _ssKey.size());
|
||||
leveldb::Slice slKey((const char*)_ssKey.data(), _ssKey.size());
|
||||
|
||||
batch.Delete(slKey);
|
||||
// - byte: header
|
||||
@ -150,7 +151,7 @@ public:
|
||||
}
|
||||
|
||||
void Seek(const CDataStream& ssKey) {
|
||||
leveldb::Slice slKey(ssKey.data(), ssKey.size());
|
||||
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
|
||||
piter->Seek(slKey);
|
||||
}
|
||||
|
||||
@ -168,7 +169,7 @@ public:
|
||||
|
||||
CDataStream GetKey() {
|
||||
leveldb::Slice slKey = piter->key();
|
||||
return CDataStream(slKey.data(), slKey.data() + slKey.size(), SER_DISK, CLIENT_VERSION);
|
||||
return CDataStream(MakeUCharSpan(slKey), SER_DISK, CLIENT_VERSION);
|
||||
}
|
||||
|
||||
unsigned int GetKeySize() {
|
||||
@ -178,7 +179,7 @@ public:
|
||||
template<typename V> bool GetValue(V& value) {
|
||||
leveldb::Slice slValue = piter->value();
|
||||
try {
|
||||
CDataStream ssValue(slValue.data(), slValue.data() + slValue.size(), SER_DISK, CLIENT_VERSION);
|
||||
CDataStream ssValue(MakeUCharSpan(slValue), SER_DISK, CLIENT_VERSION);
|
||||
ssValue.Xor(dbwrapper_private::GetObfuscateKey(parent));
|
||||
ssValue >> value;
|
||||
} catch (const std::exception&) {
|
||||
@ -258,7 +259,7 @@ public:
|
||||
|
||||
bool ReadDataStream(const CDataStream& ssKey, CDataStream& ssValue) const
|
||||
{
|
||||
leveldb::Slice slKey(ssKey.data(), ssKey.size());
|
||||
leveldb::Slice slKey((const char*)ssKey.data(), ssKey.size());
|
||||
|
||||
std::string strValue;
|
||||
leveldb::Status status = pdb->Get(readoptions, slKey, &strValue);
|
||||
@ -268,7 +269,7 @@ public:
|
||||
LogPrintf("LevelDB read failure: %s\n", status.ToString());
|
||||
dbwrapper_private::HandleError(status);
|
||||
}
|
||||
CDataStream ssValueTmp(strValue.data(), strValue.data() + strValue.size(), SER_DISK, CLIENT_VERSION);
|
||||
CDataStream ssValueTmp(MakeUCharSpan(strValue), SER_DISK, CLIENT_VERSION);
|
||||
ssValueTmp.Xor(obfuscate_key);
|
||||
ssValue = std::move(ssValueTmp);
|
||||
return true;
|
||||
@ -318,7 +319,7 @@ public:
|
||||
|
||||
bool Exists(const CDataStream& key) const
|
||||
{
|
||||
leveldb::Slice slKey(key.data(), key.size());
|
||||
leveldb::Slice slKey((const char*)key.data(), key.size());
|
||||
|
||||
std::string strValue;
|
||||
leveldb::Status status = pdb->Get(readoptions, slKey, &strValue);
|
||||
@ -362,8 +363,8 @@ public:
|
||||
ssKey2.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
||||
ssKey1 << key_begin;
|
||||
ssKey2 << key_end;
|
||||
leveldb::Slice slKey1(ssKey1.data(), ssKey1.size());
|
||||
leveldb::Slice slKey2(ssKey2.data(), ssKey2.size());
|
||||
leveldb::Slice slKey1((const char*)ssKey1.data(), ssKey1.size());
|
||||
leveldb::Slice slKey2((const char*)ssKey2.data(), ssKey2.size());
|
||||
uint64_t size = 0;
|
||||
leveldb::Range range(slKey1, slKey2);
|
||||
pdb->GetApproximateSizes(&range, 1, &size);
|
||||
@ -381,8 +382,8 @@ public:
|
||||
ssKey2.reserve(DBWRAPPER_PREALLOC_KEY_SIZE);
|
||||
ssKey1 << key_begin;
|
||||
ssKey2 << key_end;
|
||||
leveldb::Slice slKey1(ssKey1.data(), ssKey1.size());
|
||||
leveldb::Slice slKey2(ssKey2.data(), ssKey2.size());
|
||||
leveldb::Slice slKey1((const char*)ssKey1.data(), ssKey1.size());
|
||||
leveldb::Slice slKey2((const char*)ssKey2.data(), ssKey2.size());
|
||||
pdb->CompactRange(&slKey1, &slKey2);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ void CDKGPendingMessages::PushPendingMessage(NodeId from, CDataStream& vRecv)
|
||||
auto pm = std::make_shared<CDataStream>(std::move(vRecv));
|
||||
|
||||
CHashWriter hw(SER_GETHASH, 0);
|
||||
hw.write(pm->data(), pm->size());
|
||||
hw.write(reinterpret_cast<const char*>(pm->data()), pm->size());
|
||||
uint256 hash = hw.GetHash();
|
||||
|
||||
if (from != -1) {
|
||||
|
@ -461,7 +461,7 @@ bool DecodeBase64PSBT(PartiallySignedTransaction& psbt, const std::string& base6
|
||||
|
||||
bool DecodeRawPSBT(PartiallySignedTransaction& psbt, const std::string& tx_data, std::string& error)
|
||||
{
|
||||
CDataStream ss_data(tx_data.data(), tx_data.data() + tx_data.size(), SER_NETWORK, PROTOCOL_VERSION);
|
||||
CDataStream ss_data(MakeUCharSpan(tx_data), SER_NETWORK, PROTOCOL_VERSION);
|
||||
try {
|
||||
ss_data >> psbt;
|
||||
if (!ss_data.empty()) {
|
||||
|
@ -181,7 +181,7 @@ void RecentRequestsTableModel::addNewRequest(const SendCoinsRecipient &recipient
|
||||
// called from ctor when loading from wallet
|
||||
void RecentRequestsTableModel::addNewRequest(const std::string &recipient)
|
||||
{
|
||||
std::vector<char> data(recipient.begin(), recipient.end());
|
||||
std::vector<uint8_t> data(recipient.begin(), recipient.end());
|
||||
CDataStream ss(data, SER_DISK, CLIENT_VERSION);
|
||||
|
||||
RecentRequestEntry entry;
|
||||
|
@ -288,7 +288,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction &tran
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssTx << *newTx;
|
||||
transaction_array.append(ssTx.data(), ssTx.size());
|
||||
transaction_array.append((const char*)ssTx.data(), ssTx.size());
|
||||
}
|
||||
|
||||
// Add addresses / update labels that we've sent to the address book,
|
||||
|
@ -1306,7 +1306,7 @@ UniValue combinepsbt(const JSONRPCRequest& request)
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssTx << merged_psbt;
|
||||
return EncodeBase64(ssTx.str());
|
||||
return EncodeBase64(ssTx);
|
||||
}
|
||||
|
||||
UniValue finalizepsbt(const JSONRPCRequest& request)
|
||||
@ -1434,7 +1434,7 @@ UniValue createpsbt(const JSONRPCRequest& request)
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssTx << psbtx;
|
||||
|
||||
return EncodeBase64(ssTx.str());
|
||||
return EncodeBase64(ssTx);
|
||||
}
|
||||
|
||||
UniValue converttopsbt(const JSONRPCRequest& request)
|
||||
@ -1489,7 +1489,7 @@ UniValue converttopsbt(const JSONRPCRequest& request)
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssTx << psbtx;
|
||||
|
||||
return EncodeBase64(ssTx.str());
|
||||
return EncodeBase64(ssTx);
|
||||
}
|
||||
|
||||
UniValue utxoupdatepsbt(const JSONRPCRequest& request)
|
||||
@ -1573,7 +1573,7 @@ UniValue utxoupdatepsbt(const JSONRPCRequest& request)
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssTx << psbtx;
|
||||
return EncodeBase64(ssTx.str());
|
||||
return EncodeBase64(ssTx);
|
||||
}
|
||||
|
||||
UniValue joinpsbts(const JSONRPCRequest& request)
|
||||
@ -1644,7 +1644,7 @@ UniValue joinpsbts(const JSONRPCRequest& request)
|
||||
|
||||
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION);
|
||||
ssTx << merged_psbt;
|
||||
return EncodeBase64(ssTx.str());
|
||||
return EncodeBase64(ssTx);
|
||||
}
|
||||
|
||||
UniValue analyzepsbt(const JSONRPCRequest& request)
|
||||
|
@ -6,17 +6,19 @@
|
||||
#ifndef BITCOIN_STREAMS_H
|
||||
#define BITCOIN_STREAMS_H
|
||||
|
||||
#include <support/allocators/zeroafterfree.h>
|
||||
#include <serialize.h>
|
||||
#include <span.h>
|
||||
#include <support/allocators/zeroafterfree.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <assert.h>
|
||||
#include <ios>
|
||||
#include <limits>
|
||||
#include <optional>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@ -206,14 +208,14 @@ public:
|
||||
class CDataStream
|
||||
{
|
||||
protected:
|
||||
typedef CSerializeData vector_type;
|
||||
using vector_type = SerializeData;
|
||||
vector_type vch;
|
||||
unsigned int nReadPos;
|
||||
unsigned int nReadPos{0};
|
||||
|
||||
int nType;
|
||||
int nVersion;
|
||||
public:
|
||||
|
||||
public:
|
||||
typedef vector_type::allocator_type allocator_type;
|
||||
typedef vector_type::size_type size_type;
|
||||
typedef vector_type::difference_type difference_type;
|
||||
@ -225,62 +227,22 @@ public:
|
||||
typedef vector_type::reverse_iterator reverse_iterator;
|
||||
|
||||
explicit CDataStream(int nTypeIn, int nVersionIn)
|
||||
{
|
||||
Init(nTypeIn, nVersionIn);
|
||||
}
|
||||
: nType{nTypeIn},
|
||||
nVersion{nVersionIn} {}
|
||||
|
||||
CDataStream(const_iterator pbegin, const_iterator pend, int nTypeIn, int nVersionIn) : vch(pbegin, pend)
|
||||
{
|
||||
Init(nTypeIn, nVersionIn);
|
||||
}
|
||||
|
||||
CDataStream(const char* pbegin, const char* pend, int nTypeIn, int nVersionIn) : vch(pbegin, pend)
|
||||
{
|
||||
Init(nTypeIn, nVersionIn);
|
||||
}
|
||||
|
||||
CDataStream(const vector_type& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end())
|
||||
{
|
||||
Init(nTypeIn, nVersionIn);
|
||||
}
|
||||
|
||||
CDataStream(const std::vector<char>& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end())
|
||||
{
|
||||
Init(nTypeIn, nVersionIn);
|
||||
}
|
||||
|
||||
CDataStream(const std::vector<unsigned char>& vchIn, int nTypeIn, int nVersionIn) : vch(vchIn.begin(), vchIn.end())
|
||||
{
|
||||
Init(nTypeIn, nVersionIn);
|
||||
}
|
||||
explicit CDataStream(Span<const uint8_t> sp, int nTypeIn, int nVersionIn)
|
||||
: vch(sp.data(), sp.data() + sp.size()),
|
||||
nType{nTypeIn},
|
||||
nVersion{nVersionIn} {}
|
||||
|
||||
template <typename... Args>
|
||||
CDataStream(int nTypeIn, int nVersionIn, Args&&... args)
|
||||
: nType{nTypeIn},
|
||||
nVersion{nVersionIn}
|
||||
{
|
||||
Init(nTypeIn, nVersionIn);
|
||||
::SerializeMany(*this, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
void Init(int nTypeIn, int nVersionIn)
|
||||
{
|
||||
nReadPos = 0;
|
||||
nType = nTypeIn;
|
||||
nVersion = nVersionIn;
|
||||
}
|
||||
|
||||
CDataStream& operator+=(const CDataStream& b)
|
||||
{
|
||||
vch.insert(vch.end(), b.begin(), b.end());
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend CDataStream operator+(const CDataStream& a, const CDataStream& b)
|
||||
{
|
||||
CDataStream ret = a;
|
||||
ret += b;
|
||||
return (ret);
|
||||
}
|
||||
|
||||
std::string str() const
|
||||
{
|
||||
return (std::string(begin(), end()));
|
||||
@ -301,12 +263,12 @@ public:
|
||||
const_reference operator[](size_type pos) const { return vch[pos + nReadPos]; }
|
||||
reference operator[](size_type pos) { return vch[pos + nReadPos]; }
|
||||
void clear() { vch.clear(); nReadPos = 0; }
|
||||
iterator insert(iterator it, const char x=char()) { return vch.insert(it, x); }
|
||||
void insert(iterator it, size_type n, const char x) { vch.insert(it, n, x); }
|
||||
iterator insert(iterator it, const uint8_t x) { return vch.insert(it, x); }
|
||||
void insert(iterator it, size_type n, const uint8_t x) { vch.insert(it, n, x); }
|
||||
value_type* data() { return vch.data() + nReadPos; }
|
||||
const value_type* data() const { return vch.data() + nReadPos; }
|
||||
|
||||
void insert(iterator it, std::vector<char>::const_iterator first, std::vector<char>::const_iterator last)
|
||||
void insert(iterator it, std::vector<uint8_t>::const_iterator first, std::vector<uint8_t>::const_iterator last)
|
||||
{
|
||||
if (last == first) return;
|
||||
assert(last - first > 0);
|
||||
@ -377,12 +339,17 @@ public:
|
||||
nReadPos = 0;
|
||||
}
|
||||
|
||||
bool Rewind(size_type n)
|
||||
bool Rewind(std::optional<size_type> n = std::nullopt)
|
||||
{
|
||||
// Total rewind if no size is passed
|
||||
if (!n) {
|
||||
nReadPos = 0;
|
||||
return true;
|
||||
}
|
||||
// Rewind by n characters if the buffer hasn't been compacted yet
|
||||
if (n > nReadPos)
|
||||
if (*n > nReadPos)
|
||||
return false;
|
||||
nReadPos -= n;
|
||||
nReadPos -= *n;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -466,11 +433,6 @@ public:
|
||||
return (*this);
|
||||
}
|
||||
|
||||
void GetAndClear(CSerializeData &d) {
|
||||
d.insert(d.end(), begin(), end());
|
||||
clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* XOR the contents of this stream with a certain key.
|
||||
*
|
||||
|
@ -40,7 +40,7 @@ struct zero_after_free_allocator : public std::allocator<T> {
|
||||
}
|
||||
};
|
||||
|
||||
// Byte-vector that clears its contents before deletion.
|
||||
typedef std::vector<char, zero_after_free_allocator<char> > CSerializeData;
|
||||
/** Byte-vector that clears its contents before deletion. */
|
||||
using SerializeData = std::vector<uint8_t, zero_after_free_allocator<uint8_t>>;
|
||||
|
||||
#endif // BITCOIN_SUPPORT_ALLOCATORS_ZEROAFTERFREE_H
|
||||
|
@ -40,11 +40,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize)
|
||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||
stream << filter;
|
||||
|
||||
std::vector<unsigned char> vch = ParseHex("03614e9b050000000000000001");
|
||||
std::vector<char> expected(vch.size());
|
||||
|
||||
for (unsigned int i = 0; i < vch.size(); i++)
|
||||
expected[i] = (char)vch[i];
|
||||
std::vector<uint8_t> expected = ParseHex("03614e9b050000000000000001");
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expected.end());
|
||||
|
||||
@ -70,11 +66,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_serialize_with_tweak)
|
||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||
stream << filter;
|
||||
|
||||
std::vector<unsigned char> vch = ParseHex("03ce4299050000000100008001");
|
||||
std::vector<char> expected(vch.size());
|
||||
|
||||
for (unsigned int i = 0; i < vch.size(); i++)
|
||||
expected[i] = (char)vch[i];
|
||||
std::vector<uint8_t> expected = ParseHex("03ce4299050000000100008001");
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expected.end());
|
||||
}
|
||||
@ -94,11 +86,7 @@ BOOST_AUTO_TEST_CASE(bloom_create_insert_key)
|
||||
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
|
||||
stream << filter;
|
||||
|
||||
std::vector<unsigned char> vch = ParseHex("038fc16b080000000000000001");
|
||||
std::vector<char> expected(vch.size());
|
||||
|
||||
for (unsigned int i = 0; i < vch.size(); i++)
|
||||
expected[i] = (char)vch[i];
|
||||
std::vector<unsigned char> expected = ParseHex("038fc16b080000000000000001");
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expected.end());
|
||||
}
|
||||
@ -454,11 +442,7 @@ BOOST_AUTO_TEST_CASE(merkle_block_3_and_serialize)
|
||||
CDataStream merkleStream(SER_NETWORK, PROTOCOL_VERSION);
|
||||
merkleStream << merkleBlock;
|
||||
|
||||
std::vector<unsigned char> vch = ParseHex("0100000079cda856b143d9db2c1caff01d1aecc8630d30625d10e8b4b8b0000000000000b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f196367291b4d4c86041b8fa45d630100000001b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f19630101");
|
||||
std::vector<char> expected(vch.size());
|
||||
|
||||
for (unsigned int i = 0; i < vch.size(); i++)
|
||||
expected[i] = (char)vch[i];
|
||||
std::vector<uint8_t> expected = ParseHex("0100000079cda856b143d9db2c1caff01d1aecc8630d30625d10e8b4b8b0000000000000b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f196367291b4d4c86041b8fa45d630100000001b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f19630101");
|
||||
|
||||
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), merkleStream.begin(), merkleStream.end());
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ void CallOneOf(FuzzedDataProvider& fuzzed_data_provider, Callables... callables)
|
||||
|
||||
[[ nodiscard ]] inline CDataStream ConsumeDataStream(FuzzedDataProvider& fuzzed_data_provider, const size_t max_length = 4096) noexcept
|
||||
{
|
||||
return {ConsumeRandomLengthByteVector(fuzzed_data_provider, max_length), SER_NETWORK, INIT_PROTO_VERSION};
|
||||
return CDataStream{ConsumeRandomLengthByteVector(fuzzed_data_provider, max_length), SER_NETWORK, INIT_PROTO_VERSION};
|
||||
}
|
||||
|
||||
[[ nodiscard ]] inline std::vector<std::string> ConsumeRandomLengthStringVector(FuzzedDataProvider& fuzzed_data_provider, const size_t max_vector_size = 16, const size_t max_string_length = 16) noexcept
|
||||
|
@ -320,7 +320,7 @@ BOOST_AUTO_TEST_CASE(insert_delete)
|
||||
|
||||
ss.insert(ss.end(), c);
|
||||
BOOST_CHECK_EQUAL(ss.size(), 6U);
|
||||
BOOST_CHECK_EQUAL(ss[4], (char)0xff);
|
||||
BOOST_CHECK_EQUAL(ss[4], 0xff);
|
||||
BOOST_CHECK_EQUAL(ss[5], c);
|
||||
|
||||
ss.insert(ss.begin()+2, c);
|
||||
@ -334,19 +334,14 @@ BOOST_AUTO_TEST_CASE(insert_delete)
|
||||
|
||||
ss.erase(ss.begin()+ss.size()-1);
|
||||
BOOST_CHECK_EQUAL(ss.size(), 5U);
|
||||
BOOST_CHECK_EQUAL(ss[4], (char)0xff);
|
||||
BOOST_CHECK_EQUAL(ss[4], 0xff);
|
||||
|
||||
ss.erase(ss.begin()+1);
|
||||
BOOST_CHECK_EQUAL(ss.size(), 4U);
|
||||
BOOST_CHECK_EQUAL(ss[0], 0);
|
||||
BOOST_CHECK_EQUAL(ss[1], 1);
|
||||
BOOST_CHECK_EQUAL(ss[2], 2);
|
||||
BOOST_CHECK_EQUAL(ss[3], (char)0xff);
|
||||
|
||||
// Make sure GetAndClear does the right thing:
|
||||
CSerializeData d;
|
||||
ss.GetAndClear(d);
|
||||
BOOST_CHECK_EQUAL(ss.size(), 0U);
|
||||
BOOST_CHECK_EQUAL(ss[3], 0xff);
|
||||
}
|
||||
|
||||
// Change struct size and check if it can be deserialized
|
||||
|
@ -160,7 +160,7 @@ BOOST_AUTO_TEST_CASE(bitstream_reader_writer)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(streams_serializedata_xor)
|
||||
{
|
||||
std::vector<char> in;
|
||||
std::vector<uint8_t> in;
|
||||
std::vector<char> expected_xor;
|
||||
std::vector<unsigned char> key;
|
||||
CDataStream ds(in, 0, 0);
|
||||
|
@ -488,9 +488,9 @@ bool BerkeleyDatabase::Rewrite(const char* pszSkip)
|
||||
break;
|
||||
}
|
||||
if (pszSkip &&
|
||||
strncmp(ssKey.data(), pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0)
|
||||
strncmp((const char*)ssKey.data(), pszSkip, std::min(ssKey.size(), strlen(pszSkip))) == 0)
|
||||
continue;
|
||||
if (strncmp(ssKey.data(), "\x07version", 8) == 0) {
|
||||
if (strncmp((const char*)ssKey.data(), "\x07version", 8) == 0) {
|
||||
// Update version:
|
||||
ssValue.clear();
|
||||
ssValue << CLIENT_VERSION;
|
||||
|
Loading…
Reference in New Issue
Block a user