Skip to content

Commit ec20fd7

Browse files
committed
Merge pull request #5490
6bd0dc2 arith_uint256: remove initialization from byte vector (Wladimir J. van der Laan) 30007fd Remove now-unused methods from arith_uint256 and base_uint (Wladimir J. van der Laan) edc7204 Remove arith_uint160 (Wladimir J. van der Laan) dba2e91 Add tests for new uint256 (Wladimir J. van der Laan) 92cdb1a Add conversion functions arith_uint256<->uint_256 (Wladimir J. van der Laan) bfc6070 uint256->arith_uint256 blob256->uint256 (Wladimir J. van der Laan) 734f85c Use arith_uint256 where necessary (Wladimir J. van der Laan) 34cdc41 String conversions uint256 -> uint256S (Wladimir J. van der Laan) 2eae315 Replace uint256(1) with static constant (Wladimir J. van der Laan) 8076585 Replace GetLow64 with GetCheapHash (Wladimir J. van der Laan) 4f15249 Replace direct use of 0 with SetNull and IsNull (Wladimir J. van der Laan) 5d3064b Temporarily add SetNull/IsNull/GetCheapHash to base_uint (Wladimir J. van der Laan)
2 parents a043fac + 6bd0dc2 commit ec20fd7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1515
-1338
lines changed

src/Makefile.am

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ BITCOIN_CORE_H = \
7474
alert.h \
7575
allocators.h \
7676
amount.h \
77+
arith_uint256.h \
7778
base58.h \
7879
bloom.h \
7980
chain.h \
80-
chainparams.h \
8181
chainparamsbase.h \
82+
chainparams.h \
8283
chainparamsseeds.h \
8384
checkpoints.h \
8485
checkqueue.h \
@@ -87,8 +88,6 @@ BITCOIN_CORE_H = \
8788
coins.h \
8889
compat.h \
8990
compressor.h \
90-
primitives/block.h \
91-
primitives/transaction.h \
9291
core_io.h \
9392
crypter.h \
9493
db.h \
@@ -108,18 +107,20 @@ BITCOIN_CORE_H = \
108107
net.h \
109108
noui.h \
110109
pow.h \
110+
primitives/block.h \
111+
primitives/transaction.h \
111112
protocol.h \
112113
pubkey.h \
113114
random.h \
114115
rpcclient.h \
115116
rpcprotocol.h \
116117
rpcserver.h \
117118
script/interpreter.h \
119+
script/script_error.h \
118120
script/script.h \
119121
script/sigcache.h \
120122
script/sign.h \
121123
script/standard.h \
122-
script/script_error.h \
123124
serialize.h \
124125
streams.h \
125126
sync.h \
@@ -132,13 +133,13 @@ BITCOIN_CORE_H = \
132133
uint256.h \
133134
undo.h \
134135
util.h \
135-
utilstrencodings.h \
136136
utilmoneystr.h \
137+
utilstrencodings.h \
137138
utiltime.h \
138139
version.h \
140+
walletdb.h \
139141
wallet.h \
140142
wallet_ismine.h \
141-
walletdb.h \
142143
compat/sanity.h
143144

144145
JSON_H = \
@@ -261,18 +262,19 @@ libbitcoin_common_a_SOURCES = \
261262
# backward-compatibility objects and their sanity checks are linked.
262263
libbitcoin_util_a_CPPFLAGS = $(BITCOIN_INCLUDES)
263264
libbitcoin_util_a_SOURCES = \
264-
compat/strnlen.cpp \
265-
compat/glibc_sanity.cpp \
266-
compat/glibcxx_sanity.cpp \
265+
arith_uint256.cpp \
267266
chainparamsbase.cpp \
268267
clientversion.cpp \
268+
compat/glibc_sanity.cpp \
269+
compat/glibcxx_sanity.cpp \
270+
compat/strnlen.cpp \
269271
random.cpp \
270272
rpcprotocol.cpp \
271273
sync.cpp \
272274
uint256.cpp \
273275
util.cpp \
274-
utilstrencodings.cpp \
275276
utilmoneystr.cpp \
277+
utilstrencodings.cpp \
276278
utiltime.cpp \
277279
$(BITCOIN_CORE_H)
278280

@@ -352,19 +354,20 @@ bitcoin_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
352354
if BUILD_BITCOIN_LIBS
353355
include_HEADERS = script/bitcoinconsensus.h
354356
libbitcoinconsensus_la_SOURCES = \
355-
primitives/transaction.cpp \
357+
arith_uint256.cpp \
356358
crypto/hmac_sha512.cpp \
359+
crypto/ripemd160.cpp \
357360
crypto/sha1.cpp \
358361
crypto/sha256.cpp \
359362
crypto/sha512.cpp \
360-
crypto/ripemd160.cpp \
361363
eccryptoverify.cpp \
362364
ecwrapper.cpp \
363365
hash.cpp \
366+
primitives/transaction.cpp \
364367
pubkey.cpp \
365-
script/script.cpp \
366-
script/interpreter.cpp \
367368
script/bitcoinconsensus.cpp \
369+
script/interpreter.cpp \
370+
script/script.cpp \
368371
uint256.cpp \
369372
utilstrencodings.cpp
370373

src/Makefile.test.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ RAW_TEST_FILES = test/data/alertTests.raw
3434
GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h)
3535

3636
BITCOIN_TESTS =\
37+
test/arith_uint256_tests.cpp \
3738
test/bignum.h \
3839
test/alert_tests.cpp \
3940
test/allocator_tests.cpp \

src/addrman.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ int CAddrInfo::GetTriedBucket(const std::vector<unsigned char>& nKey) const
1515
CDataStream ss1(SER_GETHASH, 0);
1616
std::vector<unsigned char> vchKey = GetKey();
1717
ss1 << nKey << vchKey;
18-
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).GetLow64();
18+
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).GetCheapHash();
1919

2020
CDataStream ss2(SER_GETHASH, 0);
2121
std::vector<unsigned char> vchGroupKey = GetGroup();
2222
ss2 << nKey << vchGroupKey << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP);
23-
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetLow64();
23+
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetCheapHash();
2424
return hash2 % ADDRMAN_TRIED_BUCKET_COUNT;
2525
}
2626

@@ -30,11 +30,11 @@ int CAddrInfo::GetNewBucket(const std::vector<unsigned char>& nKey, const CNetAd
3030
std::vector<unsigned char> vchGroupKey = GetGroup();
3131
std::vector<unsigned char> vchSourceGroupKey = src.GetGroup();
3232
ss1 << nKey << vchGroupKey << vchSourceGroupKey;
33-
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).GetLow64();
33+
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).GetCheapHash();
3434

3535
CDataStream ss2(SER_GETHASH, 0);
3636
ss2 << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP);
37-
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetLow64();
37+
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetCheapHash();
3838
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
3939
}
4040

0 commit comments

Comments
 (0)