mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
merge bitcoin#24989: rename BytePtr to AsBytePtr
This commit is contained in:
parent
5dbe58c996
commit
1a630ba785
@ -22,7 +22,7 @@ static void EllSwiftCreate(benchmark::Bench& bench)
|
|||||||
key.Set(UCharCast(ret.data()), UCharCast(ret.data()) + 32, true);
|
key.Set(UCharCast(ret.data()), UCharCast(ret.data()) + 32, true);
|
||||||
assert(key.IsValid());
|
assert(key.IsValid());
|
||||||
/* Use the last 32 bytes of the ellswift encoded public key as next entropy. */
|
/* Use the last 32 bytes of the ellswift encoded public key as next entropy. */
|
||||||
std::copy(ret.begin() + 32, ret.begin() + 64, BytePtr(entropy.data()));
|
std::copy(ret.begin() + 32, ret.begin() + 64, AsBytePtr(entropy.data()));
|
||||||
});
|
});
|
||||||
|
|
||||||
ECC_Stop();
|
ECC_Stop();
|
||||||
|
@ -656,10 +656,10 @@ struct CustomUintFormatter
|
|||||||
if (v < 0 || v > MAX) throw std::ios_base::failure("CustomUintFormatter value out of range");
|
if (v < 0 || v > MAX) throw std::ios_base::failure("CustomUintFormatter value out of range");
|
||||||
if (BigEndian) {
|
if (BigEndian) {
|
||||||
uint64_t raw = htobe64(v);
|
uint64_t raw = htobe64(v);
|
||||||
s.write({BytePtr(&raw) + 8 - Bytes, Bytes});
|
s.write({AsBytePtr(&raw) + 8 - Bytes, Bytes});
|
||||||
} else {
|
} else {
|
||||||
uint64_t raw = htole64(v);
|
uint64_t raw = htole64(v);
|
||||||
s.write({BytePtr(&raw), Bytes});
|
s.write({AsBytePtr(&raw), Bytes});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -669,10 +669,10 @@ struct CustomUintFormatter
|
|||||||
static_assert(std::numeric_limits<U>::max() >= MAX && std::numeric_limits<U>::min() <= 0, "Assigned type too small");
|
static_assert(std::numeric_limits<U>::max() >= MAX && std::numeric_limits<U>::min() <= 0, "Assigned type too small");
|
||||||
uint64_t raw = 0;
|
uint64_t raw = 0;
|
||||||
if (BigEndian) {
|
if (BigEndian) {
|
||||||
s.read({BytePtr(&raw) + 8 - Bytes, Bytes});
|
s.read({AsBytePtr(&raw) + 8 - Bytes, Bytes});
|
||||||
v = static_cast<I>(be64toh(raw));
|
v = static_cast<I>(be64toh(raw));
|
||||||
} else {
|
} else {
|
||||||
s.read({BytePtr(&raw), Bytes});
|
s.read({AsBytePtr(&raw), Bytes});
|
||||||
v = static_cast<I>(le64toh(raw));
|
v = static_cast<I>(le64toh(raw));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,19 +245,19 @@ T& SpanPopBack(Span<T>& span)
|
|||||||
|
|
||||||
//! Convert a data pointer to a std::byte data pointer.
|
//! Convert a data pointer to a std::byte data pointer.
|
||||||
//! Where possible, please use the safer AsBytes helpers.
|
//! Where possible, please use the safer AsBytes helpers.
|
||||||
inline const std::byte* BytePtr(const void* data) { return reinterpret_cast<const std::byte*>(data); }
|
inline const std::byte* AsBytePtr(const void* data) { return reinterpret_cast<const std::byte*>(data); }
|
||||||
inline std::byte* BytePtr(void* data) { return reinterpret_cast<std::byte*>(data); }
|
inline std::byte* AsBytePtr(void* data) { return reinterpret_cast<std::byte*>(data); }
|
||||||
|
|
||||||
// From C++20 as_bytes and as_writeable_bytes
|
// From C++20 as_bytes and as_writeable_bytes
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Span<const std::byte> AsBytes(Span<T> s) noexcept
|
Span<const std::byte> AsBytes(Span<T> s) noexcept
|
||||||
{
|
{
|
||||||
return {BytePtr(s.data()), s.size_bytes()};
|
return {AsBytePtr(s.data()), s.size_bytes()};
|
||||||
}
|
}
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Span<std::byte> AsWritableBytes(Span<T> s) noexcept
|
Span<std::byte> AsWritableBytes(Span<T> s) noexcept
|
||||||
{
|
{
|
||||||
return {BytePtr(s.data()), s.size_bytes()};
|
return {AsBytePtr(s.data()), s.size_bytes()};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename V>
|
template <typename V>
|
||||||
|
@ -681,10 +681,10 @@ bool BerkeleyBatch::ReadAtCursor(CDataStream& ssKey, CDataStream& ssValue, bool&
|
|||||||
// Convert to streams
|
// Convert to streams
|
||||||
ssKey.SetType(SER_DISK);
|
ssKey.SetType(SER_DISK);
|
||||||
ssKey.clear();
|
ssKey.clear();
|
||||||
ssKey.write({BytePtr(datKey.get_data()), datKey.get_size()});
|
ssKey.write({AsBytePtr(datKey.get_data()), datKey.get_size()});
|
||||||
ssValue.SetType(SER_DISK);
|
ssValue.SetType(SER_DISK);
|
||||||
ssValue.clear();
|
ssValue.clear();
|
||||||
ssValue.write({BytePtr(datValue.get_data()), datValue.get_size()});
|
ssValue.write({AsBytePtr(datValue.get_data()), datValue.get_size()});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -756,7 +756,7 @@ bool BerkeleyBatch::ReadKey(CDataStream&& key, CDataStream& value)
|
|||||||
SafeDbt datValue;
|
SafeDbt datValue;
|
||||||
int ret = pdb->get(activeTxn, datKey, datValue, 0);
|
int ret = pdb->get(activeTxn, datKey, datValue, 0);
|
||||||
if (ret == 0 && datValue.get_data() != nullptr) {
|
if (ret == 0 && datValue.get_data() != nullptr) {
|
||||||
value.write({BytePtr(datValue.get_data()), datValue.get_size()});
|
value.write({AsBytePtr(datValue.get_data()), datValue.get_size()});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -404,7 +404,7 @@ bool SQLiteBatch::ReadKey(CDataStream&& key, CDataStream& value)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Leftmost column in result is index 0
|
// Leftmost column in result is index 0
|
||||||
const std::byte* data{BytePtr(sqlite3_column_blob(m_read_stmt, 0))};
|
const std::byte* data{AsBytePtr(sqlite3_column_blob(m_read_stmt, 0))};
|
||||||
size_t data_size(sqlite3_column_bytes(m_read_stmt, 0));
|
size_t data_size(sqlite3_column_bytes(m_read_stmt, 0));
|
||||||
value.write({data, data_size});
|
value.write({data, data_size});
|
||||||
|
|
||||||
@ -496,10 +496,10 @@ bool SQLiteBatch::ReadAtCursor(CDataStream& key, CDataStream& value, bool& compl
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Leftmost column in result is index 0
|
// Leftmost column in result is index 0
|
||||||
const std::byte* key_data{BytePtr(sqlite3_column_blob(m_cursor_stmt, 0))};
|
const std::byte* key_data{AsBytePtr(sqlite3_column_blob(m_cursor_stmt, 0))};
|
||||||
size_t key_data_size(sqlite3_column_bytes(m_cursor_stmt, 0));
|
size_t key_data_size(sqlite3_column_bytes(m_cursor_stmt, 0));
|
||||||
key.write({key_data, key_data_size});
|
key.write({key_data, key_data_size});
|
||||||
const std::byte* value_data{BytePtr(sqlite3_column_blob(m_cursor_stmt, 1))};
|
const std::byte* value_data{AsBytePtr(sqlite3_column_blob(m_cursor_stmt, 1))};
|
||||||
size_t value_data_size(sqlite3_column_bytes(m_cursor_stmt, 1));
|
size_t value_data_size(sqlite3_column_bytes(m_cursor_stmt, 1));
|
||||||
value.write({value_data, value_data_size});
|
value.write({value_data, value_data_size});
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user