From e414486d56b9f06af7aeb07ce13e3c3780c2b69b Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 31 Oct 2018 15:41:13 -0700 Subject: Do not permit copying FastRandomContexts --- src/random.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/random.cpp') diff --git a/src/random.cpp b/src/random.cpp index ebc2ff42c8..f8ffda136d 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -464,6 +464,20 @@ FastRandomContext::FastRandomContext(bool fDeterministic) : requires_seed(!fDete rng.SetKey(seed.begin(), 32); } +FastRandomContext& FastRandomContext::operator=(FastRandomContext&& from) noexcept +{ + requires_seed = from.requires_seed; + rng = from.rng; + std::copy(std::begin(from.bytebuf), std::end(from.bytebuf), std::begin(bytebuf)); + bytebuf_size = from.bytebuf_size; + bitbuf = from.bitbuf; + bitbuf_size = from.bitbuf_size; + from.requires_seed = true; + from.bytebuf_size = 0; + from.bitbuf_size = 0; + return *this; +} + void RandomInit() { RDRandInit(); -- cgit v1.2.3