Skip to content

Commit

Permalink
Merge pull request bitcoin#5490
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
laanwj committed Jan 5, 2015
2 parents a043fac + 6bd0dc2 commit ec20fd7
Show file tree
Hide file tree
Showing 50 changed files with 1,515 additions and 1,338 deletions.
31 changes: 17 additions & 14 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ BITCOIN_CORE_H = \
alert.h \
allocators.h \
amount.h \
arith_uint256.h \
base58.h \
bloom.h \
chain.h \
chainparams.h \
chainparamsbase.h \
chainparams.h \
chainparamsseeds.h \
checkpoints.h \
checkqueue.h \
Expand All @@ -87,8 +88,6 @@ BITCOIN_CORE_H = \
coins.h \
compat.h \
compressor.h \
primitives/block.h \
primitives/transaction.h \
core_io.h \
crypter.h \
db.h \
Expand All @@ -108,18 +107,20 @@ BITCOIN_CORE_H = \
net.h \
noui.h \
pow.h \
primitives/block.h \
primitives/transaction.h \
protocol.h \
pubkey.h \
random.h \
rpcclient.h \
rpcprotocol.h \
rpcserver.h \
script/interpreter.h \
script/script_error.h \
script/script.h \
script/sigcache.h \
script/sign.h \
script/standard.h \
script/script_error.h \
serialize.h \
streams.h \
sync.h \
Expand All @@ -132,13 +133,13 @@ BITCOIN_CORE_H = \
uint256.h \
undo.h \
util.h \
utilstrencodings.h \
utilmoneystr.h \
utilstrencodings.h \
utiltime.h \
version.h \
walletdb.h \
wallet.h \
wallet_ismine.h \
walletdb.h \
compat/sanity.h

JSON_H = \
Expand Down Expand Up @@ -261,18 +262,19 @@ libbitcoin_common_a_SOURCES = \
# backward-compatibility objects and their sanity checks are linked.
libbitcoin_util_a_CPPFLAGS = $(BITCOIN_INCLUDES)
libbitcoin_util_a_SOURCES = \
compat/strnlen.cpp \
compat/glibc_sanity.cpp \
compat/glibcxx_sanity.cpp \
arith_uint256.cpp \
chainparamsbase.cpp \
clientversion.cpp \
compat/glibc_sanity.cpp \
compat/glibcxx_sanity.cpp \
compat/strnlen.cpp \
random.cpp \
rpcprotocol.cpp \
sync.cpp \
uint256.cpp \
util.cpp \
utilstrencodings.cpp \
utilmoneystr.cpp \
utilstrencodings.cpp \
utiltime.cpp \
$(BITCOIN_CORE_H)

Expand Down Expand Up @@ -352,19 +354,20 @@ bitcoin_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
if BUILD_BITCOIN_LIBS
include_HEADERS = script/bitcoinconsensus.h
libbitcoinconsensus_la_SOURCES = \
primitives/transaction.cpp \
arith_uint256.cpp \
crypto/hmac_sha512.cpp \
crypto/ripemd160.cpp \
crypto/sha1.cpp \
crypto/sha256.cpp \
crypto/sha512.cpp \
crypto/ripemd160.cpp \
eccryptoverify.cpp \
ecwrapper.cpp \
hash.cpp \
primitives/transaction.cpp \
pubkey.cpp \
script/script.cpp \
script/interpreter.cpp \
script/bitcoinconsensus.cpp \
script/interpreter.cpp \
script/script.cpp \
uint256.cpp \
utilstrencodings.cpp

Expand Down
1 change: 1 addition & 0 deletions src/Makefile.test.include
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ RAW_TEST_FILES = test/data/alertTests.raw
GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.raw.h)

BITCOIN_TESTS =\
test/arith_uint256_tests.cpp \
test/bignum.h \
test/alert_tests.cpp \
test/allocator_tests.cpp \
Expand Down
8 changes: 4 additions & 4 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ int CAddrInfo::GetTriedBucket(const std::vector<unsigned char>& nKey) const
CDataStream ss1(SER_GETHASH, 0);
std::vector<unsigned char> vchKey = GetKey();
ss1 << nKey << vchKey;
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).GetLow64();
uint64_t hash1 = Hash(ss1.begin(), ss1.end()).GetCheapHash();

CDataStream ss2(SER_GETHASH, 0);
std::vector<unsigned char> vchGroupKey = GetGroup();
ss2 << nKey << vchGroupKey << (hash1 % ADDRMAN_TRIED_BUCKETS_PER_GROUP);
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetLow64();
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetCheapHash();
return hash2 % ADDRMAN_TRIED_BUCKET_COUNT;
}

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

CDataStream ss2(SER_GETHASH, 0);
ss2 << nKey << vchSourceGroupKey << (hash1 % ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP);
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetLow64();
uint64_t hash2 = Hash(ss2.begin(), ss2.end()).GetCheapHash();
return hash2 % ADDRMAN_NEW_BUCKET_COUNT;
}

Expand Down
Loading

0 comments on commit ec20fd7

Please sign in to comment.