practicalswift
6e8c48dc59
Add const to methods that do not modify the object for which it is called
7 years ago
Jorge Timón
3eff827f89
scripted-diff: Remove BOOST_REVERSE_FOREACH
...
-BEGIN VERIFY SCRIPT-
sed -i 's/BOOST_REVERSE_FOREACH(\(.*\), \(.*\))/for (\1 : reverse_iterate(\2))/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ;
-END VERIFY SCRIPT-
7 years ago
Jorge Timón
300851ec16
Introduce src/reverse_iterator.hpp and include it...
...
...where it will be needed
Taken from https://gist.github.com/arvidsson/7231973 with small
modifications to fit the bitcoin core project
7 years ago
Pieter Wuille
e945848582
scripted-diff: Use new naming style for insecure_rand* functions
...
-BEGIN VERIFY SCRIPT-
sed -i 's/\<insecure_randbits(/InsecureRandBits(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_randbool(/InsecureRandBool(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_randrange(/InsecureRandRange(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_randbytes(/InsecureRandBytes(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_rand256(/InsecureRand256(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<insecure_rand(/InsecureRand32(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
sed -i 's/\<seed_insecure_rand(/SeedInsecureRand(/g' src/test/*.cpp src/test/*.h src/wallet/test/*.cpp
-END VERIFY SCRIPT-
8 years ago
Pieter Wuille
2fcd9cc86b
scripted-diff: Use randbits/bool instead of randrange where possible
...
-BEGIN VERIFY SCRIPT-
sed -i 's/insecure_randbits(1)/insecure_randbool()/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(2)/insecure_randbool()/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(4)/insecure_randbits(2)/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(32)/insecure_randbits(5)/g' src/test/*_tests.cpp
sed -i 's/insecure_randrange(256)/insecure_randbits(8)/g' src/test/*_tests.cpp
-END VERIFY SCRIPT-
8 years ago
Pieter Wuille
2ada678521
Use randbits instead of ad-hoc emulation in prevector tests
8 years ago
Pieter Wuille
3ecabae363
Replace more rand() % NUM by randranges
8 years ago
Pieter Wuille
efee1db21a
scripted-diff: use insecure_rand256/randrange more
...
-BEGIN VERIFY SCRIPT-
sed -i "s/\<GetRandHash(/insecure_rand256(/" src/test/*_tests.cpp
sed -i "s/\<GetRand(/insecure_randrange(/" src/test/*_tests.cpp src/test/test_bitcoin.cpp
sed -i 's/\<insecure_rand() % \([0-9]\+\)/insecure_randrange(\1)/g' src/test/*_tests.cpp
-END VERIFY SCRIPT-
8 years ago
Pieter Wuille
124d13a58c
Merge test_random.h into test_bitcoin.h
8 years ago
Jorge Timón
7c00c26726
scripted-diff: Fully remove BOOST_FOREACH
...
-BEGIN VERIFY SCRIPT-
sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
-END VERIFY SCRIPT-
8 years ago
Pieter Wuille
16329224e7
Switch FastRandomContext to ChaCha20
8 years ago
isle2983
27765b6403
Increment MIT Licence copyright header year on files modified in 2016
...
Edited via:
$ contrib/devtools/copyright_header.py update .
8 years ago
Pieter Wuille
2ddfcfd2d6
Make CScript (and prevector) c++11 movable.
...
Such moves are used when reallocating vectors that contain them,
for example.
8 years ago
MarcoFalke
fa8278e845
test: Fix test_random includes
8 years ago
Wladimir J. van der Laan
5eaaa83ac1
Kill insecure_random and associated global state
...
There are only a few uses of `insecure_random` outside the tests.
This PR replaces uses of insecure_random (and its accompanying global
state) in the core code with an FastRandomContext that is automatically
seeded on creation.
This is meant to be used for inner loops. The FastRandomContext
can be in the outer scope, or the class itself, then rand32() is used
inside the loop. Useful e.g. for pushing addresses in CNode or the fee
rounding, or randomization for coin selection.
As a context is created per purpose, thus it gets rid of
cross-thread unprotected shared usage of a single set of globals, this
should also get rid of the potential race conditions.
- I'd say TxMempool::check is not called enough to warrant using a special
fast random context, this is switched to GetRand() (open for
discussion...)
- The use of `insecure_rand` in ConnectThroughProxy has been replaced by
an atomic integer counter. The only goal here is to have a different
credentials pair for each connection to go on a different Tor circuit,
it does not need to be random nor unpredictable.
- To avoid having a FastRandomContext on every CNode, the context is
passed into PushAddress as appropriate.
There remains an insecure_random for test usage in `test_random.h`.
8 years ago
Jeremy Rubin
f71d4a3786
Minimal fix to slow prevector tests as stopgap measure
8 years ago
Pavel Janík
c2715d3ab8
Do not shadow local variables
9 years ago
Kaz Wesley
4ed41a2b61
test prevector::swap
...
- add a swap operation to prevector tests (fails due to broken prevector::swap)
- fix 2 prevector test operation conditions that were impossible
9 years ago
Pieter Wuille
114b5812f6
Prevector type
9 years ago