mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 17:24:58 +02:00
scripted-diff: Use std::span over Span
-BEGIN VERIFY SCRIPT-
ren() { sed -i "s!\<$1\>!$2!g" $( git grep -l "$1" -- "./src" ":(exclude)src/span.h" ":(exclude)src/leveldb/db/log_test.cc" ) ; }
ren Span std::span
ren AsBytes std::as_bytes
ren AsWritableBytes std::as_writable_bytes
sed -i 's!SpanPopBack(Span!SpanPopBack(std::span!g' ./src/span.h
-END VERIFY SCRIPT-
This commit is contained in:
14
src/random.h
14
src/random.h
@@ -114,7 +114,7 @@ void RandAddEvent(const uint32_t event_info) noexcept;
|
||||
*
|
||||
* Thread-safe.
|
||||
*/
|
||||
void GetRandBytes(Span<unsigned char> bytes) noexcept;
|
||||
void GetRandBytes(std::span<unsigned char> bytes) noexcept;
|
||||
|
||||
/**
|
||||
* Gather entropy from various sources, feed it into the internal PRNG, and
|
||||
@@ -126,7 +126,7 @@ void GetRandBytes(Span<unsigned char> bytes) noexcept;
|
||||
*
|
||||
* Thread-safe.
|
||||
*/
|
||||
void GetStrongRandBytes(Span<unsigned char> bytes) noexcept;
|
||||
void GetStrongRandBytes(std::span<unsigned char> bytes) noexcept;
|
||||
|
||||
|
||||
/* ============================= RANDOM NUMBER GENERATION CLASSES =============================
|
||||
@@ -144,7 +144,7 @@ class RandomMixin;
|
||||
|
||||
/** A concept for RandomMixin-based random number generators. */
|
||||
template<typename T>
|
||||
concept RandomNumberGenerator = requires(T& rng, Span<std::byte> s) {
|
||||
concept RandomNumberGenerator = requires(T& rng, std::span<std::byte> s) {
|
||||
// A random number generator must provide rand64().
|
||||
{ rng.rand64() } noexcept -> std::same_as<uint64_t>;
|
||||
// A random number generator must derive from RandomMixin, which adds other rand* functions.
|
||||
@@ -263,8 +263,8 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
/** Fill a Span with random bytes. */
|
||||
void fillrand(Span<std::byte> span) noexcept
|
||||
/** Fill a std::span with random bytes. */
|
||||
void fillrand(std::span<std::byte> span) noexcept
|
||||
{
|
||||
while (span.size() >= 8) {
|
||||
uint64_t gen = Impl().rand64();
|
||||
@@ -400,8 +400,8 @@ public:
|
||||
return ReadLE64(buf.data());
|
||||
}
|
||||
|
||||
/** Fill a byte Span with random bytes. This overrides the RandomMixin version. */
|
||||
void fillrand(Span<std::byte> output) noexcept;
|
||||
/** Fill a byte std::span with random bytes. This overrides the RandomMixin version. */
|
||||
void fillrand(std::span<std::byte> output) noexcept;
|
||||
};
|
||||
|
||||
/** xoroshiro128++ PRNG. Extremely fast, not appropriate for cryptographic purposes.
|
||||
|
||||
Reference in New Issue
Block a user