practicalswift
6e8c48dc59
Add const to methods that do not modify the object for which it is called
2017-07-25 13:46:52 +02:00
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-
2017-06-22 03:48:50 +02:00
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
2017-06-22 03:48:42 +02:00
Pieter Wuille
1ad3d4e126
Merge #10502 : scripted-diff: Remove BOOST_FOREACH, Q_FOREACH and PAIRTYPE
...
1238f13cf
scripted-diff: Remove PAIRTYPE (Jorge Timón)
18dc3c396
scripted-diff: Remove Q_FOREACH (Jorge Timón)
7c00c2672
scripted-diff: Fully remove BOOST_FOREACH (Jorge Timón)
a5410ac5e
Small preparations for Q_FOREACH, PAIRTYPE and #include <boost/foreach.hpp> removal (Jorge Timón)
Tree-SHA512: d3ab4a173366402e7dcef31608977b757d4aa07abbbad2ee1bcbcfa311e994a4552f24e5a55272cb22c2dcf89a4b0495e02e9d9aceae4b08c0bab668f20e324c
2017-06-13 18:05:58 -07:00
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-
2017-06-07 12:08:39 -07:00
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-
2017-06-07 11:35:16 -07:00
Pieter Wuille
2ada678521
Use randbits instead of ad-hoc emulation in prevector tests
2017-06-07 11:35:16 -07:00
Pieter Wuille
3ecabae363
Replace more rand() % NUM by randranges
2017-06-07 11:34:55 -07:00
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-
2017-06-05 12:45:44 -07:00
Pieter Wuille
124d13a58c
Merge test_random.h into test_bitcoin.h
2017-06-05 12:44:44 -07:00
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-
2017-06-05 20:10:50 +02:00
Pieter Wuille
16329224e7
Switch FastRandomContext to ChaCha20
2017-03-29 11:26:08 -07:00
isle2983
27765b6403
Increment MIT Licence copyright header year on files modified in 2016
...
Edited via:
$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Pieter Wuille
2ddfcfd2d6
Make CScript (and prevector) c++11 movable.
...
Such moves are used when reallocating vectors that contain them,
for example.
2016-12-21 18:28:33 -08:00
MarcoFalke
fa8278e845
test: Fix test_random includes
2016-11-07 16:11:51 +01:00
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`.
2016-10-17 13:08:35 +02:00
Jeremy Rubin
f71d4a3786
Minimal fix to slow prevector tests as stopgap measure
2016-09-06 16:19:25 -04:00
Pavel Janík
c2715d3ab8
Do not shadow local variables
2016-06-07 21:22:48 +02:00
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
2016-04-16 08:05:11 -07:00
Pieter Wuille
114b5812f6
Prevector type
2015-11-13 18:15:20 +01:00