Merge branch 'master' into single_prodname
This commit is contained in:
+69
-54
@@ -28,6 +28,7 @@ BITCOIN_INCLUDES += -I$(srcdir)/univalue/include
|
||||
LIBBITCOIN_SERVER=libbitcoin_server.a
|
||||
LIBBITCOIN_WALLET=libbitcoin_wallet.a
|
||||
LIBBITCOIN_COMMON=libbitcoin_common.a
|
||||
LIBBITCOIN_CONSENSUS=libbitcoin_consensus.a
|
||||
LIBBITCOIN_CLI=libbitcoin_cli.a
|
||||
LIBBITCOIN_UTIL=libbitcoin_util.a
|
||||
LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a
|
||||
@@ -47,6 +48,7 @@ EXTRA_LIBRARIES = \
|
||||
crypto/libbitcoin_crypto.a \
|
||||
libbitcoin_util.a \
|
||||
libbitcoin_common.a \
|
||||
libbitcoin_consensus.a \
|
||||
libbitcoin_server.a \
|
||||
libbitcoin_cli.a
|
||||
if ENABLE_WALLET
|
||||
@@ -59,9 +61,9 @@ endif
|
||||
|
||||
if BUILD_BITCOIN_LIBS
|
||||
lib_LTLIBRARIES = libbitcoinconsensus.la
|
||||
LIBBITCOIN_CONSENSUS=libbitcoinconsensus.la
|
||||
LIBBITCOINCONSENSUS=libbitcoinconsensus.la
|
||||
else
|
||||
LIBBITCOIN_CONSENSUS=
|
||||
LIBBITCOINCONSENSUS=
|
||||
endif
|
||||
|
||||
bin_PROGRAMS =
|
||||
@@ -76,13 +78,11 @@ if BUILD_BITCOIN_UTILS
|
||||
bin_PROGRAMS += bitcoin-cli bitcoin-tx
|
||||
endif
|
||||
|
||||
.PHONY: FORCE
|
||||
.PHONY: FORCE check-symbols check-security
|
||||
# bitcoin core #
|
||||
BITCOIN_CORE_H = \
|
||||
addrman.h \
|
||||
alert.h \
|
||||
amount.h \
|
||||
arith_uint256.h \
|
||||
base58.h \
|
||||
bloom.h \
|
||||
chain.h \
|
||||
@@ -100,11 +100,8 @@ BITCOIN_CORE_H = \
|
||||
compat/sanity.h \
|
||||
compressor.h \
|
||||
consensus/consensus.h \
|
||||
consensus/params.h \
|
||||
consensus/validation.h \
|
||||
core_io.h \
|
||||
core_memusage.h \
|
||||
hash.h \
|
||||
httprpc.h \
|
||||
httpserver.h \
|
||||
init.h \
|
||||
@@ -116,30 +113,23 @@ BITCOIN_CORE_H = \
|
||||
memusage.h \
|
||||
merkleblock.h \
|
||||
miner.h \
|
||||
mruset.h \
|
||||
net.h \
|
||||
netbase.h \
|
||||
noui.h \
|
||||
policy/fees.h \
|
||||
policy/policy.h \
|
||||
policy/rbf.h \
|
||||
pow.h \
|
||||
primitives/block.h \
|
||||
primitives/transaction.h \
|
||||
protocol.h \
|
||||
pubkey.h \
|
||||
random.h \
|
||||
reverselock.h \
|
||||
rpcclient.h \
|
||||
rpcprotocol.h \
|
||||
rpcserver.h \
|
||||
rpc/client.h \
|
||||
rpc/protocol.h \
|
||||
rpc/server.h \
|
||||
scheduler.h \
|
||||
script/interpreter.h \
|
||||
script/script.h \
|
||||
script/script_error.h \
|
||||
script/sigcache.h \
|
||||
script/sign.h \
|
||||
script/standard.h \
|
||||
serialize.h \
|
||||
streams.h \
|
||||
support/allocators/secure.h \
|
||||
support/allocators/zeroafterfree.h \
|
||||
@@ -148,21 +138,18 @@ BITCOIN_CORE_H = \
|
||||
sync.h \
|
||||
threadsafety.h \
|
||||
timedata.h \
|
||||
tinyformat.h \
|
||||
torcontrol.h \
|
||||
txdb.h \
|
||||
txmempool.h \
|
||||
ui_interface.h \
|
||||
uint256.h \
|
||||
undo.h \
|
||||
util.h \
|
||||
utilmoneystr.h \
|
||||
utilstrencodings.h \
|
||||
utiltime.h \
|
||||
validationinterface.h \
|
||||
version.h \
|
||||
wallet/crypter.h \
|
||||
wallet/db.h \
|
||||
wallet/rpcwallet.h \
|
||||
wallet/wallet.h \
|
||||
wallet/wallet_ismine.h \
|
||||
wallet/walletdb.h \
|
||||
@@ -200,12 +187,12 @@ libbitcoin_server_a_SOURCES = \
|
||||
policy/policy.cpp \
|
||||
pow.cpp \
|
||||
rest.cpp \
|
||||
rpcblockchain.cpp \
|
||||
rpcmining.cpp \
|
||||
rpcmisc.cpp \
|
||||
rpcnet.cpp \
|
||||
rpcrawtransaction.cpp \
|
||||
rpcserver.cpp \
|
||||
rpc/blockchain.cpp \
|
||||
rpc/mining.cpp \
|
||||
rpc/misc.cpp \
|
||||
rpc/net.cpp \
|
||||
rpc/rawtransaction.cpp \
|
||||
rpc/server.cpp \
|
||||
script/sigcache.cpp \
|
||||
timedata.cpp \
|
||||
torcontrol.cpp \
|
||||
@@ -238,6 +225,7 @@ libbitcoin_wallet_a_SOURCES = \
|
||||
wallet/wallet.cpp \
|
||||
wallet/wallet_ismine.cpp \
|
||||
wallet/walletdb.cpp \
|
||||
policy/rbf.cpp \
|
||||
$(BITCOIN_CORE_H)
|
||||
|
||||
# crypto primitives library
|
||||
@@ -258,30 +246,57 @@ crypto_libbitcoin_crypto_a_SOURCES = \
|
||||
crypto/sha512.cpp \
|
||||
crypto/sha512.h
|
||||
|
||||
# consensus: shared between all executables that validate any consensus rules.
|
||||
libbitcoin_consensus_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||
libbitcoin_consensus_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
libbitcoin_consensus_a_SOURCES = \
|
||||
amount.h \
|
||||
arith_uint256.cpp \
|
||||
arith_uint256.h \
|
||||
consensus/merkle.cpp \
|
||||
consensus/merkle.h \
|
||||
consensus/params.h \
|
||||
consensus/validation.h \
|
||||
hash.cpp \
|
||||
hash.h \
|
||||
prevector.h \
|
||||
primitives/block.cpp \
|
||||
primitives/block.h \
|
||||
primitives/transaction.cpp \
|
||||
primitives/transaction.h \
|
||||
pubkey.cpp \
|
||||
pubkey.h \
|
||||
script/bitcoinconsensus.cpp \
|
||||
script/interpreter.cpp \
|
||||
script/interpreter.h \
|
||||
script/script.cpp \
|
||||
script/script.h \
|
||||
script/script_error.cpp \
|
||||
script/script_error.h \
|
||||
serialize.h \
|
||||
tinyformat.h \
|
||||
uint256.cpp \
|
||||
uint256.h \
|
||||
utilstrencodings.cpp \
|
||||
utilstrencodings.h \
|
||||
version.h
|
||||
|
||||
# common: shared between bitcoind, and bitcoin-qt and non-server tools
|
||||
libbitcoin_common_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||
libbitcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
libbitcoin_common_a_SOURCES = \
|
||||
amount.cpp \
|
||||
arith_uint256.cpp \
|
||||
base58.cpp \
|
||||
chainparams.cpp \
|
||||
coins.cpp \
|
||||
compressor.cpp \
|
||||
core_read.cpp \
|
||||
core_write.cpp \
|
||||
hash.cpp \
|
||||
key.cpp \
|
||||
keystore.cpp \
|
||||
netbase.cpp \
|
||||
primitives/block.cpp \
|
||||
primitives/transaction.cpp \
|
||||
protocol.cpp \
|
||||
pubkey.cpp \
|
||||
scheduler.cpp \
|
||||
script/interpreter.cpp \
|
||||
script/script.cpp \
|
||||
script/script_error.cpp \
|
||||
script/sign.cpp \
|
||||
script/standard.cpp \
|
||||
$(BITCOIN_CORE_H)
|
||||
@@ -299,10 +314,9 @@ libbitcoin_util_a_SOURCES = \
|
||||
compat/glibcxx_sanity.cpp \
|
||||
compat/strnlen.cpp \
|
||||
random.cpp \
|
||||
rpcprotocol.cpp \
|
||||
rpc/protocol.cpp \
|
||||
support/cleanse.cpp \
|
||||
sync.cpp \
|
||||
uint256.cpp \
|
||||
util.cpp \
|
||||
utilmoneystr.cpp \
|
||||
utilstrencodings.cpp \
|
||||
@@ -317,7 +331,7 @@ endif
|
||||
libbitcoin_cli_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
|
||||
libbitcoin_cli_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
libbitcoin_cli_a_SOURCES = \
|
||||
rpcclient.cpp \
|
||||
rpc/client.cpp \
|
||||
$(BITCOIN_CORE_H)
|
||||
|
||||
nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h
|
||||
@@ -338,6 +352,7 @@ bitcoind_LDADD = \
|
||||
$(LIBBITCOIN_COMMON) \
|
||||
$(LIBUNIVALUE) \
|
||||
$(LIBBITCOIN_UTIL) \
|
||||
$(LIBBITCOIN_CONSENSUS) \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBLEVELDB) \
|
||||
$(LIBMEMENV) \
|
||||
@@ -385,6 +400,7 @@ bitcoin_tx_LDADD = \
|
||||
$(LIBUNIVALUE) \
|
||||
$(LIBBITCOIN_COMMON) \
|
||||
$(LIBBITCOIN_UTIL) \
|
||||
$(LIBBITCOIN_CONSENSUS) \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBSECP256K1)
|
||||
|
||||
@@ -394,20 +410,7 @@ bitcoin_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
|
||||
# bitcoinconsensus library #
|
||||
if BUILD_BITCOIN_LIBS
|
||||
include_HEADERS = script/bitcoinconsensus.h
|
||||
libbitcoinconsensus_la_SOURCES = \
|
||||
crypto/hmac_sha512.cpp \
|
||||
crypto/ripemd160.cpp \
|
||||
crypto/sha1.cpp \
|
||||
crypto/sha256.cpp \
|
||||
crypto/sha512.cpp \
|
||||
hash.cpp \
|
||||
primitives/transaction.cpp \
|
||||
pubkey.cpp \
|
||||
script/bitcoinconsensus.cpp \
|
||||
script/interpreter.cpp \
|
||||
script/script.cpp \
|
||||
uint256.cpp \
|
||||
utilstrencodings.cpp
|
||||
libbitcoinconsensus_la_SOURCES = $(crypto_libbitcoin_crypto_a_SOURCES) $(libbitcoin_consensus_a_SOURCES)
|
||||
|
||||
if GLIBC_BACK_COMPAT
|
||||
libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp
|
||||
@@ -455,6 +458,18 @@ clean-local:
|
||||
$(AM_V_CXX) $(OBJCXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CXXFLAGS) $(QT_INCLUDES) $(AM_CXXFLAGS) $(PIE_FLAGS) $(CXXFLAGS) -c -o $@ $<
|
||||
|
||||
check-symbols: $(bin_PROGRAMS)
|
||||
if GLIBC_BACK_COMPAT
|
||||
@echo "Checking glibc back compat..."
|
||||
$(AM_V_at) READELF=$(READELF) CPPFILT=$(CPPFILT) $(top_srcdir)/contrib/devtools/symbol-check.py < $(bin_PROGRAMS)
|
||||
endif
|
||||
|
||||
check-security: $(bin_PROGRAMS)
|
||||
if HARDEN
|
||||
@echo "Checking binary security..."
|
||||
$(AM_V_at) READELF=$(READELF) OBJDUMP=$(OBJDUMP) $(top_srcdir)/contrib/devtools/security-check.py < $(bin_PROGRAMS)
|
||||
endif
|
||||
|
||||
%.pb.cc %.pb.h: %.proto
|
||||
@test -f $(PROTOC)
|
||||
$(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(abspath $(<D) $<)
|
||||
|
||||
@@ -16,6 +16,7 @@ bench_bench_bitcoin_LDADD = \
|
||||
$(LIBBITCOIN_COMMON) \
|
||||
$(LIBBITCOIN_UNIVALUE) \
|
||||
$(LIBBITCOIN_UTIL) \
|
||||
$(LIBBITCOIN_CONSENSUS) \
|
||||
$(LIBBITCOIN_CRYPTO) \
|
||||
$(LIBLEVELDB) \
|
||||
$(LIBMEMENV) \
|
||||
|
||||
+15
-6
@@ -3,37 +3,41 @@ EXTRA_LIBRARIES += qt/libbitcoinqt.a
|
||||
|
||||
# bitcoin qt core #
|
||||
QT_TS = \
|
||||
qt/locale/bitcoin_ach.ts \
|
||||
qt/locale/bitcoin_af_ZA.ts \
|
||||
qt/locale/bitcoin_ar.ts \
|
||||
qt/locale/bitcoin_be_BY.ts \
|
||||
qt/locale/bitcoin_bg_BG.ts \
|
||||
qt/locale/bitcoin_bg.ts \
|
||||
qt/locale/bitcoin_bs.ts \
|
||||
qt/locale/bitcoin_ca_ES.ts \
|
||||
qt/locale/bitcoin_ca.ts \
|
||||
qt/locale/bitcoin_ca@valencia.ts \
|
||||
qt/locale/bitcoin_cmn.ts \
|
||||
qt/locale/bitcoin_cs_CZ.ts \
|
||||
qt/locale/bitcoin_cs.ts \
|
||||
qt/locale/bitcoin_cy.ts \
|
||||
qt/locale/bitcoin_da.ts \
|
||||
qt/locale/bitcoin_de.ts \
|
||||
qt/locale/bitcoin_el_GR.ts \
|
||||
qt/locale/bitcoin_el.ts \
|
||||
qt/locale/bitcoin_en_GB.ts \
|
||||
qt/locale/bitcoin_en.ts \
|
||||
qt/locale/bitcoin_eo.ts \
|
||||
qt/locale/bitcoin_es_CL.ts \
|
||||
qt/locale/bitcoin_es_DO.ts \
|
||||
qt/locale/bitcoin_es_ES.ts \
|
||||
qt/locale/bitcoin_es_MX.ts \
|
||||
qt/locale/bitcoin_es.ts \
|
||||
qt/locale/bitcoin_es_UY.ts \
|
||||
qt/locale/bitcoin_es_VE.ts \
|
||||
qt/locale/bitcoin_et.ts \
|
||||
qt/locale/bitcoin_eu_ES.ts \
|
||||
qt/locale/bitcoin_fa_IR.ts \
|
||||
qt/locale/bitcoin_fa.ts \
|
||||
qt/locale/bitcoin_fi.ts \
|
||||
qt/locale/bitcoin_fr_CA.ts \
|
||||
qt/locale/bitcoin_fr_FR.ts \
|
||||
qt/locale/bitcoin_fr.ts \
|
||||
qt/locale/bitcoin_gl.ts \
|
||||
qt/locale/bitcoin_gu_IN.ts \
|
||||
qt/locale/bitcoin_he.ts \
|
||||
qt/locale/bitcoin_hi_IN.ts \
|
||||
qt/locale/bitcoin_hr.ts \
|
||||
@@ -48,6 +52,7 @@ QT_TS = \
|
||||
qt/locale/bitcoin_la.ts \
|
||||
qt/locale/bitcoin_lt.ts \
|
||||
qt/locale/bitcoin_lv_LV.ts \
|
||||
qt/locale/bitcoin_mk_MK.ts \
|
||||
qt/locale/bitcoin_mn.ts \
|
||||
qt/locale/bitcoin_ms_MY.ts \
|
||||
qt/locale/bitcoin_nb.ts \
|
||||
@@ -57,14 +62,15 @@ QT_TS = \
|
||||
qt/locale/bitcoin_pt_BR.ts \
|
||||
qt/locale/bitcoin_pt_PT.ts \
|
||||
qt/locale/bitcoin_ro_RO.ts \
|
||||
qt/locale/bitcoin_ru_RU.ts \
|
||||
qt/locale/bitcoin_ru.ts \
|
||||
qt/locale/bitcoin_sah.ts \
|
||||
qt/locale/bitcoin_sk.ts \
|
||||
qt/locale/bitcoin_sl_SI.ts \
|
||||
qt/locale/bitcoin_sq.ts \
|
||||
qt/locale/bitcoin_sr.ts \
|
||||
qt/locale/bitcoin_sv.ts \
|
||||
qt/locale/bitcoin_th_TH.ts \
|
||||
qt/locale/bitcoin_tr_TR.ts \
|
||||
qt/locale/bitcoin_tr.ts \
|
||||
qt/locale/bitcoin_uk.ts \
|
||||
qt/locale/bitcoin_ur_PK.ts \
|
||||
@@ -72,7 +78,7 @@ QT_TS = \
|
||||
qt/locale/bitcoin_vi.ts \
|
||||
qt/locale/bitcoin_vi_VN.ts \
|
||||
qt/locale/bitcoin_zh_CN.ts \
|
||||
qt/locale/bitcoin_zh_HK.ts \
|
||||
qt/locale/bitcoin_zh.ts \
|
||||
qt/locale/bitcoin_zh_TW.ts
|
||||
|
||||
QT_FORMS_UI = \
|
||||
@@ -219,6 +225,7 @@ RES_ICONS = \
|
||||
qt/res/icons/about_qt.png \
|
||||
qt/res/icons/bitcoin.ico \
|
||||
qt/res/icons/bitcoin.png \
|
||||
qt/res/icons/chevron.png \
|
||||
qt/res/icons/clock1.png \
|
||||
qt/res/icons/clock2.png \
|
||||
qt/res/icons/clock3.png \
|
||||
@@ -239,6 +246,8 @@ RES_ICONS = \
|
||||
qt/res/icons/eye_minus.png \
|
||||
qt/res/icons/eye_plus.png \
|
||||
qt/res/icons/filesave.png \
|
||||
qt/res/icons/fontbigger.png \
|
||||
qt/res/icons/fontsmaller.png \
|
||||
qt/res/icons/history.png \
|
||||
qt/res/icons/info.png \
|
||||
qt/res/icons/key.png \
|
||||
@@ -369,7 +378,7 @@ endif
|
||||
if ENABLE_ZMQ
|
||||
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
|
||||
endif
|
||||
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
|
||||
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
|
||||
qt_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
|
||||
|
||||
@@ -33,7 +33,7 @@ endif
|
||||
if ENABLE_ZMQ
|
||||
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS)
|
||||
endif
|
||||
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \
|
||||
qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \
|
||||
$(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \
|
||||
$(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(LIBSECP256K1) \
|
||||
$(EVENT_PTHREADS_LIBS) $(EVENT_LIBS)
|
||||
|
||||
@@ -35,7 +35,7 @@ GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) $(RAW_TEST_FILES:.raw=.r
|
||||
|
||||
BITCOIN_TESTS =\
|
||||
test/arith_uint256_tests.cpp \
|
||||
test/bignum.h \
|
||||
test/scriptnum10.h \
|
||||
test/addrman_tests.cpp \
|
||||
test/alert_tests.cpp \
|
||||
test/allocator_tests.cpp \
|
||||
@@ -57,13 +57,14 @@ BITCOIN_TESTS =\
|
||||
test/dbwrapper_tests.cpp \
|
||||
test/main_tests.cpp \
|
||||
test/mempool_tests.cpp \
|
||||
test/merkle_tests.cpp \
|
||||
test/miner_tests.cpp \
|
||||
test/mruset_tests.cpp \
|
||||
test/multisig_tests.cpp \
|
||||
test/netbase_tests.cpp \
|
||||
test/pmt_tests.cpp \
|
||||
test/policyestimator_tests.cpp \
|
||||
test/pow_tests.cpp \
|
||||
test/prevector_tests.cpp \
|
||||
test/reverselock_tests.cpp \
|
||||
test/rpc_tests.cpp \
|
||||
test/sanity_tests.cpp \
|
||||
@@ -94,7 +95,7 @@ endif
|
||||
|
||||
test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES)
|
||||
test_test_bitcoin_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) -I$(builddir)/test/ $(TESTDEFS)
|
||||
test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \
|
||||
$(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) $(LIBSECP256K1)
|
||||
test_test_bitcoin_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
|
||||
if ENABLE_WALLET
|
||||
|
||||
+15
-10
@@ -1,4 +1,5 @@
|
||||
// Copyright (c) 2012 Pieter Wuille
|
||||
// Copyright (c) 2012-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -220,7 +221,7 @@ void CAddrMan::Good_(const CService& addr, int64_t nTime)
|
||||
return;
|
||||
|
||||
// find a bucket it is in now
|
||||
int nRnd = GetRandInt(ADDRMAN_NEW_BUCKET_COUNT);
|
||||
int nRnd = RandomInt(ADDRMAN_NEW_BUCKET_COUNT);
|
||||
int nUBucket = -1;
|
||||
for (unsigned int n = 0; n < ADDRMAN_NEW_BUCKET_COUNT; n++) {
|
||||
int nB = (n + nRnd) % ADDRMAN_NEW_BUCKET_COUNT;
|
||||
@@ -277,7 +278,7 @@ bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimeP
|
||||
int nFactor = 1;
|
||||
for (int n = 0; n < pinfo->nRefCount; n++)
|
||||
nFactor *= 2;
|
||||
if (nFactor > 1 && (GetRandInt(nFactor) != 0))
|
||||
if (nFactor > 1 && (RandomInt(nFactor) != 0))
|
||||
return false;
|
||||
} else {
|
||||
pinfo = Create(addr, source, &nId);
|
||||
@@ -339,12 +340,12 @@ CAddrInfo CAddrMan::Select_(bool newOnly)
|
||||
|
||||
// Use a 50% chance for choosing between tried and new table entries.
|
||||
if (!newOnly &&
|
||||
(nTried > 0 && (nNew == 0 || GetRandInt(2) == 0))) {
|
||||
(nTried > 0 && (nNew == 0 || RandomInt(2) == 0))) {
|
||||
// use a tried node
|
||||
double fChanceFactor = 1.0;
|
||||
while (1) {
|
||||
int nKBucket = GetRandInt(ADDRMAN_TRIED_BUCKET_COUNT);
|
||||
int nKBucketPos = GetRandInt(ADDRMAN_BUCKET_SIZE);
|
||||
int nKBucket = RandomInt(ADDRMAN_TRIED_BUCKET_COUNT);
|
||||
int nKBucketPos = RandomInt(ADDRMAN_BUCKET_SIZE);
|
||||
while (vvTried[nKBucket][nKBucketPos] == -1) {
|
||||
nKBucket = (nKBucket + insecure_rand()) % ADDRMAN_TRIED_BUCKET_COUNT;
|
||||
nKBucketPos = (nKBucketPos + insecure_rand()) % ADDRMAN_BUCKET_SIZE;
|
||||
@@ -352,7 +353,7 @@ CAddrInfo CAddrMan::Select_(bool newOnly)
|
||||
int nId = vvTried[nKBucket][nKBucketPos];
|
||||
assert(mapInfo.count(nId) == 1);
|
||||
CAddrInfo& info = mapInfo[nId];
|
||||
if (GetRandInt(1 << 30) < fChanceFactor * info.GetChance() * (1 << 30))
|
||||
if (RandomInt(1 << 30) < fChanceFactor * info.GetChance() * (1 << 30))
|
||||
return info;
|
||||
fChanceFactor *= 1.2;
|
||||
}
|
||||
@@ -360,8 +361,8 @@ CAddrInfo CAddrMan::Select_(bool newOnly)
|
||||
// use a new node
|
||||
double fChanceFactor = 1.0;
|
||||
while (1) {
|
||||
int nUBucket = GetRandInt(ADDRMAN_NEW_BUCKET_COUNT);
|
||||
int nUBucketPos = GetRandInt(ADDRMAN_BUCKET_SIZE);
|
||||
int nUBucket = RandomInt(ADDRMAN_NEW_BUCKET_COUNT);
|
||||
int nUBucketPos = RandomInt(ADDRMAN_BUCKET_SIZE);
|
||||
while (vvNew[nUBucket][nUBucketPos] == -1) {
|
||||
nUBucket = (nUBucket + insecure_rand()) % ADDRMAN_NEW_BUCKET_COUNT;
|
||||
nUBucketPos = (nUBucketPos + insecure_rand()) % ADDRMAN_BUCKET_SIZE;
|
||||
@@ -369,7 +370,7 @@ CAddrInfo CAddrMan::Select_(bool newOnly)
|
||||
int nId = vvNew[nUBucket][nUBucketPos];
|
||||
assert(mapInfo.count(nId) == 1);
|
||||
CAddrInfo& info = mapInfo[nId];
|
||||
if (GetRandInt(1 << 30) < fChanceFactor * info.GetChance() * (1 << 30))
|
||||
if (RandomInt(1 << 30) < fChanceFactor * info.GetChance() * (1 << 30))
|
||||
return info;
|
||||
fChanceFactor *= 1.2;
|
||||
}
|
||||
@@ -465,7 +466,7 @@ void CAddrMan::GetAddr_(std::vector<CAddress>& vAddr)
|
||||
if (vAddr.size() >= nNodes)
|
||||
break;
|
||||
|
||||
int nRndPos = GetRandInt(vRandom.size() - n) + n;
|
||||
int nRndPos = RandomInt(vRandom.size() - n) + n;
|
||||
SwapRandom(n, nRndPos);
|
||||
assert(mapInfo.count(vRandom[n]) == 1);
|
||||
|
||||
@@ -494,3 +495,7 @@ void CAddrMan::Connected_(const CService& addr, int64_t nTime)
|
||||
if (nTime - info.nTime > nUpdateInterval)
|
||||
info.nTime = nTime;
|
||||
}
|
||||
|
||||
int CAddrMan::RandomInt(int nMax){
|
||||
return GetRandInt(nMax);
|
||||
}
|
||||
|
||||
+6
-8
@@ -1,4 +1,5 @@
|
||||
// Copyright (c) 2012 Pieter Wuille
|
||||
// Copyright (c) 2012-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -175,9 +176,6 @@ private:
|
||||
//! critical section to protect the inner data structures
|
||||
mutable CCriticalSection cs;
|
||||
|
||||
//! secret key to randomize bucket select with
|
||||
uint256 nKey;
|
||||
|
||||
//! last used nId
|
||||
int nIdCount;
|
||||
|
||||
@@ -203,6 +201,8 @@ private:
|
||||
int vvNew[ADDRMAN_NEW_BUCKET_COUNT][ADDRMAN_BUCKET_SIZE];
|
||||
|
||||
protected:
|
||||
//! secret key to randomize bucket select with
|
||||
uint256 nKey;
|
||||
|
||||
//! Find an entry.
|
||||
CAddrInfo* Find(const CNetAddr& addr, int *pnId = NULL);
|
||||
@@ -235,6 +235,9 @@ protected:
|
||||
//! Select an address to connect to, if newOnly is set to true, only the new table is selected from.
|
||||
CAddrInfo Select_(bool newOnly);
|
||||
|
||||
//! Wraps GetRandInt to allow tests to override RandomInt and make it determinismistic.
|
||||
virtual int RandomInt(int nMax);
|
||||
|
||||
#ifdef DEBUG_ADDRMAN
|
||||
//! Perform consistency check. Returns an error code or zero.
|
||||
int Check_();
|
||||
@@ -569,11 +572,6 @@ public:
|
||||
Check();
|
||||
}
|
||||
}
|
||||
|
||||
//! Ensure that bucket placement is always the same for testing purposes.
|
||||
void MakeDeterministic(){
|
||||
nKey.SetNull(); //Do not use outside of tests.
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -138,7 +138,7 @@ bool CAlert::RelayTo(CNode* pnode) const
|
||||
AppliesToMe() ||
|
||||
GetAdjustedTime() < nRelayUntil)
|
||||
{
|
||||
pnode->PushMessage("alert", *this);
|
||||
pnode->PushMessage(NetMsgType::ALERT, *this);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -30,7 +30,7 @@ extern const std::string CURRENCY_UNIT;
|
||||
static const CAmount MAX_MONEY = 21000000 * COIN;
|
||||
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
|
||||
|
||||
/** Type-safe wrapper class to for fee rates
|
||||
/** Type-safe wrapper class for fee rates
|
||||
* (how much to pay based on transaction size)
|
||||
*/
|
||||
class CFeeRate
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2014-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+8
-7
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
|
||||
#include "chainparamsbase.h"
|
||||
#include "clientversion.h"
|
||||
#include "rpcclient.h"
|
||||
#include "rpcprotocol.h"
|
||||
#include "rpc/client.h"
|
||||
#include "rpc/protocol.h"
|
||||
#include "util.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
static const char DEFAULT_RPCCONNECT[] = "127.0.0.1";
|
||||
static const int DEFAULT_HTTP_CLIENT_TIMEOUT=900;
|
||||
|
||||
std::string HelpMessageCli()
|
||||
@@ -33,11 +34,11 @@ std::string HelpMessageCli()
|
||||
string strUsage;
|
||||
strUsage += HelpMessageGroup(_("Options:"));
|
||||
strUsage += HelpMessageOpt("-?", _("This help message"));
|
||||
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "bitcoin.conf"));
|
||||
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), BITCOIN_CONF_FILENAME));
|
||||
strUsage += HelpMessageOpt("-datadir=<dir>", _("Specify data directory"));
|
||||
AppendParamsHelpMessages(strUsage);
|
||||
strUsage += HelpMessageOpt("-rpcconnect=<ip>", strprintf(_("Send commands to node running on <ip> (default: %s)"), "127.0.0.1"));
|
||||
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Connect to JSON-RPC on <port> (default: %u or testnet: %u)"), 8332, 18332));
|
||||
strUsage += HelpMessageOpt("-rpcconnect=<ip>", strprintf(_("Send commands to node running on <ip> (default: %s)"), DEFAULT_RPCCONNECT));
|
||||
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Connect to JSON-RPC on <port> (default: %u or testnet: %u)"), BaseParams(CBaseChainParams::MAIN).RPCPort(), BaseParams(CBaseChainParams::TESTNET).RPCPort()));
|
||||
strUsage += HelpMessageOpt("-rpcwait", _("Wait for RPC server to start"));
|
||||
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
|
||||
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
|
||||
@@ -145,7 +146,7 @@ static void http_request_done(struct evhttp_request *req, void *ctx)
|
||||
|
||||
UniValue CallRPC(const string& strMethod, const UniValue& params)
|
||||
{
|
||||
std::string host = GetArg("-rpcconnect", "127.0.0.1");
|
||||
std::string host = GetArg("-rpcconnect", DEFAULT_RPCCONNECT);
|
||||
int port = GetArg("-rpcport", BaseParams().RPCPort());
|
||||
|
||||
// Create event base
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+5
-3
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -9,14 +9,13 @@
|
||||
|
||||
#include "chainparams.h"
|
||||
#include "clientversion.h"
|
||||
#include "rpcserver.h"
|
||||
#include "rpc/server.h"
|
||||
#include "init.h"
|
||||
#include "noui.h"
|
||||
#include "scheduler.h"
|
||||
#include "util.h"
|
||||
#include "httpserver.h"
|
||||
#include "httprpc.h"
|
||||
#include "rpcserver.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
@@ -156,6 +155,9 @@ bool AppInit(int argc, char* argv[])
|
||||
#endif
|
||||
SoftSetBoolArg("-server", true);
|
||||
|
||||
// Set this early so that parameter interactions go to console
|
||||
InitLogging();
|
||||
InitParameterInteraction();
|
||||
fRet = AppInit2(threadGroup, scheduler);
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
|
||||
+54
-25
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2012-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2012-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -216,30 +216,54 @@ void CBloomFilter::UpdateEmptyFull()
|
||||
isEmpty = empty;
|
||||
}
|
||||
|
||||
CRollingBloomFilter::CRollingBloomFilter(unsigned int nElements, double fpRate) :
|
||||
b1(nElements * 2, fpRate, 0), b2(nElements * 2, fpRate, 0)
|
||||
CRollingBloomFilter::CRollingBloomFilter(unsigned int nElements, double fpRate)
|
||||
{
|
||||
// Implemented using two bloom filters of 2 * nElements each.
|
||||
// We fill them up, and clear them, staggered, every nElements
|
||||
// inserted, so at least one always contains the last nElements
|
||||
// inserted.
|
||||
nInsertions = 0;
|
||||
nBloomSize = nElements * 2;
|
||||
|
||||
double logFpRate = log(fpRate);
|
||||
/* The optimal number of hash functions is log(fpRate) / log(0.5), but
|
||||
* restrict it to the range 1-50. */
|
||||
nHashFuncs = std::max(1, std::min((int)round(logFpRate / log(0.5)), 50));
|
||||
/* In this rolling bloom filter, we'll store between 2 and 3 generations of nElements / 2 entries. */
|
||||
nEntriesPerGeneration = (nElements + 1) / 2;
|
||||
uint32_t nMaxElements = nEntriesPerGeneration * 3;
|
||||
/* The maximum fpRate = pow(1.0 - exp(-nHashFuncs * nMaxElements / nFilterBits), nHashFuncs)
|
||||
* => pow(fpRate, 1.0 / nHashFuncs) = 1.0 - exp(-nHashFuncs * nMaxElements / nFilterBits)
|
||||
* => 1.0 - pow(fpRate, 1.0 / nHashFuncs) = exp(-nHashFuncs * nMaxElements / nFilterBits)
|
||||
* => log(1.0 - pow(fpRate, 1.0 / nHashFuncs)) = -nHashFuncs * nMaxElements / nFilterBits
|
||||
* => nFilterBits = -nHashFuncs * nMaxElements / log(1.0 - pow(fpRate, 1.0 / nHashFuncs))
|
||||
* => nFilterBits = -nHashFuncs * nMaxElements / log(1.0 - exp(logFpRate / nHashFuncs))
|
||||
*/
|
||||
uint32_t nFilterBits = (uint32_t)ceil(-1.0 * nHashFuncs * nMaxElements / log(1.0 - exp(logFpRate / nHashFuncs)));
|
||||
data.clear();
|
||||
/* We store up to 16 'bits' per data element. */
|
||||
data.resize((nFilterBits + 15) / 16);
|
||||
reset();
|
||||
}
|
||||
|
||||
/* Similar to CBloomFilter::Hash */
|
||||
inline unsigned int CRollingBloomFilter::Hash(unsigned int nHashNum, const std::vector<unsigned char>& vDataToHash) const {
|
||||
return MurmurHash3(nHashNum * 0xFBA4C795 + nTweak, vDataToHash) % (data.size() * 16);
|
||||
}
|
||||
|
||||
void CRollingBloomFilter::insert(const std::vector<unsigned char>& vKey)
|
||||
{
|
||||
if (nInsertions == 0) {
|
||||
b1.clear();
|
||||
} else if (nInsertions == nBloomSize / 2) {
|
||||
b2.clear();
|
||||
if (nEntriesThisGeneration == nEntriesPerGeneration) {
|
||||
nEntriesThisGeneration = 0;
|
||||
nGeneration++;
|
||||
if (nGeneration == 4) {
|
||||
nGeneration = 1;
|
||||
}
|
||||
/* Wipe old entries that used this generation number. */
|
||||
for (uint32_t p = 0; p < data.size() * 16; p++) {
|
||||
if (get(p) == nGeneration) {
|
||||
put(p, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
b1.insert(vKey);
|
||||
b2.insert(vKey);
|
||||
if (++nInsertions == nBloomSize) {
|
||||
nInsertions = 0;
|
||||
nEntriesThisGeneration++;
|
||||
|
||||
for (int n = 0; n < nHashFuncs; n++) {
|
||||
uint32_t h = Hash(n, vKey);
|
||||
put(h, nGeneration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,10 +275,13 @@ void CRollingBloomFilter::insert(const uint256& hash)
|
||||
|
||||
bool CRollingBloomFilter::contains(const std::vector<unsigned char>& vKey) const
|
||||
{
|
||||
if (nInsertions < nBloomSize / 2) {
|
||||
return b2.contains(vKey);
|
||||
for (int n = 0; n < nHashFuncs; n++) {
|
||||
uint32_t h = Hash(n, vKey);
|
||||
if (get(h) == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return b1.contains(vKey);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CRollingBloomFilter::contains(const uint256& hash) const
|
||||
@@ -265,8 +292,10 @@ bool CRollingBloomFilter::contains(const uint256& hash) const
|
||||
|
||||
void CRollingBloomFilter::reset()
|
||||
{
|
||||
unsigned int nNewTweak = GetRand(std::numeric_limits<unsigned int>::max());
|
||||
b1.reset(nNewTweak);
|
||||
b2.reset(nNewTweak);
|
||||
nInsertions = 0;
|
||||
nTweak = GetRand(std::numeric_limits<unsigned int>::max());
|
||||
nEntriesThisGeneration = 0;
|
||||
nGeneration = 1;
|
||||
for (std::vector<uint32_t>::iterator it = data.begin(); it != data.end(); it++) {
|
||||
*it = 0;
|
||||
}
|
||||
}
|
||||
|
||||
+22
-6
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2012-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2012-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -110,8 +110,11 @@ public:
|
||||
* reset() is provided, which also changes nTweak to decrease the impact of
|
||||
* false-positives.
|
||||
*
|
||||
* contains(item) will always return true if item was one of the last N things
|
||||
* contains(item) will always return true if item was one of the last N to 1.5*N
|
||||
* insert()'ed ... but may also return true for items that were not inserted.
|
||||
*
|
||||
* It needs around 1.8 bytes per element per factor 0.1 of false positive rate.
|
||||
* (More accurately: 3/(log(256)*log(2)) * log(1/fpRate) * nElements bytes)
|
||||
*/
|
||||
class CRollingBloomFilter
|
||||
{
|
||||
@@ -129,10 +132,23 @@ public:
|
||||
void reset();
|
||||
|
||||
private:
|
||||
unsigned int nBloomSize;
|
||||
unsigned int nInsertions;
|
||||
CBloomFilter b1, b2;
|
||||
int nEntriesPerGeneration;
|
||||
int nEntriesThisGeneration;
|
||||
int nGeneration;
|
||||
std::vector<uint32_t> data;
|
||||
unsigned int nTweak;
|
||||
int nHashFuncs;
|
||||
|
||||
unsigned int Hash(unsigned int nHashNum, const std::vector<unsigned char>& vDataToHash) const;
|
||||
|
||||
inline int get(uint32_t position) const {
|
||||
return (data[(position >> 4) % data.size()] >> (2 * (position & 0xF))) & 0x3;
|
||||
}
|
||||
|
||||
inline void put(uint32_t position, uint32_t val) {
|
||||
uint32_t& cell = data[(position >> 4) % data.size()];
|
||||
cell = (cell & ~(((uint32_t)3) << (2 * (position & 0xF)))) | (val << (2 * (position & 0xF)));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // BITCOIN_BLOOM_H
|
||||
|
||||
@@ -51,6 +51,9 @@ CBlockLocator CChain::GetLocator(const CBlockIndex *pindex) const {
|
||||
}
|
||||
|
||||
const CBlockIndex *CChain::FindFork(const CBlockIndex *pindex) const {
|
||||
if (pindex == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (pindex->nHeight > Height())
|
||||
pindex = pindex->GetAncestor(Height());
|
||||
while (pindex && !Contains(pindex))
|
||||
@@ -107,3 +110,35 @@ void CBlockIndex::BuildSkip()
|
||||
if (pprev)
|
||||
pskip = pprev->GetAncestor(GetSkipHeight(nHeight));
|
||||
}
|
||||
|
||||
arith_uint256 GetBlockProof(const CBlockIndex& block)
|
||||
{
|
||||
arith_uint256 bnTarget;
|
||||
bool fNegative;
|
||||
bool fOverflow;
|
||||
bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow);
|
||||
if (fNegative || fOverflow || bnTarget == 0)
|
||||
return 0;
|
||||
// We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256
|
||||
// as it's too large for a arith_uint256. However, as 2**256 is at least as large
|
||||
// as bnTarget+1, it is equal to ((2**256 - bnTarget - 1) / (bnTarget+1)) + 1,
|
||||
// or ~bnTarget / (nTarget+1) + 1.
|
||||
return (~bnTarget / (bnTarget + 1)) + 1;
|
||||
}
|
||||
|
||||
int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params)
|
||||
{
|
||||
arith_uint256 r;
|
||||
int sign = 1;
|
||||
if (to.nChainWork > from.nChainWork) {
|
||||
r = to.nChainWork - from.nChainWork;
|
||||
} else {
|
||||
r = from.nChainWork - to.nChainWork;
|
||||
sign = -1;
|
||||
}
|
||||
r = r * arith_uint256(params.nPowTargetSpacing) / GetBlockProof(tip);
|
||||
if (r.bits() > 63) {
|
||||
return sign * std::numeric_limits<int64_t>::max();
|
||||
}
|
||||
return sign * r.GetLow64();
|
||||
}
|
||||
|
||||
+5
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -282,6 +282,10 @@ public:
|
||||
const CBlockIndex* GetAncestor(int height) const;
|
||||
};
|
||||
|
||||
arith_uint256 GetBlockProof(const CBlockIndex& block);
|
||||
/** Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds. */
|
||||
int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params&);
|
||||
|
||||
/** Used to marshal pointers into hashes for db storage. */
|
||||
class CDiskBlockIndex : public CBlockIndex
|
||||
{
|
||||
|
||||
+3
-6
@@ -1,9 +1,10 @@
|
||||
// Copyright (c) 2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "chainparams.h"
|
||||
#include "consensus/merkle.h"
|
||||
|
||||
#include "tinyformat.h"
|
||||
#include "util.h"
|
||||
@@ -32,7 +33,7 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi
|
||||
genesis.nVersion = nVersion;
|
||||
genesis.vtx.push_back(txNew);
|
||||
genesis.hashPrevBlock.SetNull();
|
||||
genesis.hashMerkleRoot = genesis.ComputeMerkleRoot();
|
||||
genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
|
||||
return genesis;
|
||||
}
|
||||
|
||||
@@ -91,7 +92,6 @@ public:
|
||||
pchMessageStart[3] = 0xd9;
|
||||
vAlertPubKey = ParseHex("04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284");
|
||||
nDefaultPort = 8333;
|
||||
nMaxTipAge = 24 * 60 * 60;
|
||||
nPruneAfterHeight = 100000;
|
||||
|
||||
genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
|
||||
@@ -168,7 +168,6 @@ public:
|
||||
pchMessageStart[3] = 0x07;
|
||||
vAlertPubKey = ParseHex("04302390343f91cc401d56d68b123028bf52e5fca1939df127f63c6467cdf9c8e2c14b61104cf817d0b780da337893ecc4aaff1309e536162dabbdb45200ca2b0a");
|
||||
nDefaultPort = 18333;
|
||||
nMaxTipAge = 0x7fffffff;
|
||||
nPruneAfterHeight = 1000;
|
||||
|
||||
genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN);
|
||||
@@ -178,7 +177,6 @@ public:
|
||||
|
||||
vFixedSeeds.clear();
|
||||
vSeeds.clear();
|
||||
vSeeds.push_back(CDNSSeedData("alexykot.me", "testnet-seed.alexykot.me"));
|
||||
vSeeds.push_back(CDNSSeedData("bitcoin.petertodd.org", "testnet-seed.bitcoin.petertodd.org"));
|
||||
vSeeds.push_back(CDNSSeedData("bluematt.me", "testnet-seed.bluematt.me"));
|
||||
vSeeds.push_back(CDNSSeedData("bitcoin.schildbach.de", "testnet-seed.bitcoin.schildbach.de"));
|
||||
@@ -232,7 +230,6 @@ public:
|
||||
pchMessageStart[1] = 0xbf;
|
||||
pchMessageStart[2] = 0xb5;
|
||||
pchMessageStart[3] = 0xda;
|
||||
nMaxTipAge = 24 * 60 * 60;
|
||||
nDefaultPort = 18444;
|
||||
nPruneAfterHeight = 1000;
|
||||
|
||||
|
||||
+2
-4
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -64,8 +64,7 @@ public:
|
||||
bool DefaultConsistencyChecks() const { return fDefaultConsistencyChecks; }
|
||||
/** Policy: Filter transactions that do not match well-defined patterns */
|
||||
bool RequireStandard() const { return fRequireStandard; }
|
||||
int64_t MaxTipAge() const { return nMaxTipAge; }
|
||||
int64_t PruneAfterHeight() const { return nPruneAfterHeight; }
|
||||
uint64_t PruneAfterHeight() const { return nPruneAfterHeight; }
|
||||
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
|
||||
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
|
||||
/** In the future use NetworkIDString() for RPC fields */
|
||||
@@ -84,7 +83,6 @@ protected:
|
||||
//! Raw pub key bytes for the broadcast alert signing key.
|
||||
std::vector<unsigned char> vAlertPubKey;
|
||||
int nDefaultPort;
|
||||
long nMaxTipAge;
|
||||
uint64_t nPruneAfterHeight;
|
||||
std::vector<CDNSSeedData> vSeeds;
|
||||
std::vector<unsigned char> base58Prefixes[MAX_BASE58_TYPES];
|
||||
|
||||
+10
-18
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -65,19 +65,6 @@ public:
|
||||
};
|
||||
static CBaseRegTestParams regTestParams;
|
||||
|
||||
/*
|
||||
* Unit test
|
||||
*/
|
||||
class CBaseUnitTestParams : public CBaseMainParams
|
||||
{
|
||||
public:
|
||||
CBaseUnitTestParams()
|
||||
{
|
||||
strDataDir = "unittest";
|
||||
}
|
||||
};
|
||||
static CBaseUnitTestParams unitTestParams;
|
||||
|
||||
static CBaseChainParams* pCurrentBaseParams = 0;
|
||||
|
||||
const CBaseChainParams& BaseParams()
|
||||
@@ -86,18 +73,23 @@ const CBaseChainParams& BaseParams()
|
||||
return *pCurrentBaseParams;
|
||||
}
|
||||
|
||||
void SelectBaseParams(const std::string& chain)
|
||||
CBaseChainParams& BaseParams(const std::string& chain)
|
||||
{
|
||||
if (chain == CBaseChainParams::MAIN)
|
||||
pCurrentBaseParams = &mainParams;
|
||||
return mainParams;
|
||||
else if (chain == CBaseChainParams::TESTNET)
|
||||
pCurrentBaseParams = &testNetParams;
|
||||
return testNetParams;
|
||||
else if (chain == CBaseChainParams::REGTEST)
|
||||
pCurrentBaseParams = ®TestParams;
|
||||
return regTestParams;
|
||||
else
|
||||
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
||||
}
|
||||
|
||||
void SelectBaseParams(const std::string& chain)
|
||||
{
|
||||
pCurrentBaseParams = &BaseParams(chain);
|
||||
}
|
||||
|
||||
std::string ChainNameFromCommandLine()
|
||||
{
|
||||
bool fRegTest = GetBoolArg("-regtest", false);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2014-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -42,6 +42,8 @@ void AppendParamsHelpMessages(std::string& strUsage, bool debugHelp=true);
|
||||
*/
|
||||
const CBaseChainParams& BaseParams();
|
||||
|
||||
CBaseChainParams& BaseParams(const std::string& chain);
|
||||
|
||||
/** Sets the params returned by Params() to those for the given network. */
|
||||
void SelectBaseParams(const std::string& chain);
|
||||
|
||||
|
||||
+747
-689
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2012-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2012-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
//! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it
|
||||
#define CLIENT_VERSION_MAJOR 0
|
||||
#define CLIENT_VERSION_MINOR 11
|
||||
#define CLIENT_VERSION_MINOR 12
|
||||
#define CLIENT_VERSION_REVISION 99
|
||||
#define CLIENT_VERSION_BUILD 0
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* Copyright year (2009-this)
|
||||
* Todo: update this when changing our copyright comments in the source
|
||||
*/
|
||||
#define COPYRIGHT_YEAR 2015
|
||||
#define COPYRIGHT_YEAR 2016
|
||||
|
||||
#endif //HAVE_CONFIG_H
|
||||
|
||||
|
||||
+4
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -16,6 +16,8 @@ public:
|
||||
bool fAllowOtherInputs;
|
||||
//! Includes watch only addresses which match the ISMINE_WATCH_SOLVABLE criteria
|
||||
bool fAllowWatchOnly;
|
||||
//! Minimum absolute fee (not per kilobyte)
|
||||
CAmount nMinimumTotalFee;
|
||||
|
||||
CCoinControl()
|
||||
{
|
||||
@@ -28,6 +30,7 @@ public:
|
||||
fAllowOtherInputs = false;
|
||||
fAllowWatchOnly = false;
|
||||
setSelected.clear();
|
||||
nMinimumTotalFee = 0;
|
||||
}
|
||||
|
||||
bool HasSelected() const
|
||||
|
||||
+39
-12
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2012-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2012-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -117,11 +117,17 @@ CCoinsModifier CCoinsViewCache::ModifyCoins(const uint256 &txid) {
|
||||
return CCoinsModifier(*this, ret.first, cachedCoinUsage);
|
||||
}
|
||||
|
||||
CCoinsModifier CCoinsViewCache::ModifyNewCoins(const uint256 &txid) {
|
||||
// ModifyNewCoins has to know whether the new outputs its creating are for a
|
||||
// coinbase or not. If they are for a coinbase, it can not mark them as fresh.
|
||||
// This is to ensure that the historical duplicate coinbases before BIP30 was
|
||||
// in effect will still be properly overwritten when spent.
|
||||
CCoinsModifier CCoinsViewCache::ModifyNewCoins(const uint256 &txid, bool coinbase) {
|
||||
assert(!hasModifier);
|
||||
std::pair<CCoinsMap::iterator, bool> ret = cacheCoins.insert(std::make_pair(txid, CCoinsCacheEntry()));
|
||||
ret.first->second.coins.Clear();
|
||||
ret.first->second.flags = CCoinsCacheEntry::FRESH;
|
||||
if (!coinbase) {
|
||||
ret.first->second.flags = CCoinsCacheEntry::FRESH;
|
||||
}
|
||||
ret.first->second.flags |= CCoinsCacheEntry::DIRTY;
|
||||
return CCoinsModifier(*this, ret.first, 0);
|
||||
}
|
||||
@@ -144,6 +150,11 @@ bool CCoinsViewCache::HaveCoins(const uint256 &txid) const {
|
||||
return (it != cacheCoins.end() && !it->second.coins.vout.empty());
|
||||
}
|
||||
|
||||
bool CCoinsViewCache::HaveCoinsInCache(const uint256 &txid) const {
|
||||
CCoinsMap::const_iterator it = cacheCoins.find(txid);
|
||||
return it != cacheCoins.end();
|
||||
}
|
||||
|
||||
uint256 CCoinsViewCache::GetBestBlock() const {
|
||||
if (hashBlock.IsNull())
|
||||
hashBlock = base->GetBestBlock();
|
||||
@@ -160,18 +171,23 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn
|
||||
if (it->second.flags & CCoinsCacheEntry::DIRTY) { // Ignore non-dirty entries (optimization).
|
||||
CCoinsMap::iterator itUs = cacheCoins.find(it->first);
|
||||
if (itUs == cacheCoins.end()) {
|
||||
if (!it->second.coins.IsPruned()) {
|
||||
// The parent cache does not have an entry, while the child
|
||||
// cache does have (a non-pruned) one. Move the data up, and
|
||||
// mark it as fresh (if the grandparent did have it, we
|
||||
// would have pulled it in at first GetCoins).
|
||||
assert(it->second.flags & CCoinsCacheEntry::FRESH);
|
||||
// The parent cache does not have an entry, while the child does
|
||||
// We can ignore it if it's both FRESH and pruned in the child
|
||||
if (!(it->second.flags & CCoinsCacheEntry::FRESH && it->second.coins.IsPruned())) {
|
||||
// Otherwise we will need to create it in the parent
|
||||
// and move the data up and mark it as dirty
|
||||
CCoinsCacheEntry& entry = cacheCoins[it->first];
|
||||
entry.coins.swap(it->second.coins);
|
||||
cachedCoinsUsage += entry.coins.DynamicMemoryUsage();
|
||||
entry.flags = CCoinsCacheEntry::DIRTY | CCoinsCacheEntry::FRESH;
|
||||
entry.flags = CCoinsCacheEntry::DIRTY;
|
||||
// We can mark it FRESH in the parent if it was FRESH in the child
|
||||
// Otherwise it might have just been flushed from the parent's cache
|
||||
// and already exist in the grandparent
|
||||
if (it->second.flags & CCoinsCacheEntry::FRESH)
|
||||
entry.flags |= CCoinsCacheEntry::FRESH;
|
||||
}
|
||||
} else {
|
||||
// Found the entry in the parent cache
|
||||
if ((itUs->second.flags & CCoinsCacheEntry::FRESH) && it->second.coins.IsPruned()) {
|
||||
// The grandparent does not have an entry, and the child is
|
||||
// modified and being pruned. This means we can just delete
|
||||
@@ -201,6 +217,15 @@ bool CCoinsViewCache::Flush() {
|
||||
return fOk;
|
||||
}
|
||||
|
||||
void CCoinsViewCache::Uncache(const uint256& hash)
|
||||
{
|
||||
CCoinsMap::iterator it = cacheCoins.find(hash);
|
||||
if (it != cacheCoins.end() && it->second.flags == 0) {
|
||||
cachedCoinsUsage -= it->second.coins.DynamicMemoryUsage();
|
||||
cacheCoins.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int CCoinsViewCache::GetCacheSize() const {
|
||||
return cacheCoins.size();
|
||||
}
|
||||
@@ -238,8 +263,9 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const
|
||||
return true;
|
||||
}
|
||||
|
||||
double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight) const
|
||||
double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight, CAmount &inChainInputValue) const
|
||||
{
|
||||
inChainInputValue = 0;
|
||||
if (tx.IsCoinBase())
|
||||
return 0.0;
|
||||
double dResult = 0.0;
|
||||
@@ -248,8 +274,9 @@ double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight) const
|
||||
const CCoins* coins = AccessCoins(txin.prevout.hash);
|
||||
assert(coins);
|
||||
if (!coins->IsAvailable(txin.prevout.n)) continue;
|
||||
if (coins->nHeight < nHeight) {
|
||||
if (coins->nHeight <= nHeight) {
|
||||
dResult += coins->vout[txin.prevout.n].nValue * (nHeight-coins->nHeight);
|
||||
inChainInputValue += coins->vout[txin.prevout.n].nValue;
|
||||
}
|
||||
}
|
||||
return tx.ComputePriority(dResult);
|
||||
|
||||
+26
-9
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
* - VARINT(nHeight)
|
||||
*
|
||||
* The nCode value consists of:
|
||||
* - bit 1: IsCoinBase()
|
||||
* - bit 2: vout[0] is not spent
|
||||
* - bit 4: vout[1] is not spent
|
||||
* - bit 0: IsCoinBase()
|
||||
* - bit 1: vout[0] is not spent
|
||||
* - bit 2: vout[1] is not spent
|
||||
* - The higher bits encode N, the number of non-zero bytes in the following bitvector.
|
||||
* - In case both bit 2 and bit 4 are unset, they encode N-1, as there must be at
|
||||
* - In case both bit 1 and bit 2 are unset, they encode N-1, as there must be at
|
||||
* least one non-spent output).
|
||||
*
|
||||
* Example: 0104835800816115944e077fe7c803cfa57f29b36bf87c1d358bb85e
|
||||
@@ -58,7 +58,7 @@
|
||||
*
|
||||
* - version = 1
|
||||
* - code = 9 (coinbase, neither vout[0] or vout[1] are unspent,
|
||||
* 2 (1, +1 because both bit 2 and bit 4 are unset) non-zero bitvector bytes follow)
|
||||
* 2 (1, +1 because both bit 1 and bit 2 are unset) non-zero bitvector bytes follow)
|
||||
* - unspentness bitvector: bits 2 (0x04) and 14 (0x4000) are set, so vout[2+2] and vout[14+2] are unspent
|
||||
* - vout[4]: 86ef97d5790061b01caab50f1b8e9c50a5057eb43c2d9563a4ee
|
||||
* * 86ef97d579: compact amount representation for 234925952 (2.35 BTC)
|
||||
@@ -405,6 +405,13 @@ public:
|
||||
void SetBestBlock(const uint256 &hashBlock);
|
||||
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock);
|
||||
|
||||
/**
|
||||
* Check if we have the given tx already loaded in this cache.
|
||||
* The semantics are the same as HaveCoins(), but no calls to
|
||||
* the backing CCoinsView are made.
|
||||
*/
|
||||
bool HaveCoinsInCache(const uint256 &txid) const;
|
||||
|
||||
/**
|
||||
* Return a pointer to CCoins in the cache, or NULL if not found. This is
|
||||
* more efficient than GetCoins. Modifications to other cache entries are
|
||||
@@ -428,7 +435,7 @@ public:
|
||||
* would not properly overwrite the first coinbase of the pair. Simultaneous modifications
|
||||
* are not allowed.
|
||||
*/
|
||||
CCoinsModifier ModifyNewCoins(const uint256 &txid);
|
||||
CCoinsModifier ModifyNewCoins(const uint256 &txid, bool coinbase);
|
||||
|
||||
/**
|
||||
* Push the modifications applied to this cache to its base.
|
||||
@@ -437,6 +444,12 @@ public:
|
||||
*/
|
||||
bool Flush();
|
||||
|
||||
/**
|
||||
* Removes the transaction with the given hash from the cache, if it is
|
||||
* not modified.
|
||||
*/
|
||||
void Uncache(const uint256 &txid);
|
||||
|
||||
//! Calculate the size of the cache (in number of transactions)
|
||||
unsigned int GetCacheSize() const;
|
||||
|
||||
@@ -456,8 +469,12 @@ public:
|
||||
//! Check whether all prevouts of the transaction are present in the UTXO set represented by this view
|
||||
bool HaveInputs(const CTransaction& tx) const;
|
||||
|
||||
//! Return priority of tx at height nHeight
|
||||
double GetPriority(const CTransaction &tx, int nHeight) const;
|
||||
/**
|
||||
* Return priority of tx at height nHeight. Also calculate the sum of the values of the inputs
|
||||
* that are already in the chain. These are the inputs that will age and increase priority as
|
||||
* new blocks are added to the chain.
|
||||
*/
|
||||
double GetPriority(const CTransaction &tx, int nHeight, CAmount &inChainInputValue) const;
|
||||
|
||||
const CTxOut &GetOutputFor(const CTxIn& input) const;
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2014 The Bitcoin developers
|
||||
// Copyright (c) 2014-2015 The Bitcoin developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
// Copyright (c) 2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "merkle.h"
|
||||
#include "hash.h"
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
/* WARNING! If you're reading this because you're learning about crypto
|
||||
and/or designing a new system that will use merkle trees, keep in mind
|
||||
that the following merkle tree algorithm has a serious flaw related to
|
||||
duplicate txids, resulting in a vulnerability (CVE-2012-2459).
|
||||
|
||||
The reason is that if the number of hashes in the list at a given time
|
||||
is odd, the last one is duplicated before computing the next level (which
|
||||
is unusual in Merkle trees). This results in certain sequences of
|
||||
transactions leading to the same merkle root. For example, these two
|
||||
trees:
|
||||
|
||||
A A
|
||||
/ \ / \
|
||||
B C B C
|
||||
/ \ | / \ / \
|
||||
D E F D E F F
|
||||
/ \ / \ / \ / \ / \ / \ / \
|
||||
1 2 3 4 5 6 1 2 3 4 5 6 5 6
|
||||
|
||||
for transaction lists [1,2,3,4,5,6] and [1,2,3,4,5,6,5,6] (where 5 and
|
||||
6 are repeated) result in the same root hash A (because the hash of both
|
||||
of (F) and (F,F) is C).
|
||||
|
||||
The vulnerability results from being able to send a block with such a
|
||||
transaction list, with the same merkle root, and the same block hash as
|
||||
the original without duplication, resulting in failed validation. If the
|
||||
receiving node proceeds to mark that block as permanently invalid
|
||||
however, it will fail to accept further unmodified (and thus potentially
|
||||
valid) versions of the same block. We defend against this by detecting
|
||||
the case where we would hash two identical hashes at the end of the list
|
||||
together, and treating that identically to the block having an invalid
|
||||
merkle root. Assuming no double-SHA256 collisions, this will detect all
|
||||
known ways of changing the transactions without affecting the merkle
|
||||
root.
|
||||
*/
|
||||
|
||||
/* This implements a constant-space merkle root/path calculator, limited to 2^32 leaves. */
|
||||
static void MerkleComputation(const std::vector<uint256>& leaves, uint256* proot, bool* pmutated, uint32_t branchpos, std::vector<uint256>* pbranch) {
|
||||
if (pbranch) pbranch->clear();
|
||||
if (leaves.size() == 0) {
|
||||
if (pmutated) *pmutated = false;
|
||||
if (proot) *proot = uint256();
|
||||
return;
|
||||
}
|
||||
bool mutated = false;
|
||||
// count is the number of leaves processed so far.
|
||||
uint32_t count = 0;
|
||||
// inner is an array of eagerly computed subtree hashes, indexed by tree
|
||||
// level (0 being the leaves).
|
||||
// For example, when count is 25 (11001 in binary), inner[4] is the hash of
|
||||
// the first 16 leaves, inner[3] of the next 8 leaves, and inner[0] equal to
|
||||
// the last leaf. The other inner entries are undefined.
|
||||
uint256 inner[32];
|
||||
// Which position in inner is a hash that depends on the matching leaf.
|
||||
int matchlevel = -1;
|
||||
// First process all leaves into 'inner' values.
|
||||
while (count < leaves.size()) {
|
||||
uint256 h = leaves[count];
|
||||
bool matchh = count == branchpos;
|
||||
count++;
|
||||
int level;
|
||||
// For each of the lower bits in count that are 0, do 1 step. Each
|
||||
// corresponds to an inner value that existed before processing the
|
||||
// current leaf, and each needs a hash to combine it.
|
||||
for (level = 0; !(count & (((uint32_t)1) << level)); level++) {
|
||||
if (pbranch) {
|
||||
if (matchh) {
|
||||
pbranch->push_back(inner[level]);
|
||||
} else if (matchlevel == level) {
|
||||
pbranch->push_back(h);
|
||||
matchh = true;
|
||||
}
|
||||
}
|
||||
mutated |= (inner[level] == h);
|
||||
CHash256().Write(inner[level].begin(), 32).Write(h.begin(), 32).Finalize(h.begin());
|
||||
}
|
||||
// Store the resulting hash at inner position level.
|
||||
inner[level] = h;
|
||||
if (matchh) {
|
||||
matchlevel = level;
|
||||
}
|
||||
}
|
||||
// Do a final 'sweep' over the rightmost branch of the tree to process
|
||||
// odd levels, and reduce everything to a single top value.
|
||||
// Level is the level (counted from the bottom) up to which we've sweeped.
|
||||
int level = 0;
|
||||
// As long as bit number level in count is zero, skip it. It means there
|
||||
// is nothing left at this level.
|
||||
while (!(count & (((uint32_t)1) << level))) {
|
||||
level++;
|
||||
}
|
||||
uint256 h = inner[level];
|
||||
bool matchh = matchlevel == level;
|
||||
while (count != (((uint32_t)1) << level)) {
|
||||
// If we reach this point, h is an inner value that is not the top.
|
||||
// We combine it with itself (Bitcoin's special rule for odd levels in
|
||||
// the tree) to produce a higher level one.
|
||||
if (pbranch && matchh) {
|
||||
pbranch->push_back(h);
|
||||
}
|
||||
CHash256().Write(h.begin(), 32).Write(h.begin(), 32).Finalize(h.begin());
|
||||
// Increment count to the value it would have if two entries at this
|
||||
// level had existed.
|
||||
count += (((uint32_t)1) << level);
|
||||
level++;
|
||||
// And propagate the result upwards accordingly.
|
||||
while (!(count & (((uint32_t)1) << level))) {
|
||||
if (pbranch) {
|
||||
if (matchh) {
|
||||
pbranch->push_back(inner[level]);
|
||||
} else if (matchlevel == level) {
|
||||
pbranch->push_back(h);
|
||||
matchh = true;
|
||||
}
|
||||
}
|
||||
CHash256().Write(inner[level].begin(), 32).Write(h.begin(), 32).Finalize(h.begin());
|
||||
level++;
|
||||
}
|
||||
}
|
||||
// Return result.
|
||||
if (pmutated) *pmutated = mutated;
|
||||
if (proot) *proot = h;
|
||||
}
|
||||
|
||||
uint256 ComputeMerkleRoot(const std::vector<uint256>& leaves, bool* mutated) {
|
||||
uint256 hash;
|
||||
MerkleComputation(leaves, &hash, mutated, -1, NULL);
|
||||
return hash;
|
||||
}
|
||||
|
||||
std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position) {
|
||||
std::vector<uint256> ret;
|
||||
MerkleComputation(leaves, NULL, NULL, position, &ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint256 ComputeMerkleRootFromBranch(const uint256& leaf, const std::vector<uint256>& vMerkleBranch, uint32_t nIndex) {
|
||||
uint256 hash = leaf;
|
||||
for (std::vector<uint256>::const_iterator it = vMerkleBranch.begin(); it != vMerkleBranch.end(); ++it) {
|
||||
if (nIndex & 1) {
|
||||
hash = Hash(BEGIN(*it), END(*it), BEGIN(hash), END(hash));
|
||||
} else {
|
||||
hash = Hash(BEGIN(hash), END(hash), BEGIN(*it), END(*it));
|
||||
}
|
||||
nIndex >>= 1;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
uint256 BlockMerkleRoot(const CBlock& block, bool* mutated)
|
||||
{
|
||||
std::vector<uint256> leaves;
|
||||
leaves.resize(block.vtx.size());
|
||||
for (size_t s = 0; s < block.vtx.size(); s++) {
|
||||
leaves[s] = block.vtx[s].GetHash();
|
||||
}
|
||||
return ComputeMerkleRoot(leaves, mutated);
|
||||
}
|
||||
|
||||
std::vector<uint256> BlockMerkleBranch(const CBlock& block, uint32_t position)
|
||||
{
|
||||
std::vector<uint256> leaves;
|
||||
leaves.resize(block.vtx.size());
|
||||
for (size_t s = 0; s < block.vtx.size(); s++) {
|
||||
leaves[s] = block.vtx[s].GetHash();
|
||||
}
|
||||
return ComputeMerkleBranch(leaves, position);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_MERKLE
|
||||
#define BITCOIN_MERKLE
|
||||
|
||||
#include <stdint.h>
|
||||
#include <vector>
|
||||
|
||||
#include "primitives/transaction.h"
|
||||
#include "primitives/block.h"
|
||||
#include "uint256.h"
|
||||
|
||||
uint256 ComputeMerkleRoot(const std::vector<uint256>& leaves, bool* mutated = NULL);
|
||||
std::vector<uint256> ComputeMerkleBranch(const std::vector<uint256>& leaves, uint32_t position);
|
||||
uint256 ComputeMerkleRootFromBranch(const uint256& leaf, const std::vector<uint256>& branch, uint32_t position);
|
||||
|
||||
/*
|
||||
* Compute the Merkle root of the transactions in a block.
|
||||
* *mutated is set to true if a duplicated subtree was found.
|
||||
*/
|
||||
uint256 BlockMerkleRoot(const CBlock& block, bool* mutated = NULL);
|
||||
|
||||
/*
|
||||
* Compute the Merkle branch for the tree of transactions in a block, for a
|
||||
* given position.
|
||||
* This can be verified using ComputeMerkleRootFromBranch.
|
||||
*/
|
||||
std::vector<uint256> BlockMerkleBranch(const CBlock& block, uint32_t position);
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
#include "memusage.h"
|
||||
|
||||
static inline size_t RecursiveDynamicUsage(const CScript& script) {
|
||||
return memusage::DynamicUsage(*static_cast<const std::vector<unsigned char>*>(&script));
|
||||
return memusage::DynamicUsage(*static_cast<const CScriptBase*>(&script));
|
||||
}
|
||||
|
||||
static inline size_t RecursiveDynamicUsage(const COutPoint& out) {
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2012-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2012-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2012-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2012-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2013-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+9
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "crypto/ripemd160.h"
|
||||
#include "crypto/sha256.h"
|
||||
#include "prevector.h"
|
||||
#include "serialize.h"
|
||||
#include "uint256.h"
|
||||
#include "version.h"
|
||||
@@ -118,6 +119,13 @@ inline uint160 Hash160(const std::vector<unsigned char>& vch)
|
||||
return Hash160(vch.begin(), vch.end());
|
||||
}
|
||||
|
||||
/** Compute the 160-bit hash of a vector. */
|
||||
template<unsigned int N>
|
||||
inline uint160 Hash160(const prevector<N, unsigned char>& vch)
|
||||
{
|
||||
return Hash160(vch.begin(), vch.end());
|
||||
}
|
||||
|
||||
/** A writer stream (for serialization) that computes a 256-bit hash. */
|
||||
class CHashWriter
|
||||
{
|
||||
|
||||
+63
-5
@@ -1,17 +1,25 @@
|
||||
// Copyright (c) 2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "httprpc.h"
|
||||
|
||||
#include "base58.h"
|
||||
#include "chainparams.h"
|
||||
#include "httpserver.h"
|
||||
#include "rpcprotocol.h"
|
||||
#include "rpcserver.h"
|
||||
#include "rpc/protocol.h"
|
||||
#include "rpc/server.h"
|
||||
#include "random.h"
|
||||
#include "sync.h"
|
||||
#include "util.h"
|
||||
#include "utilstrencodings.h"
|
||||
#include "ui_interface.h"
|
||||
#include "crypto/hmac_sha256.h"
|
||||
#include <stdio.h>
|
||||
#include "utilstrencodings.h"
|
||||
|
||||
#include <boost/algorithm/string.hpp> // boost::trim
|
||||
#include <boost/foreach.hpp> //BOOST_FOREACH
|
||||
|
||||
/** Simple one-shot callback timer to be used by the RPC mechanism to e.g.
|
||||
* re-lock the wellet.
|
||||
@@ -72,6 +80,50 @@ static void JSONErrorReply(HTTPRequest* req, const UniValue& objError, const Uni
|
||||
req->WriteReply(nStatus, strReply);
|
||||
}
|
||||
|
||||
//This function checks username and password against -rpcauth
|
||||
//entries from config file.
|
||||
static bool multiUserAuthorized(std::string strUserPass)
|
||||
{
|
||||
if (strUserPass.find(":") == std::string::npos) {
|
||||
return false;
|
||||
}
|
||||
std::string strUser = strUserPass.substr(0, strUserPass.find(":"));
|
||||
std::string strPass = strUserPass.substr(strUserPass.find(":") + 1);
|
||||
|
||||
if (mapMultiArgs.count("-rpcauth") > 0) {
|
||||
//Search for multi-user login/pass "rpcauth" from config
|
||||
BOOST_FOREACH(std::string strRPCAuth, mapMultiArgs["-rpcauth"])
|
||||
{
|
||||
std::vector<std::string> vFields;
|
||||
boost::split(vFields, strRPCAuth, boost::is_any_of(":$"));
|
||||
if (vFields.size() != 3) {
|
||||
//Incorrect formatting in config file
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string strName = vFields[0];
|
||||
if (!TimingResistantEqual(strName, strUser)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string strSalt = vFields[1];
|
||||
std::string strHash = vFields[2];
|
||||
|
||||
unsigned int KEY_SIZE = 32;
|
||||
unsigned char *out = new unsigned char[KEY_SIZE];
|
||||
|
||||
CHMAC_SHA256(reinterpret_cast<const unsigned char*>(strSalt.c_str()), strSalt.size()).Write(reinterpret_cast<const unsigned char*>(strPass.c_str()), strPass.size()).Finalize(out);
|
||||
std::vector<unsigned char> hexvec(out, out+KEY_SIZE);
|
||||
std::string strHashFromPass = HexStr(hexvec);
|
||||
|
||||
if (TimingResistantEqual(strHashFromPass, strHash)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool RPCAuthorized(const std::string& strAuth)
|
||||
{
|
||||
if (strRPCUserColonPass.empty()) // Belt-and-suspenders measure if InitRPCAuthentication was not called
|
||||
@@ -81,7 +133,12 @@ static bool RPCAuthorized(const std::string& strAuth)
|
||||
std::string strUserPass64 = strAuth.substr(6);
|
||||
boost::trim(strUserPass64);
|
||||
std::string strUserPass = DecodeBase64(strUserPass64);
|
||||
return TimingResistantEqual(strUserPass, strRPCUserColonPass);
|
||||
|
||||
//Check if authorized under single-user field
|
||||
if (TimingResistantEqual(strUserPass, strRPCUserColonPass)) {
|
||||
return true;
|
||||
}
|
||||
return multiUserAuthorized(strUserPass);
|
||||
}
|
||||
|
||||
static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &)
|
||||
@@ -157,6 +214,7 @@ static bool InitRPCAuthentication()
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LogPrintf("Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcuser for rpcauth auth generation.");
|
||||
strRPCUserColonPass = mapArgs["-rpcuser"] + ":" + mapArgs["-rpcpassword"];
|
||||
}
|
||||
return true;
|
||||
@@ -172,7 +230,7 @@ bool StartHTTPRPC()
|
||||
|
||||
assert(EventBase());
|
||||
httpRPCTimerInterface = new HTTPRPCTimerInterface(EventBase());
|
||||
RPCRegisterTimerInterface(httpRPCTimerInterface);
|
||||
RPCSetTimerInterface(httpRPCTimerInterface);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -186,7 +244,7 @@ void StopHTTPRPC()
|
||||
LogPrint("rpc", "Stopping HTTP RPC server\n");
|
||||
UnregisterHTTPHandler("/", true);
|
||||
if (httpRPCTimerInterface) {
|
||||
RPCUnregisterTimerInterface(httpRPCTimerInterface);
|
||||
RPCUnsetTimerInterface(httpRPCTimerInterface);
|
||||
delete httpRPCTimerInterface;
|
||||
httpRPCTimerInterface = 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
#include "compat.h"
|
||||
#include "util.h"
|
||||
#include "netbase.h"
|
||||
#include "rpcprotocol.h" // For HTTP status codes
|
||||
#include "rpc/protocol.h" // For HTTP status codes
|
||||
#include "sync.h"
|
||||
#include "ui_interface.h"
|
||||
|
||||
|
||||
+233
-175
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "miner.h"
|
||||
#include "net.h"
|
||||
#include "policy/policy.h"
|
||||
#include "rpcserver.h"
|
||||
#include "rpc/server.h"
|
||||
#include "script/standard.h"
|
||||
#include "script/sigcache.h"
|
||||
#include "scheduler.h"
|
||||
@@ -65,6 +65,10 @@ using namespace std;
|
||||
CWallet* pwalletMain = NULL;
|
||||
#endif
|
||||
bool fFeeEstimatesInitialized = false;
|
||||
static const bool DEFAULT_PROXYRANDOMIZE = true;
|
||||
static const bool DEFAULT_REST_ENABLE = false;
|
||||
static const bool DEFAULT_DISABLE_SAFEMODE = false;
|
||||
static const bool DEFAULT_STOPAFTERBLOCKIMPORT = false;
|
||||
|
||||
#if ENABLE_ZMQ
|
||||
static CZMQNotificationInterface* pzmqNotificationInterface = NULL;
|
||||
@@ -295,7 +299,7 @@ void OnRPCPreCommand(const CRPCCommand& cmd)
|
||||
{
|
||||
// Observe safe mode
|
||||
string strWarning = GetWarnings("rpc");
|
||||
if (strWarning != "" && !GetBoolArg("-disablesafemode", false) &&
|
||||
if (strWarning != "" && !GetBoolArg("-disablesafemode", DEFAULT_DISABLE_SAFEMODE) &&
|
||||
!cmd.okSafeMode)
|
||||
throw JSONRPCError(RPC_FORBIDDEN_BY_SAFE_MODE, string("Safe mode: ") + strWarning);
|
||||
}
|
||||
@@ -307,7 +311,8 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
// When adding new options to the categories, please keep and ensure alphabetical ordering.
|
||||
// Do not translate _(...) -help-debug options, Many technical terms, and only a very small audience, so is unnecessary stress to translators.
|
||||
string strUsage = HelpMessageGroup(_("Options:"));
|
||||
strUsage += HelpMessageOpt("-?", _("This help message"));
|
||||
strUsage += HelpMessageOpt("-?", _("Print this help message and exit"));
|
||||
strUsage += HelpMessageOpt("-version", _("Print version and exit"));
|
||||
strUsage += HelpMessageOpt("-alerts", strprintf(_("Receive and display P2P network alerts (default: %u)"), DEFAULT_ALERTS));
|
||||
strUsage += HelpMessageOpt("-alertnotify=<cmd>", _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)"));
|
||||
strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)"));
|
||||
@@ -315,7 +320,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-blocksonly", strprintf(_("Whether to operate in a blocks only mode (default: %u)"), DEFAULT_BLOCKSONLY));
|
||||
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), DEFAULT_CHECKBLOCKS));
|
||||
strUsage += HelpMessageOpt("-checklevel=<n>", strprintf(_("How thorough the block verification of -checkblocks is (0-4, default: %u)"), DEFAULT_CHECKLEVEL));
|
||||
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), "bitcoin.conf"));
|
||||
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), BITCOIN_CONF_FILENAME));
|
||||
if (mode == HMM_BITCOIND)
|
||||
{
|
||||
#ifndef WIN32
|
||||
@@ -331,7 +336,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-par=<n>", strprintf(_("Set the number of script verification threads (%u to %d, 0 = auto, <0 = leave that many cores free, default: %d)"),
|
||||
-GetNumCores(), MAX_SCRIPTCHECK_THREADS, DEFAULT_SCRIPTCHECK_THREADS));
|
||||
#ifndef WIN32
|
||||
strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file (default: %s)"), "bitcoind.pid"));
|
||||
strUsage += HelpMessageOpt("-pid=<file>", strprintf(_("Specify pid file (default: %s)"), BITCOIN_PID_FILENAME));
|
||||
#endif
|
||||
strUsage += HelpMessageOpt("-prune=<n>", strprintf(_("Reduce storage requirements by pruning (deleting) old blocks. This mode is incompatible with -txindex and -rescan. "
|
||||
"Warning: Reverting this setting requires re-downloading the entire blockchain. "
|
||||
@@ -340,30 +345,34 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
#ifndef WIN32
|
||||
strUsage += HelpMessageOpt("-sysperms", _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)"));
|
||||
#endif
|
||||
strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), 0));
|
||||
strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), DEFAULT_TXINDEX));
|
||||
|
||||
strUsage += HelpMessageGroup(_("Connection options:"));
|
||||
strUsage += HelpMessageOpt("-addnode=<ip>", _("Add a node to connect to and attempt to keep the connection open"));
|
||||
strUsage += HelpMessageOpt("-banscore=<n>", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), 100));
|
||||
strUsage += HelpMessageOpt("-bantime=<n>", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), 86400));
|
||||
strUsage += HelpMessageOpt("-banscore=<n>", strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), DEFAULT_BANSCORE_THRESHOLD));
|
||||
strUsage += HelpMessageOpt("-bantime=<n>", strprintf(_("Number of seconds to keep misbehaving peers from reconnecting (default: %u)"), DEFAULT_MISBEHAVING_BANTIME));
|
||||
strUsage += HelpMessageOpt("-bind=<addr>", _("Bind to given address and always listen on it. Use [host]:port notation for IPv6"));
|
||||
strUsage += HelpMessageOpt("-connect=<ip>", _("Connect only to the specified node(s)"));
|
||||
strUsage += HelpMessageOpt("-discover", _("Discover own IP addresses (default: 1 when listening and no -externalip or -proxy)"));
|
||||
strUsage += HelpMessageOpt("-dns", _("Allow DNS lookups for -addnode, -seednode and -connect") + " " + _("(default: 1)"));
|
||||
strUsage += HelpMessageOpt("-dns", _("Allow DNS lookups for -addnode, -seednode and -connect") + " " + strprintf(_("(default: %u)"), DEFAULT_NAME_LOOKUP));
|
||||
strUsage += HelpMessageOpt("-dnsseed", _("Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect)"));
|
||||
strUsage += HelpMessageOpt("-externalip=<ip>", _("Specify your own public address"));
|
||||
strUsage += HelpMessageOpt("-forcednsseed", strprintf(_("Always query for peer addresses via DNS lookup (default: %u)"), 0));
|
||||
strUsage += HelpMessageOpt("-forcednsseed", strprintf(_("Always query for peer addresses via DNS lookup (default: %u)"), DEFAULT_FORCEDNSSEED));
|
||||
strUsage += HelpMessageOpt("-listen", _("Accept connections from outside (default: 1 if no -proxy or -connect)"));
|
||||
strUsage += HelpMessageOpt("-listenonion", strprintf(_("Automatically create Tor hidden service (default: %d)"), DEFAULT_LISTEN_ONION));
|
||||
strUsage += HelpMessageOpt("-maxconnections=<n>", strprintf(_("Maintain at most <n> connections to peers (default: %u)"), DEFAULT_MAX_PEER_CONNECTIONS));
|
||||
strUsage += HelpMessageOpt("-maxreceivebuffer=<n>", strprintf(_("Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)"), 5000));
|
||||
strUsage += HelpMessageOpt("-maxsendbuffer=<n>", strprintf(_("Maximum per-connection send buffer, <n>*1000 bytes (default: %u)"), 1000));
|
||||
strUsage += HelpMessageOpt("-maxreceivebuffer=<n>", strprintf(_("Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)"), DEFAULT_MAXRECEIVEBUFFER));
|
||||
strUsage += HelpMessageOpt("-maxsendbuffer=<n>", strprintf(_("Maximum per-connection send buffer, <n>*1000 bytes (default: %u)"), DEFAULT_MAXSENDBUFFER));
|
||||
strUsage += HelpMessageOpt("-onion=<ip:port>", strprintf(_("Use separate SOCKS5 proxy to reach peers via Tor hidden services (default: %s)"), "-proxy"));
|
||||
strUsage += HelpMessageOpt("-onlynet=<net>", _("Only connect to nodes in network <net> (ipv4, ipv6 or onion)"));
|
||||
strUsage += HelpMessageOpt("-permitbaremultisig", strprintf(_("Relay non-P2SH multisig (default: %u)"), 1));
|
||||
strUsage += HelpMessageOpt("-port=<port>", strprintf(_("Listen for connections on <port> (default: %u or testnet: %u)"), 8333, 18333));
|
||||
strUsage += HelpMessageOpt("-permitbaremultisig", strprintf(_("Relay non-P2SH multisig (default: %u)"), DEFAULT_PERMIT_BAREMULTISIG));
|
||||
strUsage += HelpMessageOpt("-permitrbf", strprintf(_("Permit transaction replacements in the memory pool (default: %u)"), DEFAULT_PERMIT_REPLACEMENT));
|
||||
strUsage += HelpMessageOpt("-peerbloomfilters", strprintf(_("Support filtering of blocks and transaction with bloom filters (default: %u)"), 1));
|
||||
if (showDebug)
|
||||
strUsage += HelpMessageOpt("-enforcenodebloom", strprintf("Enforce minimum protocol version to limit use of bloom filters (default: %u)", 0));
|
||||
strUsage += HelpMessageOpt("-port=<port>", strprintf(_("Listen for connections on <port> (default: %u or testnet: %u)"), Params(CBaseChainParams::MAIN).GetDefaultPort(), Params(CBaseChainParams::TESTNET).GetDefaultPort()));
|
||||
strUsage += HelpMessageOpt("-proxy=<ip:port>", _("Connect through SOCKS5 proxy"));
|
||||
strUsage += HelpMessageOpt("-proxyrandomize", strprintf(_("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)"), 1));
|
||||
strUsage += HelpMessageOpt("-proxyrandomize", strprintf(_("Randomize credentials for every proxy connection. This enables Tor stream isolation (default: %u)"), DEFAULT_PROXYRANDOMIZE));
|
||||
strUsage += HelpMessageOpt("-seednode=<ip>", _("Connect to a node to retrieve peer addresses, and disconnect"));
|
||||
strUsage += HelpMessageOpt("-timeout=<n>", strprintf(_("Specify connection timeout in milliseconds (minimum: 1, default: %d)"), DEFAULT_CONNECT_TIMEOUT));
|
||||
strUsage += HelpMessageOpt("-torcontrol=<ip>:<port>", strprintf(_("Tor control port to use if onion listening enabled (default: %s)"), DEFAULT_TOR_CONTROL));
|
||||
@@ -378,28 +387,28 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-whitebind=<addr>", _("Bind to given address and whitelist peers connecting to it. Use [host]:port notation for IPv6"));
|
||||
strUsage += HelpMessageOpt("-whitelist=<netmask>", _("Whitelist peers connecting from the given netmask or IP address. Can be specified multiple times.") +
|
||||
" " + _("Whitelisted peers cannot be DoS banned and their transactions are always relayed, even if they are already in the mempool, useful e.g. for a gateway"));
|
||||
strUsage += HelpMessageOpt("-whitelistalwaysrelay", strprintf(_("Always relay transactions received from whitelisted peers (default: %d)"), DEFAULT_WHITELISTALWAYSRELAY));
|
||||
strUsage += HelpMessageOpt("-whitelistrelay", strprintf(_("Accept relayed transactions received from whitelisted peers even when not relaying transactions (default: %d)"), DEFAULT_WHITELISTRELAY));
|
||||
strUsage += HelpMessageOpt("-whitelistforcerelay", strprintf(_("Force relay of transactions from whitelisted peers even they violate local relay policy (default: %d)"), DEFAULT_WHITELISTFORCERELAY));
|
||||
strUsage += HelpMessageOpt("-maxuploadtarget=<n>", strprintf(_("Tries to keep outbound traffic under the given target (in MiB per 24h), 0 = no limit (default: %d)"), DEFAULT_MAX_UPLOAD_TARGET));
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
strUsage += HelpMessageGroup(_("Wallet options:"));
|
||||
strUsage += HelpMessageOpt("-disablewallet", _("Do not load the wallet and disable wallet RPC calls"));
|
||||
strUsage += HelpMessageOpt("-keypool=<n>", strprintf(_("Set key pool size to <n> (default: %u)"), 100));
|
||||
if (showDebug)
|
||||
strUsage += HelpMessageOpt("-mintxfee=<amt>", strprintf("Fees (in %s/kB) smaller than this are considered zero fee for transaction creation (default: %s)",
|
||||
strUsage += HelpMessageOpt("-keypool=<n>", strprintf(_("Set key pool size to <n> (default: %u)"), DEFAULT_KEYPOOL_SIZE));
|
||||
strUsage += HelpMessageOpt("-fallbackfee=<amt>", strprintf(_("A fee rate (in %s/kB) that will be used when fee estimation has insufficient data (default: %s)"),
|
||||
CURRENCY_UNIT, FormatMoney(DEFAULT_FALLBACK_FEE)));
|
||||
strUsage += HelpMessageOpt("-mintxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for transaction creation (default: %s)"),
|
||||
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MINFEE)));
|
||||
strUsage += HelpMessageOpt("-paytxfee=<amt>", strprintf(_("Fee (in %s/kB) to add to transactions you send (default: %s)"),
|
||||
CURRENCY_UNIT, FormatMoney(payTxFee.GetFeePerK())));
|
||||
strUsage += HelpMessageOpt("-rescan", _("Rescan the block chain for missing wallet transactions on startup"));
|
||||
strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet.dat on startup"));
|
||||
strUsage += HelpMessageOpt("-sendfreetransactions", strprintf(_("Send transactions as zero-fee transactions if possible (default: %u)"), 0));
|
||||
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), 1));
|
||||
strUsage += HelpMessageOpt("-sendfreetransactions", strprintf(_("Send transactions as zero-fee transactions if possible (default: %u)"), DEFAULT_SEND_FREE_TRANSACTIONS));
|
||||
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), DEFAULT_SPEND_ZEROCONF_CHANGE));
|
||||
strUsage += HelpMessageOpt("-txconfirmtarget=<n>", strprintf(_("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)"), DEFAULT_TX_CONFIRM_TARGET));
|
||||
strUsage += HelpMessageOpt("-maxtxfee=<amt>", strprintf(_("Maximum total fees (in %s) to use in a single wallet transaction; setting this too low may abort large transactions (default: %s)"),
|
||||
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)));
|
||||
strUsage += HelpMessageOpt("-upgradewallet", _("Upgrade wallet to latest format on startup"));
|
||||
strUsage += HelpMessageOpt("-wallet=<file>", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), "wallet.dat"));
|
||||
strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), true));
|
||||
strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), DEFAULT_WALLETBROADCAST));
|
||||
strUsage += HelpMessageOpt("-walletnotify=<cmd>", _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)"));
|
||||
strUsage += HelpMessageOpt("-zapwallettxes=<mode>", _("Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup") +
|
||||
" " + _("(1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)"));
|
||||
@@ -408,55 +417,66 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
#if ENABLE_ZMQ
|
||||
strUsage += HelpMessageGroup(_("ZeroMQ notification options:"));
|
||||
strUsage += HelpMessageOpt("-zmqpubhashblock=<address>", _("Enable publish hash block in <address>"));
|
||||
strUsage += HelpMessageOpt("-zmqpubhashtransaction=<address>", _("Enable publish hash transaction in <address>"));
|
||||
strUsage += HelpMessageOpt("-zmqpubhashtx=<address>", _("Enable publish hash transaction in <address>"));
|
||||
strUsage += HelpMessageOpt("-zmqpubrawblock=<address>", _("Enable publish raw block in <address>"));
|
||||
strUsage += HelpMessageOpt("-zmqpubrawtransaction=<address>", _("Enable publish raw transaction in <address>"));
|
||||
strUsage += HelpMessageOpt("-zmqpubrawtx=<address>", _("Enable publish raw transaction in <address>"));
|
||||
#endif
|
||||
|
||||
strUsage += HelpMessageGroup(_("Debugging/Testing options:"));
|
||||
strUsage += HelpMessageOpt("-uacomment=<cmt>", _("Append comment to the user agent string"));
|
||||
if (showDebug)
|
||||
{
|
||||
strUsage += HelpMessageOpt("-checkpoints", strprintf("Disable expensive verification for known chain history (default: %u)", 1));
|
||||
strUsage += HelpMessageOpt("-checkblockindex", strprintf("Do a full consistency check for mapBlockIndex, setBlockIndexCandidates, chainActive and mapBlocksUnlinked occasionally. Also sets -checkmempool (default: %u)", Params(CBaseChainParams::MAIN).DefaultConsistencyChecks()));
|
||||
strUsage += HelpMessageOpt("-checkmempool=<n>", strprintf("Run checks every <n> transactions (default: %u)", Params(CBaseChainParams::MAIN).DefaultConsistencyChecks()));
|
||||
strUsage += HelpMessageOpt("-checkpoints", strprintf("Disable expensive verification for known chain history (default: %u)", DEFAULT_CHECKPOINTS_ENABLED));
|
||||
#ifdef ENABLE_WALLET
|
||||
strUsage += HelpMessageOpt("-dblogsize=<n>", strprintf("Flush wallet database activity from memory to disk log every <n> megabytes (default: %u)", DEFAULT_WALLET_DBLOGSIZE));
|
||||
#endif
|
||||
strUsage += HelpMessageOpt("-disablesafemode", strprintf("Disable safemode, override a real safe mode event (default: %u)", 0));
|
||||
strUsage += HelpMessageOpt("-testsafemode", strprintf("Force safe mode (default: %u)", 0));
|
||||
strUsage += HelpMessageOpt("-disablesafemode", strprintf("Disable safemode, override a real safe mode event (default: %u)", DEFAULT_DISABLE_SAFEMODE));
|
||||
strUsage += HelpMessageOpt("-testsafemode", strprintf("Force safe mode (default: %u)", DEFAULT_TESTSAFEMODE));
|
||||
strUsage += HelpMessageOpt("-dropmessagestest=<n>", "Randomly drop 1 of every <n> network messages");
|
||||
strUsage += HelpMessageOpt("-fuzzmessagestest=<n>", "Randomly fuzz 1 of every <n> network messages");
|
||||
#ifdef ENABLE_WALLET
|
||||
strUsage += HelpMessageOpt("-flushwallet", strprintf("Run a thread to flush wallet periodically (default: %u)", 1));
|
||||
strUsage += HelpMessageOpt("-flushwallet", strprintf("Run a thread to flush wallet periodically (default: %u)", DEFAULT_FLUSHWALLET));
|
||||
#endif
|
||||
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", 0));
|
||||
strUsage += HelpMessageOpt("-stopafterblockimport", strprintf("Stop running after importing blocks from disk (default: %u)", DEFAULT_STOPAFTERBLOCKIMPORT));
|
||||
strUsage += HelpMessageOpt("-limitancestorcount=<n>", strprintf("Do not accept transactions if number of in-mempool ancestors is <n> or more (default: %u)", DEFAULT_ANCESTOR_LIMIT));
|
||||
strUsage += HelpMessageOpt("-limitancestorsize=<n>", strprintf("Do not accept transactions whose size with all in-mempool ancestors exceeds <n> kilobytes (default: %u)", DEFAULT_ANCESTOR_SIZE_LIMIT));
|
||||
strUsage += HelpMessageOpt("-limitdescendantcount=<n>", strprintf("Do not accept transactions if any ancestor would have <n> or more in-mempool descendants (default: %u)", DEFAULT_DESCENDANT_LIMIT));
|
||||
strUsage += HelpMessageOpt("-limitdescendantsize=<n>", strprintf("Do not accept transactions if any ancestor would have more than <n> kilobytes of in-mempool descendants (default: %u).", DEFAULT_DESCENDANT_SIZE_LIMIT));
|
||||
}
|
||||
string debugCategories = "addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, mempool, mempoolrej, net, proxy, prune, http, libevent"; // Don't translate these and qt below
|
||||
string debugCategories = "addrman, alert, bench, coindb, db, lock, rand, rpc, selectcoins, mempool, mempoolrej, net, proxy, prune, http, libevent, tor, zmq"; // Don't translate these and qt below
|
||||
if (mode == HMM_BITCOIN_QT)
|
||||
debugCategories += ", qt";
|
||||
strUsage += HelpMessageOpt("-debug=<category>", strprintf(_("Output debugging information (default: %u, supplying <category> is optional)"), 0) + ". " +
|
||||
_("If <category> is not supplied or if <category> = 1, output all debugging information.") + _("<category> can be:") + " " + debugCategories + ".");
|
||||
strUsage += HelpMessageOpt("-gen", strprintf(_("Generate coins (default: %u)"), 0));
|
||||
if (showDebug)
|
||||
strUsage += HelpMessageOpt("-nodebug", "Turn off debugging messages, same as -debug=0");
|
||||
strUsage += HelpMessageOpt("-gen", strprintf(_("Generate coins (default: %u)"), DEFAULT_GENERATE));
|
||||
strUsage += HelpMessageOpt("-genproclimit=<n>", strprintf(_("Set the number of threads for coin generation if enabled (-1 = all cores, default: %d)"), DEFAULT_GENERATE_THREADS));
|
||||
strUsage += HelpMessageOpt("-help-debug", _("Show all debugging options (usage: --help -help-debug)"));
|
||||
strUsage += HelpMessageOpt("-logips", strprintf(_("Include IP addresses in debug output (default: %u)"), 0));
|
||||
strUsage += HelpMessageOpt("-logtimestamps", strprintf(_("Prepend debug output with timestamp (default: %u)"), 1));
|
||||
strUsage += HelpMessageOpt("-logips", strprintf(_("Include IP addresses in debug output (default: %u)"), DEFAULT_LOGIPS));
|
||||
strUsage += HelpMessageOpt("-logtimestamps", strprintf(_("Prepend debug output with timestamp (default: %u)"), DEFAULT_LOGTIMESTAMPS));
|
||||
if (showDebug)
|
||||
{
|
||||
strUsage += HelpMessageOpt("-logtimemicros", strprintf("Add microsecond precision to debug timestamps (default: %u)", DEFAULT_LOGTIMEMICROS));
|
||||
strUsage += HelpMessageOpt("-limitfreerelay=<n>", strprintf("Continuously rate-limit free transactions to <n>*1000 bytes per minute (default: %u)", 15));
|
||||
strUsage += HelpMessageOpt("-relaypriority", strprintf("Require high priority for relaying free or low-fee transactions (default: %u)", 1));
|
||||
strUsage += HelpMessageOpt("-mocktime=<n>", "Replace actual time with <n> seconds since epoch (default: 0)");
|
||||
strUsage += HelpMessageOpt("-limitfreerelay=<n>", strprintf("Continuously rate-limit free transactions to <n>*1000 bytes per minute (default: %u)", DEFAULT_LIMITFREERELAY));
|
||||
strUsage += HelpMessageOpt("-relaypriority", strprintf("Require high priority for relaying free or low-fee transactions (default: %u)", DEFAULT_RELAYPRIORITY));
|
||||
strUsage += HelpMessageOpt("-maxsigcachesize=<n>", strprintf("Limit size of signature cache to <n> MiB (default: %u)", DEFAULT_MAX_SIG_CACHE_SIZE));
|
||||
strUsage += HelpMessageOpt("-maxtipage=<n>", strprintf("Maximum tip age in seconds to consider node in initial block download (default: %u)", DEFAULT_MAX_TIP_AGE));
|
||||
}
|
||||
strUsage += HelpMessageOpt("-minrelaytxfee=<amt>", strprintf(_("Fees (in %s/kB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)"),
|
||||
CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)));
|
||||
strUsage += HelpMessageOpt("-maxtxfee=<amt>", strprintf(_("Maximum total fees (in %s) to use in a single wallet transaction or raw transaction; setting this too low may abort large transactions (default: %s)"),
|
||||
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)));
|
||||
strUsage += HelpMessageOpt("-printtoconsole", _("Send trace/debug info to console instead of debug.log file"));
|
||||
if (showDebug)
|
||||
{
|
||||
strUsage += HelpMessageOpt("-printpriority", strprintf("Log transaction priority and fee per kB when mining blocks (default: %u)", 0));
|
||||
strUsage += HelpMessageOpt("-privdb", strprintf("Sets the DB_PRIVATE flag in the wallet db environment (default: %u)", 1));
|
||||
strUsage += HelpMessageOpt("-printpriority", strprintf("Log transaction priority and fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY));
|
||||
#ifdef ENABLE_WALLET
|
||||
strUsage += HelpMessageOpt("-privdb", strprintf("Sets the DB_PRIVATE flag in the wallet db environment (default: %u)", DEFAULT_WALLET_PRIVDB));
|
||||
#endif
|
||||
}
|
||||
strUsage += HelpMessageOpt("-shrinkdebugfile", _("Shrink debug.log file on client startup (default: 1 when no -debug)"));
|
||||
|
||||
@@ -465,11 +485,12 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageGroup(_("Node relay options:"));
|
||||
if (showDebug)
|
||||
strUsage += HelpMessageOpt("-acceptnonstdtxn", strprintf("Relay and mine \"non-standard\" transactions (%sdefault: %u)", "testnet/regtest only; ", !Params(CBaseChainParams::TESTNET).RequireStandard()));
|
||||
strUsage += HelpMessageOpt("-datacarrier", strprintf(_("Relay and mine data carrier transactions (default: %u)"), 1));
|
||||
strUsage += HelpMessageOpt("-bytespersigop", strprintf(_("Minimum bytes per sigop in transactions we relay and mine (default: %u)"), DEFAULT_BYTES_PER_SIGOP));
|
||||
strUsage += HelpMessageOpt("-datacarrier", strprintf(_("Relay and mine data carrier transactions (default: %u)"), DEFAULT_ACCEPT_DATACARRIER));
|
||||
strUsage += HelpMessageOpt("-datacarriersize", strprintf(_("Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY));
|
||||
|
||||
strUsage += HelpMessageGroup(_("Block creation options:"));
|
||||
strUsage += HelpMessageOpt("-blockminsize=<n>", strprintf(_("Set minimum block size in bytes (default: %u)"), 0));
|
||||
strUsage += HelpMessageOpt("-blockminsize=<n>", strprintf(_("Set minimum block size in bytes (default: %u)"), DEFAULT_BLOCK_MIN_SIZE));
|
||||
strUsage += HelpMessageOpt("-blockmaxsize=<n>", strprintf(_("Set maximum block size in bytes (default: %d)"), DEFAULT_BLOCK_MAX_SIZE));
|
||||
strUsage += HelpMessageOpt("-blockprioritysize=<n>", strprintf(_("Set maximum size of high-priority/low-fee transactions in bytes (default: %d)"), DEFAULT_BLOCK_PRIORITY_SIZE));
|
||||
if (showDebug)
|
||||
@@ -477,11 +498,13 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
|
||||
strUsage += HelpMessageGroup(_("RPC server options:"));
|
||||
strUsage += HelpMessageOpt("-server", _("Accept command line and JSON-RPC commands"));
|
||||
strUsage += HelpMessageOpt("-rest", strprintf(_("Accept public REST requests (default: %u)"), 0));
|
||||
strUsage += HelpMessageOpt("-rest", strprintf(_("Accept public REST requests (default: %u)"), DEFAULT_REST_ENABLE));
|
||||
strUsage += HelpMessageOpt("-rpcbind=<addr>", _("Bind to given address to listen for JSON-RPC connections. Use [host]:port notation for IPv6. This option can be specified multiple times (default: bind to all interfaces)"));
|
||||
strUsage += HelpMessageOpt("-rpccookiefile=<loc>", _("Location of the auth cookie (default: data dir)"));
|
||||
strUsage += HelpMessageOpt("-rpcuser=<user>", _("Username for JSON-RPC connections"));
|
||||
strUsage += HelpMessageOpt("-rpcpassword=<pw>", _("Password for JSON-RPC connections"));
|
||||
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), 8332, 18332));
|
||||
strUsage += HelpMessageOpt("-rpcauth=<userpw>", _("Username and hashed password for JSON-RPC connections. The field <userpw> comes in the format: <USERNAME>:<SALT>$<HASH>. A canonical python script is included in share/rpcuser. This option can be specified multiple times"));
|
||||
strUsage += HelpMessageOpt("-rpcport=<port>", strprintf(_("Listen for JSON-RPC connections on <port> (default: %u or testnet: %u)"), BaseParams(CBaseChainParams::MAIN).RPCPort(), BaseParams(CBaseChainParams::TESTNET).RPCPort()));
|
||||
strUsage += HelpMessageOpt("-rpcallowip=<ip>", _("Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4), a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option can be specified multiple times"));
|
||||
strUsage += HelpMessageOpt("-rpcthreads=<n>", strprintf(_("Set the number of threads to service RPC calls (default: %d)"), DEFAULT_HTTP_THREADS));
|
||||
if (showDebug) {
|
||||
@@ -489,23 +512,6 @@ std::string HelpMessage(HelpMessageMode mode)
|
||||
strUsage += HelpMessageOpt("-rpcservertimeout=<n>", strprintf("Timeout during HTTP requests (default: %d)", DEFAULT_HTTP_SERVER_TIMEOUT));
|
||||
}
|
||||
|
||||
if (mode == HMM_BITCOIN_QT)
|
||||
{
|
||||
strUsage += HelpMessageGroup(_("UI Options:"));
|
||||
if (showDebug) {
|
||||
strUsage += HelpMessageOpt("-allowselfsignedrootcertificates", "Allow self signed root certificates (default: 0)");
|
||||
}
|
||||
strUsage += HelpMessageOpt("-choosedatadir", _("Choose data directory on startup (default: 0)"));
|
||||
strUsage += HelpMessageOpt("-lang=<lang>", _("Set language, for example \"de_DE\" (default: system locale)"));
|
||||
strUsage += HelpMessageOpt("-min", _("Start minimized"));
|
||||
strUsage += HelpMessageOpt("-rootcertificates=<file>", _("Set SSL root certificates for payment request (default: -system-)"));
|
||||
strUsage += HelpMessageOpt("-splash", _("Show splash screen on startup (default: 1)"));
|
||||
strUsage += HelpMessageOpt("-resetguisettings", _("Reset all settings changes made over the GUI"));
|
||||
if (showDebug) {
|
||||
strUsage += HelpMessageOpt("-uiplatform", "Select platform to customize UI for (one of windows, macosx, other; default: platform compiled on)");
|
||||
}
|
||||
}
|
||||
|
||||
return strUsage;
|
||||
}
|
||||
|
||||
@@ -522,11 +528,14 @@ std::string LicenseInfo()
|
||||
"\n";
|
||||
}
|
||||
|
||||
static void BlockNotifyCallback(const uint256& hashNewTip)
|
||||
static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex)
|
||||
{
|
||||
if (initialSync || !pBlockIndex)
|
||||
return;
|
||||
|
||||
std::string strCmd = GetArg("-blocknotify", "");
|
||||
|
||||
boost::replace_all(strCmd, "%s", hashNewTip.GetHex());
|
||||
boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex());
|
||||
boost::thread t(runCommand, strCmd); // thread runs free
|
||||
}
|
||||
|
||||
@@ -588,6 +597,7 @@ void CleanupBlockRevFiles()
|
||||
|
||||
void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
{
|
||||
const CChainParams& chainparams = Params();
|
||||
RenameThread("bitcoin-loadblk");
|
||||
// -reindex
|
||||
if (fReindex) {
|
||||
@@ -601,14 +611,14 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
if (!file)
|
||||
break; // This error is logged in OpenBlockFile
|
||||
LogPrintf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile);
|
||||
LoadExternalBlockFile(file, &pos);
|
||||
LoadExternalBlockFile(chainparams, file, &pos);
|
||||
nFile++;
|
||||
}
|
||||
pblocktree->WriteReindexing(false);
|
||||
fReindex = false;
|
||||
LogPrintf("Reindexing finished\n");
|
||||
// To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked):
|
||||
InitBlockIndex();
|
||||
InitBlockIndex(chainparams);
|
||||
}
|
||||
|
||||
// hardcoded $DATADIR/bootstrap.dat
|
||||
@@ -619,7 +629,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
CImportingNow imp;
|
||||
boost::filesystem::path pathBootstrapOld = GetDataDir() / "bootstrap.dat.old";
|
||||
LogPrintf("Importing bootstrap.dat...\n");
|
||||
LoadExternalBlockFile(file);
|
||||
LoadExternalBlockFile(chainparams, file);
|
||||
RenameOver(pathBootstrap, pathBootstrapOld);
|
||||
} else {
|
||||
LogPrintf("Warning: Could not open bootstrap file %s\n", pathBootstrap.string());
|
||||
@@ -632,13 +642,13 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
|
||||
if (file) {
|
||||
CImportingNow imp;
|
||||
LogPrintf("Importing blocks file %s...\n", path.string());
|
||||
LoadExternalBlockFile(file);
|
||||
LoadExternalBlockFile(chainparams, file);
|
||||
} else {
|
||||
LogPrintf("Warning: Could not open blocks file %s\n", path.string());
|
||||
}
|
||||
}
|
||||
|
||||
if (GetBoolArg("-stopafterblockimport", false)) {
|
||||
if (GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
|
||||
LogPrintf("Stopping after block import\n");
|
||||
StartShutdown();
|
||||
}
|
||||
@@ -670,13 +680,114 @@ bool AppInitServers(boost::thread_group& threadGroup)
|
||||
return false;
|
||||
if (!StartHTTPRPC())
|
||||
return false;
|
||||
if (GetBoolArg("-rest", false) && !StartREST())
|
||||
if (GetBoolArg("-rest", DEFAULT_REST_ENABLE) && !StartREST())
|
||||
return false;
|
||||
if (!StartHTTPServer())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Parameter interaction based on rules
|
||||
void InitParameterInteraction()
|
||||
{
|
||||
// when specifying an explicit binding address, you want to listen on it
|
||||
// even when -connect or -proxy is specified
|
||||
if (mapArgs.count("-bind")) {
|
||||
if (SoftSetBoolArg("-listen", true))
|
||||
LogPrintf("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
|
||||
}
|
||||
if (mapArgs.count("-whitebind")) {
|
||||
if (SoftSetBoolArg("-listen", true))
|
||||
LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
|
||||
}
|
||||
|
||||
if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) {
|
||||
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
|
||||
if (SoftSetBoolArg("-dnsseed", false))
|
||||
LogPrintf("%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__);
|
||||
if (SoftSetBoolArg("-listen", false))
|
||||
LogPrintf("%s: parameter interaction: -connect set -> setting -listen=0\n", __func__);
|
||||
}
|
||||
|
||||
if (mapArgs.count("-proxy")) {
|
||||
// to protect privacy, do not listen by default if a default proxy server is specified
|
||||
if (SoftSetBoolArg("-listen", false))
|
||||
LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
|
||||
// to protect privacy, do not use UPNP when a proxy is set. The user may still specify -listen=1
|
||||
// to listen locally, so don't rely on this happening through -listen below.
|
||||
if (SoftSetBoolArg("-upnp", false))
|
||||
LogPrintf("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
|
||||
// to protect privacy, do not discover addresses by default
|
||||
if (SoftSetBoolArg("-discover", false))
|
||||
LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
|
||||
}
|
||||
|
||||
if (!GetBoolArg("-listen", DEFAULT_LISTEN)) {
|
||||
// do not map ports or try to retrieve public IP when not listening (pointless)
|
||||
if (SoftSetBoolArg("-upnp", false))
|
||||
LogPrintf("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
|
||||
if (SoftSetBoolArg("-discover", false))
|
||||
LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
|
||||
if (SoftSetBoolArg("-listenonion", false))
|
||||
LogPrintf("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
|
||||
}
|
||||
|
||||
if (mapArgs.count("-externalip")) {
|
||||
// if an explicit public IP is specified, do not try to find others
|
||||
if (SoftSetBoolArg("-discover", false))
|
||||
LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
|
||||
}
|
||||
|
||||
if (GetBoolArg("-salvagewallet", false)) {
|
||||
// Rewrite just private keys: rescan to find transactions
|
||||
if (SoftSetBoolArg("-rescan", true))
|
||||
LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__);
|
||||
}
|
||||
|
||||
// -zapwallettx implies a rescan
|
||||
if (GetBoolArg("-zapwallettxes", false)) {
|
||||
if (SoftSetBoolArg("-rescan", true))
|
||||
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
|
||||
}
|
||||
|
||||
// disable walletbroadcast and whitelistrelay in blocksonly mode
|
||||
if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) {
|
||||
if (SoftSetBoolArg("-whitelistrelay", false))
|
||||
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -whitelistrelay=0\n", __func__);
|
||||
#ifdef ENABLE_WALLET
|
||||
if (SoftSetBoolArg("-walletbroadcast", false))
|
||||
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Forcing relay from whitelisted hosts implies we will accept relays from them in the first place.
|
||||
if (GetBoolArg("-whitelistforcerelay", DEFAULT_WHITELISTFORCERELAY)) {
|
||||
if (SoftSetBoolArg("-whitelistrelay", true))
|
||||
LogPrintf("%s: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
static std::string ResolveErrMsg(const char * const optname, const std::string& strBind)
|
||||
{
|
||||
return strprintf(_("Cannot resolve -%s address: '%s'"), optname, strBind);
|
||||
}
|
||||
|
||||
static std::string AmountErrMsg(const char * const optname, const std::string& strValue)
|
||||
{
|
||||
return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue);
|
||||
}
|
||||
|
||||
void InitLogging()
|
||||
{
|
||||
fPrintToConsole = GetBoolArg("-printtoconsole", false);
|
||||
fLogTimestamps = GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
|
||||
fLogTimeMicros = GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
|
||||
fLogIPs = GetBoolArg("-logips", DEFAULT_LOGIPS);
|
||||
|
||||
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
||||
LogPrintf("Bitcoin version %s (%s)\n", FormatFullVersion(), CLIENT_DATE);
|
||||
}
|
||||
|
||||
/** Initialize bitcoin.
|
||||
* @pre Parameters should be parsed and config file should be read.
|
||||
*/
|
||||
@@ -741,78 +852,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
// ********************************************************* Step 2: parameter interactions
|
||||
const CChainParams& chainparams = Params();
|
||||
|
||||
// Set this early so that parameter interactions go to console
|
||||
fPrintToConsole = GetBoolArg("-printtoconsole", false);
|
||||
fLogTimestamps = GetBoolArg("-logtimestamps", true);
|
||||
fLogTimeMicros = GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
|
||||
fLogIPs = GetBoolArg("-logips", false);
|
||||
|
||||
LogPrintf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
|
||||
LogPrintf("Bitcoin version %s (%s)\n", FormatFullVersion(), CLIENT_DATE);
|
||||
|
||||
// when specifying an explicit binding address, you want to listen on it
|
||||
// even when -connect or -proxy is specified
|
||||
if (mapArgs.count("-bind")) {
|
||||
if (SoftSetBoolArg("-listen", true))
|
||||
LogPrintf("%s: parameter interaction: -bind set -> setting -listen=1\n", __func__);
|
||||
}
|
||||
if (mapArgs.count("-whitebind")) {
|
||||
if (SoftSetBoolArg("-listen", true))
|
||||
LogPrintf("%s: parameter interaction: -whitebind set -> setting -listen=1\n", __func__);
|
||||
}
|
||||
|
||||
if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) {
|
||||
// when only connecting to trusted nodes, do not seed via DNS, or listen by default
|
||||
if (SoftSetBoolArg("-dnsseed", false))
|
||||
LogPrintf("%s: parameter interaction: -connect set -> setting -dnsseed=0\n", __func__);
|
||||
if (SoftSetBoolArg("-listen", false))
|
||||
LogPrintf("%s: parameter interaction: -connect set -> setting -listen=0\n", __func__);
|
||||
}
|
||||
|
||||
if (mapArgs.count("-proxy")) {
|
||||
// to protect privacy, do not listen by default if a default proxy server is specified
|
||||
if (SoftSetBoolArg("-listen", false))
|
||||
LogPrintf("%s: parameter interaction: -proxy set -> setting -listen=0\n", __func__);
|
||||
// to protect privacy, do not use UPNP when a proxy is set. The user may still specify -listen=1
|
||||
// to listen locally, so don't rely on this happening through -listen below.
|
||||
if (SoftSetBoolArg("-upnp", false))
|
||||
LogPrintf("%s: parameter interaction: -proxy set -> setting -upnp=0\n", __func__);
|
||||
// to protect privacy, do not discover addresses by default
|
||||
if (SoftSetBoolArg("-discover", false))
|
||||
LogPrintf("%s: parameter interaction: -proxy set -> setting -discover=0\n", __func__);
|
||||
}
|
||||
|
||||
if (!GetBoolArg("-listen", DEFAULT_LISTEN)) {
|
||||
// do not map ports or try to retrieve public IP when not listening (pointless)
|
||||
if (SoftSetBoolArg("-upnp", false))
|
||||
LogPrintf("%s: parameter interaction: -listen=0 -> setting -upnp=0\n", __func__);
|
||||
if (SoftSetBoolArg("-discover", false))
|
||||
LogPrintf("%s: parameter interaction: -listen=0 -> setting -discover=0\n", __func__);
|
||||
if (SoftSetBoolArg("-listenonion", false))
|
||||
LogPrintf("%s: parameter interaction: -listen=0 -> setting -listenonion=0\n", __func__);
|
||||
}
|
||||
|
||||
if (mapArgs.count("-externalip")) {
|
||||
// if an explicit public IP is specified, do not try to find others
|
||||
if (SoftSetBoolArg("-discover", false))
|
||||
LogPrintf("%s: parameter interaction: -externalip set -> setting -discover=0\n", __func__);
|
||||
}
|
||||
|
||||
if (GetBoolArg("-salvagewallet", false)) {
|
||||
// Rewrite just private keys: rescan to find transactions
|
||||
if (SoftSetBoolArg("-rescan", true))
|
||||
LogPrintf("%s: parameter interaction: -salvagewallet=1 -> setting -rescan=1\n", __func__);
|
||||
}
|
||||
|
||||
// -zapwallettx implies a rescan
|
||||
if (GetBoolArg("-zapwallettxes", false)) {
|
||||
if (SoftSetBoolArg("-rescan", true))
|
||||
LogPrintf("%s: parameter interaction: -zapwallettxes=<mode> -> setting -rescan=1\n", __func__);
|
||||
}
|
||||
// also see: InitParameterInteraction()
|
||||
|
||||
// if using block pruning, then disable txindex
|
||||
if (GetArg("-prune", 0)) {
|
||||
if (GetBoolArg("-txindex", false))
|
||||
if (GetBoolArg("-txindex", DEFAULT_TXINDEX))
|
||||
return InitError(_("Prune mode is incompatible with -txindex."));
|
||||
#ifdef ENABLE_WALLET
|
||||
if (GetBoolArg("-rescan", false)) {
|
||||
@@ -821,16 +865,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
#endif
|
||||
}
|
||||
|
||||
// disable walletbroadcast and whitelistalwaysrelay in blocksonly mode
|
||||
if (GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY)) {
|
||||
if (SoftSetBoolArg("-whitelistalwaysrelay", false))
|
||||
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -whitelistalwaysrelay=0\n", __func__);
|
||||
#ifdef ENABLE_WALLET
|
||||
if (SoftSetBoolArg("-walletbroadcast", false))
|
||||
LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Make sure enough file descriptors are available
|
||||
int nBind = std::max((int)mapArgs.count("-bind") + (int)mapArgs.count("-whitebind"), 1);
|
||||
int nUserMaxConnections = GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
|
||||
@@ -867,19 +901,22 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
if (GetBoolArg("-benchmark", false))
|
||||
InitWarning(_("Unsupported argument -benchmark ignored, use -debug=bench."));
|
||||
|
||||
if (GetBoolArg("-whitelistalwaysrelay", false))
|
||||
InitWarning(_("Unsupported argument -whitelistalwaysrelay ignored, use -whitelistrelay and/or -whitelistforcerelay."));
|
||||
|
||||
// Checkmempool and checkblockindex default to true in regtest mode
|
||||
int ratio = std::min<int>(std::max<int>(GetArg("-checkmempool", chainparams.DefaultConsistencyChecks() ? 1 : 0), 0), 1000000);
|
||||
if (ratio != 0) {
|
||||
mempool.setSanityCheck(1.0 / ratio);
|
||||
}
|
||||
fCheckBlockIndex = GetBoolArg("-checkblockindex", chainparams.DefaultConsistencyChecks());
|
||||
fCheckpointsEnabled = GetBoolArg("-checkpoints", true);
|
||||
fCheckpointsEnabled = GetBoolArg("-checkpoints", DEFAULT_CHECKPOINTS_ENABLED);
|
||||
|
||||
// -mempoollimit limits
|
||||
int64_t nMempoolSizeLimit = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
|
||||
int64_t nMempoolDescendantSizeLimit = GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000;
|
||||
if (nMempoolSizeLimit < 0 || nMempoolSizeLimit < nMempoolDescendantSizeLimit * 40)
|
||||
return InitError(strprintf(_("-maxmempool must be at least %d MB"), GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) / 25));
|
||||
// mempool limits
|
||||
int64_t nMempoolSizeMax = GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000;
|
||||
int64_t nMempoolSizeMin = GetArg("-limitdescendantsize", DEFAULT_DESCENDANT_SIZE_LIMIT) * 1000 * 40;
|
||||
if (nMempoolSizeMax < 0 || nMempoolSizeMax < nMempoolSizeMin)
|
||||
return InitError(strprintf(_("-maxmempool must be at least %d MB"), std::ceil(nMempoolSizeMin / 1000000.0)));
|
||||
|
||||
// -par=0 means autodetect, but nScriptCheckThreads==0 means no concurrency
|
||||
nScriptCheckThreads = GetArg("-par", DEFAULT_SCRIPTCHECK_THREADS);
|
||||
@@ -908,6 +945,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
bool fDisableWallet = GetBoolArg("-disablewallet", false);
|
||||
if (!fDisableWallet)
|
||||
walletRegisterRPCCommands();
|
||||
#endif
|
||||
|
||||
nConnectTimeout = GetArg("-timeout", DEFAULT_CONNECT_TIMEOUT);
|
||||
@@ -926,12 +965,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
if (ParseMoney(mapArgs["-minrelaytxfee"], n) && n > 0)
|
||||
::minRelayTxFee = CFeeRate(n);
|
||||
else
|
||||
return InitError(strprintf(_("Invalid amount for -minrelaytxfee=<amount>: '%s'"), mapArgs["-minrelaytxfee"]));
|
||||
return InitError(AmountErrMsg("minrelaytxfee", mapArgs["-minrelaytxfee"]));
|
||||
}
|
||||
|
||||
fRequireStandard = !GetBoolArg("-acceptnonstdtxn", !Params().RequireStandard());
|
||||
if (Params().RequireStandard() && !fRequireStandard)
|
||||
return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));
|
||||
nBytesPerSigOp = GetArg("-bytespersigop", nBytesPerSigOp);
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
if (mapArgs.count("-mintxfee"))
|
||||
@@ -940,14 +980,23 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
if (ParseMoney(mapArgs["-mintxfee"], n) && n > 0)
|
||||
CWallet::minTxFee = CFeeRate(n);
|
||||
else
|
||||
return InitError(strprintf(_("Invalid amount for -mintxfee=<amount>: '%s'"), mapArgs["-mintxfee"]));
|
||||
return InitError(AmountErrMsg("mintxfee", mapArgs["-mintxfee"]));
|
||||
}
|
||||
if (mapArgs.count("-fallbackfee"))
|
||||
{
|
||||
CAmount nFeePerK = 0;
|
||||
if (!ParseMoney(mapArgs["-fallbackfee"], nFeePerK))
|
||||
return InitError(strprintf(_("Invalid amount for -fallbackfee=<amount>: '%s'"), mapArgs["-fallbackfee"]));
|
||||
if (nFeePerK > HIGH_TX_FEE_PER_KB)
|
||||
InitWarning(_("-fallbackfee is set very high! This is the transaction fee you may pay when fee estimates are not available."));
|
||||
CWallet::fallbackFee = CFeeRate(nFeePerK);
|
||||
}
|
||||
if (mapArgs.count("-paytxfee"))
|
||||
{
|
||||
CAmount nFeePerK = 0;
|
||||
if (!ParseMoney(mapArgs["-paytxfee"], nFeePerK))
|
||||
return InitError(strprintf(_("Invalid amount for -paytxfee=<amount>: '%s'"), mapArgs["-paytxfee"]));
|
||||
if (nFeePerK > nHighTransactionFeeWarning)
|
||||
return InitError(AmountErrMsg("paytxfee", mapArgs["-paytxfee"]));
|
||||
if (nFeePerK > HIGH_TX_FEE_PER_KB)
|
||||
InitWarning(_("-paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
|
||||
payTxFee = CFeeRate(nFeePerK, 1000);
|
||||
if (payTxFee < ::minRelayTxFee)
|
||||
@@ -960,8 +1009,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
{
|
||||
CAmount nMaxFee = 0;
|
||||
if (!ParseMoney(mapArgs["-maxtxfee"], nMaxFee))
|
||||
return InitError(strprintf(_("Invalid amount for -maxtxfee=<amount>: '%s'"), mapArgs["-maptxfee"]));
|
||||
if (nMaxFee > nHighTransactionMaxFeeWarning)
|
||||
return InitError(AmountErrMsg("maxtxfee", mapArgs["-maxtxfee"]));
|
||||
if (nMaxFee > HIGH_MAX_TX_FEE)
|
||||
InitWarning(_("-maxtxfee is set very high! Fees this large could be paid on a single transaction."));
|
||||
maxTxFee = nMaxFee;
|
||||
if (CFeeRate(maxTxFee, 1000) < ::minRelayTxFee)
|
||||
@@ -971,13 +1020,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
}
|
||||
nTxConfirmTarget = GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET);
|
||||
bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", true);
|
||||
fSendFreeTransactions = GetBoolArg("-sendfreetransactions", false);
|
||||
bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE);
|
||||
fSendFreeTransactions = GetBoolArg("-sendfreetransactions", DEFAULT_SEND_FREE_TRANSACTIONS);
|
||||
|
||||
std::string strWalletFile = GetArg("-wallet", "wallet.dat");
|
||||
#endif // ENABLE_WALLET
|
||||
|
||||
fIsBareMultisigStd = GetBoolArg("-permitbaremultisig", true);
|
||||
fIsBareMultisigStd = GetBoolArg("-permitbaremultisig", DEFAULT_PERMIT_BAREMULTISIG);
|
||||
fAcceptDatacarrier = GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER);
|
||||
nMaxDatacarrierBytes = GetArg("-datacarriersize", nMaxDatacarrierBytes);
|
||||
|
||||
fAlerts = GetBoolArg("-alerts", DEFAULT_ALERTS);
|
||||
@@ -988,6 +1038,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
if (GetBoolArg("-peerbloomfilters", true))
|
||||
nLocalServices |= NODE_BLOOM;
|
||||
|
||||
nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
|
||||
fPermitReplacement = GetBoolArg("-permitrbf", DEFAULT_PERMIT_REPLACEMENT);
|
||||
|
||||
// ********************************************************* Step 4: application initialization: dir lock, daemonize, pidfile, debug log
|
||||
|
||||
// Initialize elliptic curve code
|
||||
@@ -1026,7 +1079,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
if (fPrintToDebugLog)
|
||||
OpenDebugLog();
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER < 0x10100000L)
|
||||
LogPrintf("Using OpenSSL version %s\n", SSLeay_version(SSLEAY_VERSION));
|
||||
#else
|
||||
LogPrintf("Using OpenSSL version %s\n", OpenSSL_version(OPENSSL_VERSION));
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
LogPrintf("Using BerkeleyDB version %s\n", DbEnv::version(0, 0, 0));
|
||||
#endif
|
||||
@@ -1123,7 +1181,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
}
|
||||
|
||||
bool proxyRandomize = GetBoolArg("-proxyrandomize", true);
|
||||
bool proxyRandomize = GetBoolArg("-proxyrandomize", DEFAULT_PROXYRANDOMIZE);
|
||||
// -proxy sets a proxy for all outgoing network traffic
|
||||
// -noproxy (or -proxy=0) as well as the empty string can be used to not set a proxy, this is the default
|
||||
std::string proxyArg = GetArg("-proxy", "");
|
||||
@@ -1158,7 +1216,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
// see Step 2: parameter interactions for more information about these
|
||||
fListen = GetBoolArg("-listen", DEFAULT_LISTEN);
|
||||
fDiscover = GetBoolArg("-discover", true);
|
||||
fNameLookup = GetBoolArg("-dns", true);
|
||||
fNameLookup = GetBoolArg("-dns", DEFAULT_NAME_LOOKUP);
|
||||
|
||||
bool fBound = false;
|
||||
if (fListen) {
|
||||
@@ -1166,13 +1224,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
BOOST_FOREACH(const std::string& strBind, mapMultiArgs["-bind"]) {
|
||||
CService addrBind;
|
||||
if (!Lookup(strBind.c_str(), addrBind, GetListenPort(), false))
|
||||
return InitError(strprintf(_("Cannot resolve -bind address: '%s'"), strBind));
|
||||
return InitError(ResolveErrMsg("bind", strBind));
|
||||
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR));
|
||||
}
|
||||
BOOST_FOREACH(const std::string& strBind, mapMultiArgs["-whitebind"]) {
|
||||
CService addrBind;
|
||||
if (!Lookup(strBind.c_str(), addrBind, 0, false))
|
||||
return InitError(strprintf(_("Cannot resolve -whitebind address: '%s'"), strBind));
|
||||
return InitError(ResolveErrMsg("whitebind", strBind));
|
||||
if (addrBind.GetPort() == 0)
|
||||
return InitError(strprintf(_("Need to specify a port with -whitebind: '%s'"), strBind));
|
||||
fBound |= Bind(addrBind, (BF_EXPLICIT | BF_REPORT_ERROR | BF_WHITELIST));
|
||||
@@ -1192,7 +1250,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
BOOST_FOREACH(const std::string& strAddr, mapMultiArgs["-externalip"]) {
|
||||
CService addrLocal(strAddr, GetListenPort(), fNameLookup);
|
||||
if (!addrLocal.IsValid())
|
||||
return InitError(strprintf(_("Cannot resolve -externalip address: '%s'"), strAddr));
|
||||
return InitError(ResolveErrMsg("externalip", strAddr));
|
||||
AddLocal(CService(strAddr, GetListenPort(), fNameLookup), LOCAL_MANUAL);
|
||||
}
|
||||
}
|
||||
@@ -1247,7 +1305,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
nTotalCache = std::max(nTotalCache, nMinDbCache << 20); // total cache cannot be less than nMinDbCache
|
||||
nTotalCache = std::min(nTotalCache, nMaxDbCache << 20); // total cache cannot be greated than nMaxDbcache
|
||||
int64_t nBlockTreeDBCache = nTotalCache / 8;
|
||||
if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", false))
|
||||
if (nBlockTreeDBCache > (1 << 21) && !GetBoolArg("-txindex", DEFAULT_TXINDEX))
|
||||
nBlockTreeDBCache = (1 << 21); // block tree db cache shouldn't be larger than 2 MiB
|
||||
nTotalCache -= nBlockTreeDBCache;
|
||||
int64_t nCoinDBCache = std::min(nTotalCache / 2, (nTotalCache / 4) + (1 << 23)); // use 25%-50% of the remainder for disk cache
|
||||
@@ -1297,13 +1355,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
|
||||
|
||||
// Initialize the block index (no-op if non-empty database was already loaded)
|
||||
if (!InitBlockIndex()) {
|
||||
if (!InitBlockIndex(chainparams)) {
|
||||
strLoadError = _("Error initializing block database");
|
||||
break;
|
||||
}
|
||||
|
||||
// Check for changed -txindex state
|
||||
if (fTxIndex != GetBoolArg("-txindex", false)) {
|
||||
if (fTxIndex != GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
|
||||
strLoadError = _("You need to rebuild the database using -reindex to change -txindex");
|
||||
break;
|
||||
}
|
||||
@@ -1332,7 +1390,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
}
|
||||
|
||||
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", DEFAULT_CHECKLEVEL),
|
||||
if (!CVerifyDB().VerifyDB(chainparams, pcoinsdbview, GetArg("-checklevel", DEFAULT_CHECKLEVEL),
|
||||
GetArg("-checkblocks", DEFAULT_CHECKBLOCKS))) {
|
||||
strLoadError = _("Corrupted block database detected");
|
||||
break;
|
||||
@@ -1529,7 +1587,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
}
|
||||
}
|
||||
}
|
||||
pwalletMain->SetBroadcastTransactions(GetBoolArg("-walletbroadcast", true));
|
||||
pwalletMain->SetBroadcastTransactions(GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));
|
||||
} // (!fDisableWallet)
|
||||
#else // ENABLE_WALLET
|
||||
LogPrintf("No wallet support compiled in!\n");
|
||||
@@ -1556,7 +1614,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
uiInterface.InitMessage(_("Activating best chain..."));
|
||||
// scan for better chains in the block chain database, that are not yet connected in the active best chain
|
||||
CValidationState state;
|
||||
if (!ActivateBestChain(state))
|
||||
if (!ActivateBestChain(state, chainparams))
|
||||
strErrors << "Failed to connect best block";
|
||||
|
||||
std::vector<boost::filesystem::path> vImportFiles;
|
||||
@@ -1603,7 +1661,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
scheduler.scheduleEvery(f, nPowTargetSpacing);
|
||||
|
||||
// Generate coins in the background
|
||||
GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", DEFAULT_GENERATE_THREADS), chainparams);
|
||||
GenerateBitcoins(GetBoolArg("-gen", DEFAULT_GENERATE), GetArg("-genproclimit", DEFAULT_GENERATE_THREADS), chainparams);
|
||||
|
||||
// ********************************************************* Step 12: finished
|
||||
|
||||
|
||||
+5
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -23,6 +23,10 @@ bool ShutdownRequested();
|
||||
/** Interrupt threads */
|
||||
void Interrupt(boost::thread_group& threadGroup);
|
||||
void Shutdown();
|
||||
//!Initialize the logging infrastructure
|
||||
void InitLogging();
|
||||
//!Parameter interaction: change current parameters depending on various rules
|
||||
void InitParameterInteraction();
|
||||
bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler);
|
||||
|
||||
/** The help message mode determines what help message to show */
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2012-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2012-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+756
-355
File diff suppressed because it is too large
Load Diff
+61
-20
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -42,10 +42,18 @@ struct CNodeStateStats;
|
||||
|
||||
/** Default for accepting alerts from the P2P network. */
|
||||
static const bool DEFAULT_ALERTS = true;
|
||||
/** Default for DEFAULT_WHITELISTALWAYSRELAY. */
|
||||
static const bool DEFAULT_WHITELISTALWAYSRELAY = true;
|
||||
/** Default for DEFAULT_WHITELISTRELAY. */
|
||||
static const bool DEFAULT_WHITELISTRELAY = true;
|
||||
/** Default for DEFAULT_WHITELISTFORCERELAY. */
|
||||
static const bool DEFAULT_WHITELISTFORCERELAY = true;
|
||||
/** Default for -minrelaytxfee, minimum relay fee for transactions */
|
||||
static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 1000;
|
||||
//! -maxtxfee default
|
||||
static const CAmount DEFAULT_TRANSACTION_MAXFEE = 0.1 * COIN;
|
||||
//! Discourage users to set fees higher than this amount (in satoshis) per kB
|
||||
static const CAmount HIGH_TX_FEE_PER_KB = 0.01 * COIN;
|
||||
//! -maxtxfee will warn if called with a higher fee than this amount (in satoshis)
|
||||
static const CAmount HIGH_MAX_TX_FEE = 100 * HIGH_TX_FEE_PER_KB;
|
||||
/** Default for -maxorphantx, maximum number of orphan transactions kept in memory */
|
||||
static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
|
||||
/** Default for -limitancestorcount, max number of in-mempool ancestors */
|
||||
@@ -56,8 +64,6 @@ static const unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT = 101;
|
||||
static const unsigned int DEFAULT_DESCENDANT_LIMIT = 25;
|
||||
/** Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants */
|
||||
static const unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT = 101;
|
||||
/** Default for -maxmempool, maximum megabytes of mempool memory usage */
|
||||
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300;
|
||||
/** Default for -mempoolexpiry, expiration time for mempool transactions in hours */
|
||||
static const unsigned int DEFAULT_MEMPOOL_EXPIRY = 72;
|
||||
/** The maximum size of a blk?????.dat file (since 0.8) */
|
||||
@@ -66,6 +72,7 @@ static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000; // 128 MiB
|
||||
static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB
|
||||
/** The pre-allocation chunk size for rev?????.dat files (since 0.8) */
|
||||
static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB
|
||||
|
||||
/** Maximum number of script-checking threads allowed */
|
||||
static const int MAX_SCRIPTCHECK_THREADS = 16;
|
||||
/** -par default (number of script-checking threads, 0 = auto) */
|
||||
@@ -88,6 +95,31 @@ static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;
|
||||
static const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60;
|
||||
/** Maximum length of reject messages. */
|
||||
static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111;
|
||||
/** Average delay between local address broadcasts in seconds. */
|
||||
static const unsigned int AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = 24 * 24 * 60;
|
||||
/** Average delay between peer address broadcasts in seconds. */
|
||||
static const unsigned int AVG_ADDRESS_BROADCAST_INTERVAL = 30;
|
||||
/** Average delay between trickled inventory broadcasts in seconds.
|
||||
* Blocks, whitelisted receivers, and a random 25% of transactions bypass this. */
|
||||
static const unsigned int AVG_INVENTORY_BROADCAST_INTERVAL = 5;
|
||||
|
||||
static const unsigned int DEFAULT_LIMITFREERELAY = 15;
|
||||
static const bool DEFAULT_RELAYPRIORITY = true;
|
||||
static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
|
||||
|
||||
/** Default for -permitbaremultisig */
|
||||
static const bool DEFAULT_PERMIT_BAREMULTISIG = true;
|
||||
static const unsigned int DEFAULT_BYTES_PER_SIGOP = 20;
|
||||
static const bool DEFAULT_CHECKPOINTS_ENABLED = true;
|
||||
static const bool DEFAULT_TXINDEX = false;
|
||||
static const unsigned int DEFAULT_BANSCORE_THRESHOLD = 100;
|
||||
|
||||
static const bool DEFAULT_TESTSAFEMODE = false;
|
||||
/** Default for -permitrbf */
|
||||
static const bool DEFAULT_PERMIT_REPLACEMENT = true;
|
||||
|
||||
/** Maximum number of headers to announce when relaying blocks with headers message.*/
|
||||
static const unsigned int MAX_BLOCKS_TO_ANNOUNCE = 8;
|
||||
|
||||
struct BlockHasher
|
||||
{
|
||||
@@ -110,11 +142,18 @@ extern int nScriptCheckThreads;
|
||||
extern bool fTxIndex;
|
||||
extern bool fIsBareMultisigStd;
|
||||
extern bool fRequireStandard;
|
||||
extern unsigned int nBytesPerSigOp;
|
||||
extern bool fCheckBlockIndex;
|
||||
extern bool fCheckpointsEnabled;
|
||||
extern size_t nCoinCacheUsage;
|
||||
/** A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) */
|
||||
extern CFeeRate minRelayTxFee;
|
||||
/** Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendrawtransaction) */
|
||||
extern CAmount maxTxFee;
|
||||
extern bool fAlerts;
|
||||
/** If the tip is older than this (in seconds), the node is considered to be in initial block download. */
|
||||
extern int64_t nMaxTipAge;
|
||||
extern bool fPermitReplacement;
|
||||
|
||||
/** Best header we've seen so far (used for getheaders queries' starting points). */
|
||||
extern CBlockIndex *pindexBestHeader;
|
||||
@@ -172,9 +211,9 @@ FILE* OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly = false);
|
||||
/** Translation to a filesystem path */
|
||||
boost::filesystem::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix);
|
||||
/** Import blocks from an external file */
|
||||
bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp = NULL);
|
||||
bool LoadExternalBlockFile(const CChainParams& chainparams, FILE* fileIn, CDiskBlockPos *dbp = NULL);
|
||||
/** Initialize a new block tree database + block data on disk */
|
||||
bool InitBlockIndex();
|
||||
bool InitBlockIndex(const CChainParams& chainparams);
|
||||
/** Load the block tree and coins database from disk */
|
||||
bool LoadBlockIndex();
|
||||
/** Unload database information */
|
||||
@@ -185,21 +224,26 @@ bool ProcessMessages(CNode* pfrom);
|
||||
* Send queued protocol messages to be sent to a give node.
|
||||
*
|
||||
* @param[in] pto The node which we are sending messages to.
|
||||
* @param[in] fSendTrickle When true send the trickled data, otherwise trickle the data until true.
|
||||
*/
|
||||
bool SendMessages(CNode* pto, bool fSendTrickle);
|
||||
bool SendMessages(CNode* pto);
|
||||
/** Run an instance of the script checking thread */
|
||||
void ThreadScriptCheck();
|
||||
/** Try to detect Partition (network isolation) attacks against us */
|
||||
void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const CBlockIndex *const &bestHeader, int64_t nPowTargetSpacing);
|
||||
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
|
||||
bool IsInitialBlockDownload();
|
||||
/** Format a string that describes several potential problems detected by the core */
|
||||
/** Format a string that describes several potential problems detected by the core.
|
||||
* strFor can have three values:
|
||||
* - "rpc": get critical warnings, which should put the client in safe mode if non-empty
|
||||
* - "statusbar": get all warnings
|
||||
* - "gui": get all warnings, translated (where possible) for GUI
|
||||
* This function only returns the highest priority warning of the set selected by strFor.
|
||||
*/
|
||||
std::string GetWarnings(const std::string& strFor);
|
||||
/** Retrieve a transaction (from memory pool, or from disk, if possible) */
|
||||
bool GetTransaction(const uint256 &hash, CTransaction &tx, const Consensus::Params& params, uint256 &hashBlock, bool fAllowSlow = false);
|
||||
/** Find the best known block, and make it the tip of the block chain */
|
||||
bool ActivateBestChain(CValidationState &state, const CBlock *pblock = NULL);
|
||||
bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams, const CBlock* pblock = NULL);
|
||||
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
|
||||
|
||||
/**
|
||||
@@ -210,14 +254,14 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
|
||||
*
|
||||
* Pruning functions are called from FlushStateToDisk when the global fCheckForPruning flag has been set.
|
||||
* Block and undo files are deleted in lock-step (when blk00003.dat is deleted, so is rev00003.dat.)
|
||||
* Pruning cannot take place until the longest chain is at least a certain length (100000 on mainnet, 1000 on testnet, 10 on regtest).
|
||||
* Pruning cannot take place until the longest chain is at least a certain length (100000 on mainnet, 1000 on testnet, 1000 on regtest).
|
||||
* Pruning will never delete a block within a defined distance (currently 288) from the active chain's tip.
|
||||
* The block index is updated by unsetting HAVE_DATA and HAVE_UNDO for any blocks that were stored in the deleted files.
|
||||
* A db flag records the fact that at least some block files have been pruned.
|
||||
*
|
||||
* @param[out] setFilesToPrune The set of file indices that can be unlinked will be returned
|
||||
*/
|
||||
void FindFilesToPrune(std::set<int>& setFilesToPrune);
|
||||
void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight);
|
||||
|
||||
/**
|
||||
* Actually unlink the specified files
|
||||
@@ -239,6 +283,8 @@ void PruneAndFlush();
|
||||
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
|
||||
bool* pfMissingInputs, bool fOverrideMempoolLimit=false, bool fRejectAbsurdFee=false);
|
||||
|
||||
/** Convert CValidationState to a human-readable message for logging */
|
||||
std::string FormatStateMessage(const CValidationState &state);
|
||||
|
||||
struct CNodeStateStats {
|
||||
int nMisbehavior;
|
||||
@@ -273,8 +319,6 @@ struct CDiskTxPos : public CDiskBlockPos
|
||||
};
|
||||
|
||||
|
||||
CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree);
|
||||
|
||||
/**
|
||||
* Count ECDSA signature operations the old-fashioned (pre-0.6) way
|
||||
* @return number of sigops this transaction's outputs will produce when spent
|
||||
@@ -383,9 +427,6 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
|
||||
/** Check a block is completely valid from start to finish (only works on top of our current best block, with cs_main held) */
|
||||
bool TestBlockValidity(CValidationState& state, const CChainParams& chainparams, const CBlock& block, CBlockIndex* pindexPrev, bool fCheckPOW = true, bool fCheckMerkleRoot = true);
|
||||
|
||||
/** Store block on disk. If dbp is non-NULL, the file is known to already reside on disk */
|
||||
bool AcceptBlock(const CBlock& block, CValidationState& state, CBlockIndex **pindex, bool fRequested, CDiskBlockPos* dbp);
|
||||
|
||||
|
||||
class CBlockFileInfo
|
||||
{
|
||||
@@ -446,7 +487,7 @@ class CVerifyDB {
|
||||
public:
|
||||
CVerifyDB();
|
||||
~CVerifyDB();
|
||||
bool VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth);
|
||||
bool VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, int nCheckLevel, int nCheckDepth);
|
||||
};
|
||||
|
||||
/** Find the last common block between the parameter chain and a locator. */
|
||||
@@ -458,7 +499,7 @@ bool InvalidateBlock(CValidationState& state, const Consensus::Params& consensus
|
||||
/** Remove invalidity status from a block and its descendants. */
|
||||
bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex);
|
||||
|
||||
/** The currently-connected chain of blocks. */
|
||||
/** The currently-connected chain of blocks (protected by cs_main). */
|
||||
extern CChain chainActive;
|
||||
|
||||
/** Global variable that points to the active CCoinsView (protected by cs_main) */
|
||||
|
||||
+9
-1
@@ -46,7 +46,9 @@ template<typename X> static inline size_t DynamicUsage(const X * const &v) { ret
|
||||
static inline size_t MallocUsage(size_t alloc)
|
||||
{
|
||||
// Measured on libc6 2.19 on Linux.
|
||||
if (sizeof(void*) == 8) {
|
||||
if (alloc == 0) {
|
||||
return 0;
|
||||
} else if (sizeof(void*) == 8) {
|
||||
return ((alloc + 31) >> 4) << 4;
|
||||
} else if (sizeof(void*) == 4) {
|
||||
return ((alloc + 15) >> 3) << 3;
|
||||
@@ -74,6 +76,12 @@ static inline size_t DynamicUsage(const std::vector<X>& v)
|
||||
return MallocUsage(v.capacity() * sizeof(X));
|
||||
}
|
||||
|
||||
template<unsigned int N, typename X, typename S, typename D>
|
||||
static inline size_t DynamicUsage(const prevector<N, X, S, D>& v)
|
||||
{
|
||||
return MallocUsage(v.allocated_memory());
|
||||
}
|
||||
|
||||
template<typename X, typename Y>
|
||||
static inline size_t DynamicUsage(const std::set<X, Y>& s)
|
||||
{
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+130
-190
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "chainparams.h"
|
||||
#include "coins.h"
|
||||
#include "consensus/consensus.h"
|
||||
#include "consensus/merkle.h"
|
||||
#include "consensus/validation.h"
|
||||
#include "hash.h"
|
||||
#include "main.h"
|
||||
@@ -26,6 +27,7 @@
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/tuple/tuple.hpp>
|
||||
#include <queue>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -39,48 +41,18 @@ using namespace std;
|
||||
// transactions in the memory pool. When we select transactions from the
|
||||
// pool, we select by highest priority or fee rate, so we might consider
|
||||
// transactions that depend on transactions that aren't yet in the block.
|
||||
// The COrphan class keeps track of these 'temporary orphans' while
|
||||
// CreateBlock is figuring out which transactions to include.
|
||||
//
|
||||
class COrphan
|
||||
{
|
||||
public:
|
||||
const CTransaction* ptx;
|
||||
set<uint256> setDependsOn;
|
||||
CFeeRate feeRate;
|
||||
double dPriority;
|
||||
|
||||
COrphan(const CTransaction* ptxIn) : ptx(ptxIn), feeRate(0), dPriority(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
uint64_t nLastBlockTx = 0;
|
||||
uint64_t nLastBlockSize = 0;
|
||||
|
||||
// We want to sort transactions by priority and fee rate, so:
|
||||
typedef boost::tuple<double, CFeeRate, const CTransaction*> TxPriority;
|
||||
class TxPriorityCompare
|
||||
class ScoreCompare
|
||||
{
|
||||
bool byFee;
|
||||
|
||||
public:
|
||||
TxPriorityCompare(bool _byFee) : byFee(_byFee) { }
|
||||
ScoreCompare() {}
|
||||
|
||||
bool operator()(const TxPriority& a, const TxPriority& b)
|
||||
bool operator()(const CTxMemPool::txiter a, const CTxMemPool::txiter b)
|
||||
{
|
||||
if (byFee)
|
||||
{
|
||||
if (a.get<1>() == b.get<1>())
|
||||
return a.get<0>() < b.get<0>();
|
||||
return a.get<1>() < b.get<1>();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a.get<0>() == b.get<0>())
|
||||
return a.get<1>() < b.get<1>();
|
||||
return a.get<0>() < b.get<0>();
|
||||
}
|
||||
return CompareTxMemPoolEntryByScore()(*b,*a); // Convert to less than
|
||||
}
|
||||
};
|
||||
|
||||
@@ -126,7 +98,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s
|
||||
|
||||
// Largest block you're willing to create:
|
||||
unsigned int nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE);
|
||||
// Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity:
|
||||
// Limit to between 1K and MAX_BLOCK_SIZE-1K for sanity:
|
||||
nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize));
|
||||
|
||||
// How much of the block should be dedicated to high-priority transactions,
|
||||
@@ -140,6 +112,22 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s
|
||||
nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize);
|
||||
|
||||
// Collect memory pool transactions into the block
|
||||
CTxMemPool::setEntries inBlock;
|
||||
CTxMemPool::setEntries waitSet;
|
||||
|
||||
// This vector will be sorted into a priority queue:
|
||||
vector<TxCoinAgePriority> vecPriority;
|
||||
TxCoinAgePriorityCompare pricomparer;
|
||||
std::map<CTxMemPool::txiter, double, CTxMemPool::CompareIteratorByHash> waitPriMap;
|
||||
typedef std::map<CTxMemPool::txiter, double, CTxMemPool::CompareIteratorByHash>::iterator waitPriIter;
|
||||
double actualPriority = -1;
|
||||
|
||||
std::priority_queue<CTxMemPool::txiter, std::vector<CTxMemPool::txiter>, ScoreCompare> clearedTxs;
|
||||
bool fPrintPriority = GetBoolArg("-printpriority", DEFAULT_PRINTPRIORITY);
|
||||
uint64_t nBlockSize = 1000;
|
||||
uint64_t nBlockTx = 0;
|
||||
unsigned int nBlockSigOps = 100;
|
||||
int lastFewTxs = 0;
|
||||
CAmount nFees = 0;
|
||||
|
||||
{
|
||||
@@ -148,157 +136,102 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s
|
||||
const int nHeight = pindexPrev->nHeight + 1;
|
||||
pblock->nTime = GetAdjustedTime();
|
||||
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
|
||||
CCoinsViewCache view(pcoinsTip);
|
||||
|
||||
// Priority order to process transactions
|
||||
list<COrphan> vOrphan; // list memory doesn't move
|
||||
map<uint256, vector<COrphan*> > mapDependers;
|
||||
bool fPrintPriority = GetBoolArg("-printpriority", false);
|
||||
int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST)
|
||||
? nMedianTimePast
|
||||
: pblock->GetBlockTime();
|
||||
|
||||
// This vector will be sorted into a priority queue:
|
||||
vector<TxPriority> vecPriority;
|
||||
vecPriority.reserve(mempool.mapTx.size());
|
||||
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
|
||||
mi != mempool.mapTx.end(); ++mi)
|
||||
{
|
||||
const CTransaction& tx = mi->GetTx();
|
||||
|
||||
int64_t nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST)
|
||||
? nMedianTimePast
|
||||
: pblock->GetBlockTime();
|
||||
|
||||
if (tx.IsCoinBase() || !IsFinalTx(tx, nHeight, nLockTimeCutoff))
|
||||
continue;
|
||||
|
||||
COrphan* porphan = NULL;
|
||||
double dPriority = 0;
|
||||
CAmount nTotalIn = 0;
|
||||
bool fMissingInputs = false;
|
||||
BOOST_FOREACH(const CTxIn& txin, tx.vin)
|
||||
bool fPriorityBlock = nBlockPrioritySize > 0;
|
||||
if (fPriorityBlock) {
|
||||
vecPriority.reserve(mempool.mapTx.size());
|
||||
for (CTxMemPool::indexed_transaction_set::iterator mi = mempool.mapTx.begin();
|
||||
mi != mempool.mapTx.end(); ++mi)
|
||||
{
|
||||
// Read prev transaction
|
||||
if (!view.HaveCoins(txin.prevout.hash))
|
||||
{
|
||||
// This should never happen; all transactions in the memory
|
||||
// pool should connect to either transactions in the chain
|
||||
// or other transactions in the memory pool.
|
||||
if (!mempool.mapTx.count(txin.prevout.hash))
|
||||
{
|
||||
LogPrintf("ERROR: mempool transaction missing input\n");
|
||||
if (fDebug) assert("mempool transaction missing input" == 0);
|
||||
fMissingInputs = true;
|
||||
if (porphan)
|
||||
vOrphan.pop_back();
|
||||
break;
|
||||
}
|
||||
|
||||
// Has to wait for dependencies
|
||||
if (!porphan)
|
||||
{
|
||||
// Use list for automatic deletion
|
||||
vOrphan.push_back(COrphan(&tx));
|
||||
porphan = &vOrphan.back();
|
||||
}
|
||||
mapDependers[txin.prevout.hash].push_back(porphan);
|
||||
porphan->setDependsOn.insert(txin.prevout.hash);
|
||||
nTotalIn += mempool.mapTx.find(txin.prevout.hash)->GetTx().vout[txin.prevout.n].nValue;
|
||||
continue;
|
||||
}
|
||||
const CCoins* coins = view.AccessCoins(txin.prevout.hash);
|
||||
assert(coins);
|
||||
|
||||
CAmount nValueIn = coins->vout[txin.prevout.n].nValue;
|
||||
nTotalIn += nValueIn;
|
||||
|
||||
int nConf = nHeight - coins->nHeight;
|
||||
|
||||
dPriority += (double)nValueIn * nConf;
|
||||
double dPriority = mi->GetPriority(nHeight);
|
||||
CAmount dummy;
|
||||
mempool.ApplyDeltas(mi->GetTx().GetHash(), dPriority, dummy);
|
||||
vecPriority.push_back(TxCoinAgePriority(dPriority, mi));
|
||||
}
|
||||
if (fMissingInputs) continue;
|
||||
|
||||
// Priority is sum(valuein * age) / modified_txsize
|
||||
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
|
||||
dPriority = tx.ComputePriority(dPriority, nTxSize);
|
||||
|
||||
uint256 hash = tx.GetHash();
|
||||
mempool.ApplyDeltas(hash, dPriority, nTotalIn);
|
||||
|
||||
CFeeRate feeRate(nTotalIn-tx.GetValueOut(), nTxSize);
|
||||
|
||||
if (porphan)
|
||||
{
|
||||
porphan->dPriority = dPriority;
|
||||
porphan->feeRate = feeRate;
|
||||
}
|
||||
else
|
||||
vecPriority.push_back(TxPriority(dPriority, feeRate, &(mi->GetTx())));
|
||||
std::make_heap(vecPriority.begin(), vecPriority.end(), pricomparer);
|
||||
}
|
||||
|
||||
// Collect transactions into block
|
||||
uint64_t nBlockSize = 1000;
|
||||
uint64_t nBlockTx = 0;
|
||||
int nBlockSigOps = 100;
|
||||
bool fSortedByFee = (nBlockPrioritySize <= 0);
|
||||
CTxMemPool::indexed_transaction_set::nth_index<3>::type::iterator mi = mempool.mapTx.get<3>().begin();
|
||||
CTxMemPool::txiter iter;
|
||||
|
||||
TxPriorityCompare comparer(fSortedByFee);
|
||||
std::make_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
||||
|
||||
while (!vecPriority.empty())
|
||||
while (mi != mempool.mapTx.get<3>().end() || !clearedTxs.empty())
|
||||
{
|
||||
// Take highest priority transaction off the priority queue:
|
||||
double dPriority = vecPriority.front().get<0>();
|
||||
CFeeRate feeRate = vecPriority.front().get<1>();
|
||||
const CTransaction& tx = *(vecPriority.front().get<2>());
|
||||
|
||||
std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
||||
vecPriority.pop_back();
|
||||
|
||||
// Size limits
|
||||
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
|
||||
if (nBlockSize + nTxSize >= nBlockMaxSize)
|
||||
continue;
|
||||
|
||||
// Legacy limits on sigOps:
|
||||
unsigned int nTxSigOps = GetLegacySigOpCount(tx);
|
||||
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
|
||||
continue;
|
||||
|
||||
// Skip free transactions if we're past the minimum block size:
|
||||
const uint256& hash = tx.GetHash();
|
||||
double dPriorityDelta = 0;
|
||||
CAmount nFeeDelta = 0;
|
||||
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
|
||||
if (fSortedByFee && (dPriorityDelta <= 0) && (nFeeDelta <= 0) && (feeRate < ::minRelayTxFee) && (nBlockSize + nTxSize >= nBlockMinSize))
|
||||
continue;
|
||||
|
||||
// Prioritise by fee once past the priority size or we run out of high-priority
|
||||
// transactions:
|
||||
if (!fSortedByFee &&
|
||||
((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority)))
|
||||
{
|
||||
fSortedByFee = true;
|
||||
comparer = TxPriorityCompare(fSortedByFee);
|
||||
std::make_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
||||
bool priorityTx = false;
|
||||
if (fPriorityBlock && !vecPriority.empty()) { // add a tx from priority queue to fill the blockprioritysize
|
||||
priorityTx = true;
|
||||
iter = vecPriority.front().second;
|
||||
actualPriority = vecPriority.front().first;
|
||||
std::pop_heap(vecPriority.begin(), vecPriority.end(), pricomparer);
|
||||
vecPriority.pop_back();
|
||||
}
|
||||
else if (clearedTxs.empty()) { // add tx with next highest score
|
||||
iter = mempool.mapTx.project<0>(mi);
|
||||
mi++;
|
||||
}
|
||||
else { // try to add a previously postponed child tx
|
||||
iter = clearedTxs.top();
|
||||
clearedTxs.pop();
|
||||
}
|
||||
|
||||
if (!view.HaveInputs(tx))
|
||||
if (inBlock.count(iter))
|
||||
continue; // could have been added to the priorityBlock
|
||||
|
||||
const CTransaction& tx = iter->GetTx();
|
||||
|
||||
bool fOrphan = false;
|
||||
BOOST_FOREACH(CTxMemPool::txiter parent, mempool.GetMemPoolParents(iter))
|
||||
{
|
||||
if (!inBlock.count(parent)) {
|
||||
fOrphan = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (fOrphan) {
|
||||
if (priorityTx)
|
||||
waitPriMap.insert(std::make_pair(iter,actualPriority));
|
||||
else
|
||||
waitSet.insert(iter);
|
||||
continue;
|
||||
}
|
||||
|
||||
unsigned int nTxSize = iter->GetTxSize();
|
||||
if (fPriorityBlock &&
|
||||
(nBlockSize + nTxSize >= nBlockPrioritySize || !AllowFree(actualPriority))) {
|
||||
fPriorityBlock = false;
|
||||
waitPriMap.clear();
|
||||
}
|
||||
if (!priorityTx &&
|
||||
(iter->GetModifiedFee() < ::minRelayTxFee.GetFee(nTxSize) && nBlockSize >= nBlockMinSize)) {
|
||||
break;
|
||||
}
|
||||
if (nBlockSize + nTxSize >= nBlockMaxSize) {
|
||||
if (nBlockSize > nBlockMaxSize - 100 || lastFewTxs > 50) {
|
||||
break;
|
||||
}
|
||||
// Once we're within 1000 bytes of a full block, only look at 50 more txs
|
||||
// to try to fill the remaining space.
|
||||
if (nBlockSize > nBlockMaxSize - 1000) {
|
||||
lastFewTxs++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!IsFinalTx(tx, nHeight, nLockTimeCutoff))
|
||||
continue;
|
||||
|
||||
CAmount nTxFees = view.GetValueIn(tx)-tx.GetValueOut();
|
||||
|
||||
nTxSigOps += GetP2SHSigOpCount(tx, view);
|
||||
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)
|
||||
unsigned int nTxSigOps = iter->GetSigOpCount();
|
||||
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) {
|
||||
if (nBlockSigOps > MAX_BLOCK_SIGOPS - 2) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// Note that flags: we don't want to set mempool/IsStandard()
|
||||
// policy here, but we still have to ensure that the block we
|
||||
// create only contains transactions that are valid in new blocks.
|
||||
CValidationState state;
|
||||
if (!CheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true))
|
||||
continue;
|
||||
|
||||
UpdateCoins(tx, state, view, nHeight);
|
||||
|
||||
CAmount nTxFees = iter->GetFee();
|
||||
// Added
|
||||
pblock->vtx.push_back(tx);
|
||||
pblocktemplate->vTxFees.push_back(nTxFees);
|
||||
@@ -310,31 +243,37 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s
|
||||
|
||||
if (fPrintPriority)
|
||||
{
|
||||
double dPriority = iter->GetPriority(nHeight);
|
||||
CAmount dummy;
|
||||
mempool.ApplyDeltas(tx.GetHash(), dPriority, dummy);
|
||||
LogPrintf("priority %.1f fee %s txid %s\n",
|
||||
dPriority, feeRate.ToString(), tx.GetHash().ToString());
|
||||
dPriority , CFeeRate(iter->GetModifiedFee(), nTxSize).ToString(), tx.GetHash().ToString());
|
||||
}
|
||||
|
||||
inBlock.insert(iter);
|
||||
|
||||
// Add transactions that depend on this one to the priority queue
|
||||
if (mapDependers.count(hash))
|
||||
BOOST_FOREACH(CTxMemPool::txiter child, mempool.GetMemPoolChildren(iter))
|
||||
{
|
||||
BOOST_FOREACH(COrphan* porphan, mapDependers[hash])
|
||||
{
|
||||
if (!porphan->setDependsOn.empty())
|
||||
{
|
||||
porphan->setDependsOn.erase(hash);
|
||||
if (porphan->setDependsOn.empty())
|
||||
{
|
||||
vecPriority.push_back(TxPriority(porphan->dPriority, porphan->feeRate, porphan->ptx));
|
||||
std::push_heap(vecPriority.begin(), vecPriority.end(), comparer);
|
||||
}
|
||||
if (fPriorityBlock) {
|
||||
waitPriIter wpiter = waitPriMap.find(child);
|
||||
if (wpiter != waitPriMap.end()) {
|
||||
vecPriority.push_back(TxCoinAgePriority(wpiter->second,child));
|
||||
std::push_heap(vecPriority.begin(), vecPriority.end(), pricomparer);
|
||||
waitPriMap.erase(wpiter);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (waitSet.count(child)) {
|
||||
clearedTxs.push(child);
|
||||
waitSet.erase(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nLastBlockTx = nBlockTx;
|
||||
nLastBlockSize = nBlockSize;
|
||||
LogPrintf("CreateNewBlock(): total size %u\n", nBlockSize);
|
||||
LogPrintf("CreateNewBlock(): total size %u txs: %u fees: %ld sigops %d\n", nBlockSize, nBlockTx, nFees, nBlockSigOps);
|
||||
|
||||
// Compute final coinbase transaction.
|
||||
txNew.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, chainparams.GetConsensus());
|
||||
@@ -350,8 +289,9 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s
|
||||
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
||||
|
||||
CValidationState state;
|
||||
if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false))
|
||||
throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed");
|
||||
if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) {
|
||||
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, FormatStateMessage(state)));
|
||||
}
|
||||
}
|
||||
|
||||
return pblocktemplate.release();
|
||||
@@ -373,7 +313,7 @@ void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned
|
||||
assert(txCoinbase.vin[0].scriptSig.size() <= 100);
|
||||
|
||||
pblock->vtx[0] = txCoinbase;
|
||||
pblock->hashMerkleRoot = pblock->ComputeMerkleRoot();
|
||||
pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+4
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -17,8 +17,11 @@ class CScript;
|
||||
class CWallet;
|
||||
namespace Consensus { struct Params; };
|
||||
|
||||
static const bool DEFAULT_GENERATE = false;
|
||||
static const int DEFAULT_GENERATE_THREADS = 1;
|
||||
|
||||
static const bool DEFAULT_PRINTPRIORITY = false;
|
||||
|
||||
struct CBlockTemplate
|
||||
{
|
||||
CBlock block;
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
// Copyright (c) 2012-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_MRUSET_H
|
||||
#define BITCOIN_MRUSET_H
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
/** STL-like set container that only keeps the most recent N elements. */
|
||||
template <typename T>
|
||||
class mruset
|
||||
{
|
||||
public:
|
||||
typedef T key_type;
|
||||
typedef T value_type;
|
||||
typedef typename std::set<T>::iterator iterator;
|
||||
typedef typename std::set<T>::const_iterator const_iterator;
|
||||
typedef typename std::set<T>::size_type size_type;
|
||||
|
||||
protected:
|
||||
std::set<T> set;
|
||||
std::vector<iterator> order;
|
||||
size_type first_used;
|
||||
size_type first_unused;
|
||||
const size_type nMaxSize;
|
||||
|
||||
public:
|
||||
mruset(size_type nMaxSizeIn = 1) : nMaxSize(nMaxSizeIn) { clear(); }
|
||||
iterator begin() const { return set.begin(); }
|
||||
iterator end() const { return set.end(); }
|
||||
size_type size() const { return set.size(); }
|
||||
bool empty() const { return set.empty(); }
|
||||
iterator find(const key_type& k) const { return set.find(k); }
|
||||
size_type count(const key_type& k) const { return set.count(k); }
|
||||
void clear()
|
||||
{
|
||||
set.clear();
|
||||
order.assign(nMaxSize, set.end());
|
||||
first_used = 0;
|
||||
first_unused = 0;
|
||||
}
|
||||
bool inline friend operator==(const mruset<T>& a, const mruset<T>& b) { return a.set == b.set; }
|
||||
bool inline friend operator==(const mruset<T>& a, const std::set<T>& b) { return a.set == b; }
|
||||
bool inline friend operator<(const mruset<T>& a, const mruset<T>& b) { return a.set < b.set; }
|
||||
std::pair<iterator, bool> insert(const key_type& x)
|
||||
{
|
||||
std::pair<iterator, bool> ret = set.insert(x);
|
||||
if (ret.second) {
|
||||
if (set.size() == nMaxSize + 1) {
|
||||
set.erase(order[first_used]);
|
||||
order[first_used] = set.end();
|
||||
if (++first_used == nMaxSize) first_used = 0;
|
||||
}
|
||||
order[first_unused] = ret.first;
|
||||
if (++first_unused == nMaxSize) first_unused = 0;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
size_type max_size() const { return nMaxSize; }
|
||||
};
|
||||
|
||||
#endif // BITCOIN_MRUSET_H
|
||||
+85
-50
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -36,7 +36,9 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
// Dump addresses to peers.dat every 15 minutes (900s)
|
||||
#include <math.h>
|
||||
|
||||
// Dump addresses to peers.dat and banlist.dat every 15 minutes (900s)
|
||||
#define DUMP_ADDRESSES_INTERVAL 900
|
||||
|
||||
#if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL)
|
||||
@@ -67,6 +69,8 @@ namespace {
|
||||
};
|
||||
}
|
||||
|
||||
const static std::string NET_MESSAGE_COMMAND_OTHER = "*other*";
|
||||
|
||||
//
|
||||
// Global state variables
|
||||
//
|
||||
@@ -459,7 +463,7 @@ void CNode::PushVersion()
|
||||
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), addrYou.ToString(), id);
|
||||
else
|
||||
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id);
|
||||
PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
|
||||
PushMessage(NetMsgType::VERSION, PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
|
||||
nLocalHostNonce, strSubVersion, nBestHeight, !GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY));
|
||||
}
|
||||
|
||||
@@ -521,12 +525,11 @@ void CNode::Ban(const CSubNet& subNet, const BanReason &banReason, int64_t banti
|
||||
banEntry.banReason = banReason;
|
||||
if (bantimeoffset <= 0)
|
||||
{
|
||||
bantimeoffset = GetArg("-bantime", 60*60*24); // Default 24-hour ban
|
||||
bantimeoffset = GetArg("-bantime", DEFAULT_MISBEHAVING_BANTIME);
|
||||
sinceUnixEpoch = false;
|
||||
}
|
||||
banEntry.nBanUntil = (sinceUnixEpoch ? 0 : GetTime() )+bantimeoffset;
|
||||
|
||||
|
||||
LOCK(cs_setBanned);
|
||||
if (setBanned[subNet].nBanUntil < banEntry.nBanUntil)
|
||||
setBanned[subNet] = banEntry;
|
||||
@@ -570,11 +573,13 @@ void CNode::SweepBanned()
|
||||
banmap_t::iterator it = setBanned.begin();
|
||||
while(it != setBanned.end())
|
||||
{
|
||||
CSubNet subNet = (*it).first;
|
||||
CBanEntry banEntry = (*it).second;
|
||||
if(now > banEntry.nBanUntil)
|
||||
{
|
||||
setBanned.erase(it++);
|
||||
setBannedIsDirty = true;
|
||||
LogPrint("net", "%s: Removed banned node ip/subnet from banlist.dat: %s\n", __func__, subNet.ToString());
|
||||
}
|
||||
else
|
||||
++it;
|
||||
@@ -628,7 +633,9 @@ void CNode::copyStats(CNodeStats &stats)
|
||||
X(fInbound);
|
||||
X(nStartingHeight);
|
||||
X(nSendBytes);
|
||||
X(mapSendBytesPerMsgCmd);
|
||||
X(nRecvBytes);
|
||||
X(mapRecvBytesPerMsgCmd);
|
||||
X(fWhitelisted);
|
||||
|
||||
// It is common for nodes with good ping times to suddenly become lagged,
|
||||
@@ -683,6 +690,15 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
|
||||
nBytes -= handled;
|
||||
|
||||
if (msg.complete()) {
|
||||
|
||||
//store received bytes per message command
|
||||
//to prevent a memory DOS, only allow valid commands
|
||||
mapMsgCmdSize::iterator i = mapRecvBytesPerMsgCmd.find(msg.hdr.pchCommand);
|
||||
if (i == mapRecvBytesPerMsgCmd.end())
|
||||
i = mapRecvBytesPerMsgCmd.find(NET_MESSAGE_COMMAND_OTHER);
|
||||
assert(i != mapRecvBytesPerMsgCmd.end());
|
||||
i->second += msg.hdr.nMessageSize + CMessageHeader::HEADER_SIZE;
|
||||
|
||||
msg.nTime = GetTimeMicros();
|
||||
messageHandlerCondition.notify_one();
|
||||
}
|
||||
@@ -883,8 +899,6 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) {
|
||||
continue;
|
||||
if (node->fDisconnect)
|
||||
continue;
|
||||
if (node->addr.IsLocal())
|
||||
continue;
|
||||
vEvictionCandidates.push_back(CNodeRef(node));
|
||||
}
|
||||
}
|
||||
@@ -915,15 +929,20 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) {
|
||||
|
||||
if (vEvictionCandidates.empty()) return false;
|
||||
|
||||
// Identify the network group with the most connections
|
||||
// Identify the network group with the most connections and youngest member.
|
||||
// (vEvictionCandidates is already sorted by reverse connect time)
|
||||
std::vector<unsigned char> naMostConnections;
|
||||
unsigned int nMostConnections = 0;
|
||||
int64_t nMostConnectionsTime = 0;
|
||||
std::map<std::vector<unsigned char>, std::vector<CNodeRef> > mapAddrCounts;
|
||||
BOOST_FOREACH(const CNodeRef &node, vEvictionCandidates) {
|
||||
mapAddrCounts[node->addr.GetGroup()].push_back(node);
|
||||
int64_t grouptime = mapAddrCounts[node->addr.GetGroup()][0]->nTimeConnected;
|
||||
size_t groupsize = mapAddrCounts[node->addr.GetGroup()].size();
|
||||
|
||||
if (mapAddrCounts[node->addr.GetGroup()].size() > nMostConnections) {
|
||||
nMostConnections = mapAddrCounts[node->addr.GetGroup()].size();
|
||||
if (groupsize > nMostConnections || (groupsize == nMostConnections && grouptime > nMostConnectionsTime)) {
|
||||
nMostConnections = groupsize;
|
||||
nMostConnectionsTime = grouptime;
|
||||
naMostConnections = node->addr.GetGroup();
|
||||
}
|
||||
}
|
||||
@@ -931,14 +950,13 @@ static bool AttemptToEvictConnection(bool fPreferNewConnection) {
|
||||
// Reduce to the network group with the most connections
|
||||
vEvictionCandidates = mapAddrCounts[naMostConnections];
|
||||
|
||||
// Do not disconnect peers if there is only 1 connection from their network group
|
||||
// Do not disconnect peers if there is only one unprotected connection from their network group.
|
||||
if (vEvictionCandidates.size() <= 1)
|
||||
// unless we prefer the new connection (for whitelisted peers)
|
||||
if (!fPreferNewConnection)
|
||||
return false;
|
||||
|
||||
// Disconnect the most recent connection from the network group with the most connections
|
||||
std::sort(vEvictionCandidates.begin(), vEvictionCandidates.end(), ReverseCompareNodeTimeConnected);
|
||||
// Disconnect from the network group with the most connections
|
||||
vEvictionCandidates[0]->fDisconnect = true;
|
||||
|
||||
return true;
|
||||
@@ -1356,7 +1374,7 @@ void ThreadMapPort()
|
||||
LogPrintf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
|
||||
port, port, lanaddr, r, strupnperror(r));
|
||||
else
|
||||
LogPrintf("UPnP Port Mapping successful.\n");;
|
||||
LogPrintf("UPnP Port Mapping successful.\n");
|
||||
|
||||
MilliSleep(20*60*1000); // Refresh every 20 minutes
|
||||
}
|
||||
@@ -1414,7 +1432,7 @@ void ThreadDNSAddressSeed()
|
||||
{
|
||||
// goal: only query DNS seeds if address need is acute
|
||||
if ((addrman.size() > 0) &&
|
||||
(!GetBoolArg("-forcednsseed", false))) {
|
||||
(!GetBoolArg("-forcednsseed", DEFAULT_FORCEDNSSEED))) {
|
||||
MilliSleep(11 * 1000);
|
||||
|
||||
LOCK(cs_vNodes);
|
||||
@@ -1478,12 +1496,7 @@ void DumpAddresses()
|
||||
void DumpData()
|
||||
{
|
||||
DumpAddresses();
|
||||
|
||||
if (CNode::BannedSetIsDirty())
|
||||
{
|
||||
DumpBanlist();
|
||||
CNode::SetBannedSetDirty(false);
|
||||
}
|
||||
DumpBanlist();
|
||||
}
|
||||
|
||||
void static ProcessOneShot()
|
||||
@@ -1721,11 +1734,6 @@ void ThreadMessageHandler()
|
||||
}
|
||||
}
|
||||
|
||||
// Poll the connected nodes for messages
|
||||
CNode* pnodeTrickle = NULL;
|
||||
if (!vNodesCopy.empty())
|
||||
pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())];
|
||||
|
||||
bool fSleep = true;
|
||||
|
||||
BOOST_FOREACH(CNode* pnode, vNodesCopy)
|
||||
@@ -1756,7 +1764,7 @@ void ThreadMessageHandler()
|
||||
{
|
||||
TRY_LOCK(pnode->cs_vSend, lockSend);
|
||||
if (lockSend)
|
||||
g_signals.SendMessages(pnode, pnode == pnodeTrickle || pnode->fWhitelisted);
|
||||
g_signals.SendMessages(pnode);
|
||||
}
|
||||
boost::this_thread::interruption_point();
|
||||
}
|
||||
@@ -1929,31 +1937,36 @@ void static Discover(boost::thread_group& threadGroup)
|
||||
void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
{
|
||||
uiInterface.InitMessage(_("Loading addresses..."));
|
||||
// Load addresses for peers.dat
|
||||
// Load addresses from peers.dat
|
||||
int64_t nStart = GetTimeMillis();
|
||||
{
|
||||
CAddrDB adb;
|
||||
if (!adb.Read(addrman))
|
||||
if (adb.Read(addrman))
|
||||
LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman.size(), GetTimeMillis() - nStart);
|
||||
else
|
||||
LogPrintf("Invalid or missing peers.dat; recreating\n");
|
||||
}
|
||||
|
||||
//try to read stored banlist
|
||||
uiInterface.InitMessage(_("Loading banlist..."));
|
||||
// Load addresses from banlist.dat
|
||||
nStart = GetTimeMillis();
|
||||
CBanDB bandb;
|
||||
banmap_t banmap;
|
||||
if (!bandb.Read(banmap))
|
||||
if (bandb.Read(banmap)) {
|
||||
CNode::SetBanned(banmap); // thread save setter
|
||||
CNode::SetBannedSetDirty(false); // no need to write down, just read data
|
||||
CNode::SweepBanned(); // sweep out unused entries
|
||||
|
||||
LogPrint("net", "Loaded %d banned node ips/subnets from banlist.dat %dms\n",
|
||||
banmap.size(), GetTimeMillis() - nStart);
|
||||
} else
|
||||
LogPrintf("Invalid or missing banlist.dat; recreating\n");
|
||||
|
||||
CNode::SetBanned(banmap); //thread save setter
|
||||
CNode::SetBannedSetDirty(false); //no need to write down just read or nonexistent data
|
||||
CNode::SweepBanned(); //sweap out unused entries
|
||||
|
||||
LogPrintf("Loaded %i addresses from peers.dat %dms\n",
|
||||
addrman.size(), GetTimeMillis() - nStart);
|
||||
fAddressesInitialized = true;
|
||||
|
||||
if (semOutbound == NULL) {
|
||||
// initialize semaphore
|
||||
int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections);
|
||||
int nMaxOutbound = std::min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections);
|
||||
semOutbound = new CSemaphore(nMaxOutbound);
|
||||
}
|
||||
|
||||
@@ -2168,7 +2181,7 @@ bool CNode::OutboundTargetReached(bool historicalBlockServingLimit)
|
||||
|
||||
if (historicalBlockServingLimit)
|
||||
{
|
||||
// keep a large enought buffer to at least relay each block once
|
||||
// keep a large enough buffer to at least relay each block once
|
||||
uint64_t timeLeftInCycle = GetMaxOutboundTimeLeftInCycle();
|
||||
uint64_t buffer = timeLeftInCycle / 600 * MAX_BLOCK_SIZE;
|
||||
if (buffer >= nMaxOutboundLimit || nMaxOutboundTotalBytesSentInCycle >= nMaxOutboundLimit - buffer)
|
||||
@@ -2337,13 +2350,13 @@ bool CAddrDB::Read(CAddrMan& addr)
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); }
|
||||
unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); }
|
||||
unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", DEFAULT_MAXRECEIVEBUFFER); }
|
||||
unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", DEFAULT_MAXSENDBUFFER); }
|
||||
|
||||
CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNameIn, bool fInboundIn) :
|
||||
ssSend(SER_NETWORK, INIT_PROTO_VERSION),
|
||||
addrKnown(5000, 0.001),
|
||||
setInventoryKnown(SendBufferSize() / 1000)
|
||||
filterInventoryKnown(50000, 0.000001)
|
||||
{
|
||||
nServices = 0;
|
||||
hSocket = hSocketIn;
|
||||
@@ -2370,7 +2383,11 @@ CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNa
|
||||
nSendOffset = 0;
|
||||
hashContinue = uint256();
|
||||
nStartingHeight = -1;
|
||||
filterInventoryKnown.reset();
|
||||
fGetAddr = false;
|
||||
nNextLocalAddrSend = 0;
|
||||
nNextAddrSend = 0;
|
||||
nNextInvSend = 0;
|
||||
fRelayTxes = false;
|
||||
pfilter = new CBloomFilter();
|
||||
nPingNonceSent = 0;
|
||||
@@ -2378,6 +2395,9 @@ CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNa
|
||||
nPingUsecTime = 0;
|
||||
fPingQueued = false;
|
||||
nMinPingUsecTime = std::numeric_limits<int64_t>::max();
|
||||
BOOST_FOREACH(const std::string &msg, getAllNetMessageTypes())
|
||||
mapRecvBytesPerMsgCmd[msg] = 0;
|
||||
mapRecvBytesPerMsgCmd[NET_MESSAGE_COMMAND_OTHER] = 0;
|
||||
|
||||
{
|
||||
LOCK(cs_nLastNodeId);
|
||||
@@ -2408,8 +2428,12 @@ CNode::~CNode()
|
||||
|
||||
void CNode::AskFor(const CInv& inv)
|
||||
{
|
||||
if (mapAskFor.size() > MAPASKFOR_MAX_SZ)
|
||||
if (mapAskFor.size() > MAPASKFOR_MAX_SZ || setAskFor.size() > SETASKFOR_MAX_SZ)
|
||||
return;
|
||||
// a peer may not have multiple non-responded queue positions for a single inv item
|
||||
if (!setAskFor.insert(inv.hash).second)
|
||||
return;
|
||||
|
||||
// We're using mapAskFor as a priority queue,
|
||||
// the key is the earliest time the request can be sent
|
||||
int64_t nRequestTime;
|
||||
@@ -2453,7 +2477,7 @@ void CNode::AbortMessage() UNLOCK_FUNCTION(cs_vSend)
|
||||
LogPrint("net", "(aborted)\n");
|
||||
}
|
||||
|
||||
void CNode::EndMessage() UNLOCK_FUNCTION(cs_vSend)
|
||||
void CNode::EndMessage(const char* pszCommand) UNLOCK_FUNCTION(cs_vSend)
|
||||
{
|
||||
// The -*messagestest options are intentionally not documented in the help message,
|
||||
// since they are only used during development to debug the networking code and are
|
||||
@@ -2476,6 +2500,9 @@ void CNode::EndMessage() UNLOCK_FUNCTION(cs_vSend)
|
||||
unsigned int nSize = ssSend.size() - CMessageHeader::HEADER_SIZE;
|
||||
WriteLE32((uint8_t*)&ssSend[CMessageHeader::MESSAGE_SIZE_OFFSET], nSize);
|
||||
|
||||
//log total amount of bytes per command
|
||||
mapSendBytesPerMsgCmd[std::string(pszCommand)] += nSize + CMessageHeader::HEADER_SIZE;
|
||||
|
||||
// Set the checksum
|
||||
uint256 hash = Hash(ssSend.begin() + CMessageHeader::HEADER_SIZE, ssSend.end());
|
||||
unsigned int nChecksum = 0;
|
||||
@@ -2586,28 +2613,36 @@ bool CBanDB::Read(banmap_t& banSet)
|
||||
// ... verify the network matches ours
|
||||
if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp)))
|
||||
return error("%s: Invalid network magic number", __func__);
|
||||
|
||||
|
||||
// de-serialize address data into one CAddrMan object
|
||||
ssBanlist >> banSet;
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
return error("%s: Deserialize or I/O error - %s", __func__, e.what());
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void DumpBanlist()
|
||||
{
|
||||
int64_t nStart = GetTimeMillis();
|
||||
CNode::SweepBanned(); // clean unused entries (if bantime has expired)
|
||||
|
||||
CNode::SweepBanned(); //clean unused entries (if bantime has expired)
|
||||
if (!CNode::BannedSetIsDirty())
|
||||
return;
|
||||
|
||||
int64_t nStart = GetTimeMillis();
|
||||
|
||||
CBanDB bandb;
|
||||
banmap_t banmap;
|
||||
CNode::GetBanned(banmap);
|
||||
bandb.Write(banmap);
|
||||
if (bandb.Write(banmap))
|
||||
CNode::SetBannedSetDirty(false);
|
||||
|
||||
LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n",
|
||||
banmap.size(), GetTimeMillis() - nStart);
|
||||
banmap.size(), GetTimeMillis() - nStart);
|
||||
}
|
||||
|
||||
int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds) {
|
||||
return nNow + (int64_t)(log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 /* -1/2^48 */) * average_interval_seconds * -1000000.0 + 0.5);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include "bloom.h"
|
||||
#include "compat.h"
|
||||
#include "limitedmap.h"
|
||||
#include "mruset.h"
|
||||
#include "netbase.h"
|
||||
#include "protocol.h"
|
||||
#include "random.h"
|
||||
@@ -58,6 +57,8 @@ static const bool DEFAULT_UPNP = false;
|
||||
#endif
|
||||
/** The maximum number of entries in mapAskFor */
|
||||
static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
|
||||
/** The maximum number of entries in setAskFor (larger due to getdata latency)*/
|
||||
static const size_t SETASKFOR_MAX_SZ = 2 * MAX_INV_SZ;
|
||||
/** The maximum number of peer connections to maintain. */
|
||||
static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS = 125;
|
||||
/** The default for -maxuploadtarget. 0 = Unlimited */
|
||||
@@ -65,6 +66,13 @@ static const uint64_t DEFAULT_MAX_UPLOAD_TARGET = 0;
|
||||
/** Default for blocks only*/
|
||||
static const bool DEFAULT_BLOCKSONLY = false;
|
||||
|
||||
static const bool DEFAULT_FORCEDNSSEED = false;
|
||||
static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
|
||||
static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000;
|
||||
|
||||
// NOTE: When adjusting this, update rpcnet:setban's help ("24h")
|
||||
static const unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban
|
||||
|
||||
unsigned int ReceiveFloodSize();
|
||||
unsigned int SendBufferSize();
|
||||
|
||||
@@ -105,7 +113,7 @@ struct CNodeSignals
|
||||
{
|
||||
boost::signals2::signal<int ()> GetHeight;
|
||||
boost::signals2::signal<bool (CNode*), CombinerAll> ProcessMessages;
|
||||
boost::signals2::signal<bool (CNode*, bool), CombinerAll> SendMessages;
|
||||
boost::signals2::signal<bool (CNode*), CombinerAll> SendMessages;
|
||||
boost::signals2::signal<void (NodeId, const CNode*)> InitializeNode;
|
||||
boost::signals2::signal<void (NodeId)> FinalizeNode;
|
||||
};
|
||||
@@ -174,6 +182,7 @@ struct LocalServiceInfo {
|
||||
|
||||
extern CCriticalSection cs_mapLocalHost;
|
||||
extern std::map<CNetAddr, LocalServiceInfo> mapLocalHost;
|
||||
typedef std::map<std::string, uint64_t> mapMsgCmdSize; //command, total bytes
|
||||
|
||||
class CNodeStats
|
||||
{
|
||||
@@ -191,7 +200,9 @@ public:
|
||||
bool fInbound;
|
||||
int nStartingHeight;
|
||||
uint64_t nSendBytes;
|
||||
mapMsgCmdSize mapSendBytesPerMsgCmd;
|
||||
uint64_t nRecvBytes;
|
||||
mapMsgCmdSize mapRecvBytesPerMsgCmd;
|
||||
bool fWhitelisted;
|
||||
double dPingTime;
|
||||
double dPingWait;
|
||||
@@ -365,6 +376,9 @@ protected:
|
||||
static std::vector<CSubNet> vWhitelistedRange;
|
||||
static CCriticalSection cs_vWhitelistedRange;
|
||||
|
||||
mapMsgCmdSize mapSendBytesPerMsgCmd;
|
||||
mapMsgCmdSize mapRecvBytesPerMsgCmd;
|
||||
|
||||
// Basic fuzz-testing
|
||||
void Fuzz(int nChance); // modifies ssSend
|
||||
|
||||
@@ -377,12 +391,19 @@ public:
|
||||
CRollingBloomFilter addrKnown;
|
||||
bool fGetAddr;
|
||||
std::set<uint256> setKnown;
|
||||
int64_t nNextAddrSend;
|
||||
int64_t nNextLocalAddrSend;
|
||||
|
||||
// inventory based relay
|
||||
mruset<CInv> setInventoryKnown;
|
||||
CRollingBloomFilter filterInventoryKnown;
|
||||
std::vector<CInv> vInventoryToSend;
|
||||
CCriticalSection cs_inventory;
|
||||
std::set<uint256> setAskFor;
|
||||
std::multimap<int64_t, CInv> mapAskFor;
|
||||
int64_t nNextInvSend;
|
||||
// Used for headers announcements - unfiltered blocks to relay
|
||||
// Also protected by cs_inventory
|
||||
std::vector<uint256> vBlockHashesToAnnounce;
|
||||
|
||||
// Ping time measurement:
|
||||
// The pong reply we're expecting, or 0 if no pong expected.
|
||||
@@ -484,7 +505,7 @@ public:
|
||||
{
|
||||
{
|
||||
LOCK(cs_inventory);
|
||||
setInventoryKnown.insert(inv);
|
||||
filterInventoryKnown.insert(inv.hash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -492,11 +513,18 @@ public:
|
||||
{
|
||||
{
|
||||
LOCK(cs_inventory);
|
||||
if (!setInventoryKnown.count(inv))
|
||||
vInventoryToSend.push_back(inv);
|
||||
if (inv.type == MSG_TX && filterInventoryKnown.contains(inv.hash))
|
||||
return;
|
||||
vInventoryToSend.push_back(inv);
|
||||
}
|
||||
}
|
||||
|
||||
void PushBlockHash(const uint256 &hash)
|
||||
{
|
||||
LOCK(cs_inventory);
|
||||
vBlockHashesToAnnounce.push_back(hash);
|
||||
}
|
||||
|
||||
void AskFor(const CInv& inv);
|
||||
|
||||
// TODO: Document the postcondition of this function. Is cs_vSend locked?
|
||||
@@ -506,7 +534,7 @@ public:
|
||||
void AbortMessage() UNLOCK_FUNCTION(cs_vSend);
|
||||
|
||||
// TODO: Document the precondition of this function. Is cs_vSend locked?
|
||||
void EndMessage() UNLOCK_FUNCTION(cs_vSend);
|
||||
void EndMessage(const char* pszCommand) UNLOCK_FUNCTION(cs_vSend);
|
||||
|
||||
void PushVersion();
|
||||
|
||||
@@ -516,7 +544,7 @@ public:
|
||||
try
|
||||
{
|
||||
BeginMessage(pszCommand);
|
||||
EndMessage();
|
||||
EndMessage(pszCommand);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -532,7 +560,7 @@ public:
|
||||
{
|
||||
BeginMessage(pszCommand);
|
||||
ssSend << a1;
|
||||
EndMessage();
|
||||
EndMessage(pszCommand);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -548,7 +576,7 @@ public:
|
||||
{
|
||||
BeginMessage(pszCommand);
|
||||
ssSend << a1 << a2;
|
||||
EndMessage();
|
||||
EndMessage(pszCommand);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -564,7 +592,7 @@ public:
|
||||
{
|
||||
BeginMessage(pszCommand);
|
||||
ssSend << a1 << a2 << a3;
|
||||
EndMessage();
|
||||
EndMessage(pszCommand);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -580,7 +608,7 @@ public:
|
||||
{
|
||||
BeginMessage(pszCommand);
|
||||
ssSend << a1 << a2 << a3 << a4;
|
||||
EndMessage();
|
||||
EndMessage(pszCommand);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -596,7 +624,7 @@ public:
|
||||
{
|
||||
BeginMessage(pszCommand);
|
||||
ssSend << a1 << a2 << a3 << a4 << a5;
|
||||
EndMessage();
|
||||
EndMessage(pszCommand);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -612,7 +640,7 @@ public:
|
||||
{
|
||||
BeginMessage(pszCommand);
|
||||
ssSend << a1 << a2 << a3 << a4 << a5 << a6;
|
||||
EndMessage();
|
||||
EndMessage(pszCommand);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -628,7 +656,7 @@ public:
|
||||
{
|
||||
BeginMessage(pszCommand);
|
||||
ssSend << a1 << a2 << a3 << a4 << a5 << a6 << a7;
|
||||
EndMessage();
|
||||
EndMessage(pszCommand);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -644,7 +672,7 @@ public:
|
||||
{
|
||||
BeginMessage(pszCommand);
|
||||
ssSend << a1 << a2 << a3 << a4 << a5 << a6 << a7 << a8;
|
||||
EndMessage();
|
||||
EndMessage(pszCommand);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -660,7 +688,7 @@ public:
|
||||
{
|
||||
BeginMessage(pszCommand);
|
||||
ssSend << a1 << a2 << a3 << a4 << a5 << a6 << a7 << a8 << a9;
|
||||
EndMessage();
|
||||
EndMessage(pszCommand);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
@@ -766,4 +794,7 @@ public:
|
||||
|
||||
void DumpBanlist();
|
||||
|
||||
/** Return a timestamp in the future (in microseconds) for exponentially distributed events. */
|
||||
int64_t PoissonNextSend(int64_t nNow, int average_interval_seconds);
|
||||
|
||||
#endif // BITCOIN_NET_H
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -40,7 +40,7 @@ static proxyType proxyInfo[NET_MAX];
|
||||
static proxyType nameProxy;
|
||||
static CCriticalSection cs_proxyInfos;
|
||||
int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT;
|
||||
bool fNameLookup = false;
|
||||
bool fNameLookup = DEFAULT_NAME_LOOKUP;
|
||||
|
||||
static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
|
||||
|
||||
@@ -140,7 +140,7 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
|
||||
return false;
|
||||
|
||||
do {
|
||||
// Should set the timeout limit to a resonable value to avoid
|
||||
// Should set the timeout limit to a reasonable value to avoid
|
||||
// generating unnecessary checking call during the polling loop,
|
||||
// while it can still response to stop request quick enough.
|
||||
// 2 seconds looks fine in our situation.
|
||||
|
||||
+4
-2
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
extern int nConnectTimeout;
|
||||
extern bool fNameLookup;
|
||||
|
||||
/** -timeout default */
|
||||
//! -timeout default
|
||||
static const int DEFAULT_CONNECT_TIMEOUT = 5000;
|
||||
//! -dns default
|
||||
static const int DEFAULT_NAME_LOOKUP = true;
|
||||
|
||||
#ifdef WIN32
|
||||
// In MSVC, this is defined as a macro, undefine it to prevent a compile and link error
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2013-2014 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+53
-1
@@ -4,6 +4,7 @@
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "policy/fees.h"
|
||||
#include "policy/policy.h"
|
||||
|
||||
#include "amount.h"
|
||||
#include "primitives/transaction.h"
|
||||
@@ -86,7 +87,7 @@ double TxConfirmStats::EstimateMedianVal(int confTarget, double sufficientTxVal,
|
||||
int maxbucketindex = buckets.size() - 1;
|
||||
|
||||
// requireGreater means we are looking for the lowest fee/priority such that all higher
|
||||
// values pass, so we start at maxbucketindex (highest fee) and look at succesively
|
||||
// values pass, so we start at maxbucketindex (highest fee) and look at successively
|
||||
// smaller buckets until we reach failure. Otherwise, we are looking for the highest
|
||||
// fee/priority such that all lower values fail, and we go in the opposite direction.
|
||||
unsigned int startbucket = requireGreater ? maxbucketindex : 0;
|
||||
@@ -504,6 +505,33 @@ CFeeRate CBlockPolicyEstimator::estimateFee(int confTarget)
|
||||
return CFeeRate(median);
|
||||
}
|
||||
|
||||
CFeeRate CBlockPolicyEstimator::estimateSmartFee(int confTarget, int *answerFoundAtTarget, const CTxMemPool& pool)
|
||||
{
|
||||
if (answerFoundAtTarget)
|
||||
*answerFoundAtTarget = confTarget;
|
||||
// Return failure if trying to analyze a target we're not tracking
|
||||
if (confTarget <= 0 || (unsigned int)confTarget > feeStats.GetMaxConfirms())
|
||||
return CFeeRate(0);
|
||||
|
||||
double median = -1;
|
||||
while (median < 0 && (unsigned int)confTarget <= feeStats.GetMaxConfirms()) {
|
||||
median = feeStats.EstimateMedianVal(confTarget++, SUFFICIENT_FEETXS, MIN_SUCCESS_PCT, true, nBestSeenHeight);
|
||||
}
|
||||
|
||||
if (answerFoundAtTarget)
|
||||
*answerFoundAtTarget = confTarget - 1;
|
||||
|
||||
// If mempool is limiting txs , return at least the min fee from the mempool
|
||||
CAmount minPoolFee = pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK();
|
||||
if (minPoolFee > 0 && minPoolFee > median)
|
||||
return CFeeRate(minPoolFee);
|
||||
|
||||
if (median < 0)
|
||||
return CFeeRate(0);
|
||||
|
||||
return CFeeRate(median);
|
||||
}
|
||||
|
||||
double CBlockPolicyEstimator::estimatePriority(int confTarget)
|
||||
{
|
||||
// Return failure if trying to analyze a target we're not tracking
|
||||
@@ -513,6 +541,30 @@ double CBlockPolicyEstimator::estimatePriority(int confTarget)
|
||||
return priStats.EstimateMedianVal(confTarget, SUFFICIENT_PRITXS, MIN_SUCCESS_PCT, true, nBestSeenHeight);
|
||||
}
|
||||
|
||||
double CBlockPolicyEstimator::estimateSmartPriority(int confTarget, int *answerFoundAtTarget, const CTxMemPool& pool)
|
||||
{
|
||||
if (answerFoundAtTarget)
|
||||
*answerFoundAtTarget = confTarget;
|
||||
// Return failure if trying to analyze a target we're not tracking
|
||||
if (confTarget <= 0 || (unsigned int)confTarget > priStats.GetMaxConfirms())
|
||||
return -1;
|
||||
|
||||
// If mempool is limiting txs, no priority txs are allowed
|
||||
CAmount minPoolFee = pool.GetMinFee(GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK();
|
||||
if (minPoolFee > 0)
|
||||
return INF_PRIORITY;
|
||||
|
||||
double median = -1;
|
||||
while (median < 0 && (unsigned int)confTarget <= priStats.GetMaxConfirms()) {
|
||||
median = priStats.EstimateMedianVal(confTarget++, SUFFICIENT_PRITXS, MIN_SUCCESS_PCT, true, nBestSeenHeight);
|
||||
}
|
||||
|
||||
if (answerFoundAtTarget)
|
||||
*answerFoundAtTarget = confTarget - 1;
|
||||
|
||||
return median;
|
||||
}
|
||||
|
||||
void CBlockPolicyEstimator::Write(CAutoFile& fileout)
|
||||
{
|
||||
fileout << nBestSeenHeight;
|
||||
|
||||
+18
-5
@@ -15,6 +15,7 @@
|
||||
class CAutoFile;
|
||||
class CFeeRate;
|
||||
class CTxMemPoolEntry;
|
||||
class CTxMemPool;
|
||||
|
||||
/** \class CBlockPolicyEstimator
|
||||
* The BlockPolicyEstimator is used for estimating the fee or priority needed
|
||||
@@ -28,7 +29,7 @@ class CTxMemPoolEntry;
|
||||
* included in blocks before transactions of lower fee/priority. So for
|
||||
* example if you wanted to know what fee you should put on a transaction to
|
||||
* be included in a block within the next 5 blocks, you would start by looking
|
||||
* at the bucket with with the highest fee transactions and verifying that a
|
||||
* at the bucket with the highest fee transactions and verifying that a
|
||||
* sufficiently high percentage of them were confirmed within 5 blocks and
|
||||
* then you would look at the next highest fee bucket, and so on, stopping at
|
||||
* the last bucket to pass the test. The average fee of transactions in this
|
||||
@@ -86,13 +87,13 @@ private:
|
||||
// Count the total # of txs in each bucket
|
||||
// Track the historical moving average of this total over blocks
|
||||
std::vector<double> txCtAvg;
|
||||
// and calcuate the total for the current block to update the moving average
|
||||
// and calculate the total for the current block to update the moving average
|
||||
std::vector<int> curBlockTxCt;
|
||||
|
||||
// Count the total # of txs confirmed within Y blocks in each bucket
|
||||
// Track the historical moving average of theses totals over blocks
|
||||
std::vector<std::vector<double> > confAvg; // confAvg[Y][X]
|
||||
// and calcuate the totals for the current block to update the moving averages
|
||||
// and calculate the totals for the current block to update the moving averages
|
||||
std::vector<std::vector<int> > curBlockConf; // curBlockConf[Y][X]
|
||||
|
||||
// Sum the total priority/fee of all tx's in each bucket
|
||||
@@ -182,8 +183,8 @@ static const unsigned int MAX_BLOCK_CONFIRMS = 25;
|
||||
/** Decay of .998 is a half-life of 346 blocks or about 2.4 days */
|
||||
static const double DEFAULT_DECAY = .998;
|
||||
|
||||
/** Require greater than 85% of X fee transactions to be confirmed within Y blocks for X to be big enough */
|
||||
static const double MIN_SUCCESS_PCT = .85;
|
||||
/** Require greater than 95% of X fee transactions to be confirmed within Y blocks for X to be big enough */
|
||||
static const double MIN_SUCCESS_PCT = .95;
|
||||
static const double UNLIKELY_PCT = .5;
|
||||
|
||||
/** Require an avg of 1 tx in the combined fee bucket per block to have stat significance */
|
||||
@@ -242,9 +243,21 @@ public:
|
||||
/** Return a fee estimate */
|
||||
CFeeRate estimateFee(int confTarget);
|
||||
|
||||
/** Estimate fee rate needed to get be included in a block within
|
||||
* confTarget blocks. If no answer can be given at confTarget, return an
|
||||
* estimate at the lowest target where one can be given.
|
||||
*/
|
||||
CFeeRate estimateSmartFee(int confTarget, int *answerFoundAtTarget, const CTxMemPool& pool);
|
||||
|
||||
/** Return a priority estimate */
|
||||
double estimatePriority(int confTarget);
|
||||
|
||||
/** Estimate priority needed to get be included in a block within
|
||||
* confTarget blocks. If no answer can be given at confTarget, return an
|
||||
* estimate at the lowest target where one can be given.
|
||||
*/
|
||||
double estimateSmartPriority(int confTarget, int *answerFoundAtTarget, const CTxMemPool& pool);
|
||||
|
||||
/** Write estimation data to a file */
|
||||
void Write(CAutoFile& fileout);
|
||||
|
||||
|
||||
+8
-36
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
* 2. P2SH scripts with a crazy number of expensive
|
||||
* CHECKSIG/CHECKMULTISIG operations
|
||||
*
|
||||
* Check transaction inputs, and make sure any
|
||||
* pay-to-script-hash transactions are evaluating IsStandard scripts
|
||||
*
|
||||
* Why bother? To avoid denial-of-service attacks; an attacker
|
||||
* can submit a standard HASH... OP_EQUAL transaction,
|
||||
* which will get accepted into blocks. The redemption
|
||||
@@ -50,7 +47,7 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType)
|
||||
if (m < 1 || m > n)
|
||||
return false;
|
||||
} else if (whichType == TX_NULL_DATA &&
|
||||
(!GetBoolArg("-datacarrier", true) || scriptPubKey.size() > nMaxDatacarrierBytes))
|
||||
(!fAcceptDatacarrier || scriptPubKey.size() > nMaxDatacarrierBytes))
|
||||
return false;
|
||||
|
||||
return whichType != TX_NONSTANDARD;
|
||||
@@ -135,45 +132,20 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
|
||||
const CScript& prevScript = prev.scriptPubKey;
|
||||
if (!Solver(prevScript, whichType, vSolutions))
|
||||
return false;
|
||||
int nArgsExpected = ScriptSigArgsExpected(whichType, vSolutions);
|
||||
if (nArgsExpected < 0)
|
||||
return false;
|
||||
|
||||
// Transactions with extra stuff in their scriptSigs are
|
||||
// non-standard. Note that this EvalScript() call will
|
||||
// be quick, because if there are any operations
|
||||
// beside "push data" in the scriptSig
|
||||
// IsStandardTx() will have already returned false
|
||||
// and this method isn't called.
|
||||
std::vector<std::vector<unsigned char> > stack;
|
||||
if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker()))
|
||||
return false;
|
||||
|
||||
if (whichType == TX_SCRIPTHASH)
|
||||
{
|
||||
std::vector<std::vector<unsigned char> > stack;
|
||||
// convert the scriptSig into a stack, so we can inspect the redeemScript
|
||||
if (!EvalScript(stack, tx.vin[i].scriptSig, SCRIPT_VERIFY_NONE, BaseSignatureChecker(), 0))
|
||||
return false;
|
||||
if (stack.empty())
|
||||
return false;
|
||||
CScript subscript(stack.back().begin(), stack.back().end());
|
||||
std::vector<std::vector<unsigned char> > vSolutions2;
|
||||
txnouttype whichType2;
|
||||
if (Solver(subscript, whichType2, vSolutions2))
|
||||
{
|
||||
int tmpExpected = ScriptSigArgsExpected(whichType2, vSolutions2);
|
||||
if (tmpExpected < 0)
|
||||
return false;
|
||||
nArgsExpected += tmpExpected;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Any other Script with less than 15 sigops OK:
|
||||
unsigned int sigops = subscript.GetSigOpCount(true);
|
||||
// ... extra data left on the stack after execution is OK, too:
|
||||
return (sigops <= MAX_P2SH_SIGOPS);
|
||||
if (subscript.GetSigOpCount(true) > MAX_P2SH_SIGOPS) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (stack.size() != (unsigned int)nArgsExpected)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
+4
-2
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -18,13 +18,15 @@ class CCoinsViewCache;
|
||||
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000;
|
||||
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
|
||||
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
|
||||
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000;
|
||||
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 0;
|
||||
/** The maximum size for transactions we're willing to relay/mine */
|
||||
static const unsigned int MAX_STANDARD_TX_SIZE = 100000;
|
||||
/** Maximum number of signature check operations in an IsStandard() P2SH script */
|
||||
static const unsigned int MAX_P2SH_SIGOPS = 15;
|
||||
/** The maximum number of sigops we're willing to relay/mine in a single tx */
|
||||
static const unsigned int MAX_STANDARD_TX_SIGOPS = MAX_BLOCK_SIGOPS/5;
|
||||
/** Default for -maxmempool, maximum megabytes of mempool memory usage */
|
||||
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300;
|
||||
/**
|
||||
* Standard script verification flags that standard transactions will comply
|
||||
* with. However scripts violating these flags may still be present in valid
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright (c) 2016 The Bitcoin developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include "policy/rbf.h"
|
||||
|
||||
bool SignalsOptInRBF(const CTransaction &tx)
|
||||
{
|
||||
BOOST_FOREACH(const CTxIn &txin, tx.vin) {
|
||||
if (txin.nSequence < std::numeric_limits<unsigned int>::max()-1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsRBFOptIn(const CTxMemPoolEntry &entry, CTxMemPool &pool)
|
||||
{
|
||||
AssertLockHeld(pool.cs);
|
||||
|
||||
CTxMemPool::setEntries setAncestors;
|
||||
|
||||
// First check the transaction itself.
|
||||
if (SignalsOptInRBF(entry.GetTx())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// If this transaction is not in our mempool, then we can't be sure
|
||||
// we will know about all its inputs.
|
||||
if (!pool.exists(entry.GetTx().GetHash())) {
|
||||
throw std::runtime_error("Cannot determine RBF opt-in signal for non-mempool transaction\n");
|
||||
}
|
||||
|
||||
// If all the inputs have nSequence >= maxint-1, it still might be
|
||||
// signaled for RBF if any unconfirmed parents have signaled.
|
||||
uint64_t noLimit = std::numeric_limits<uint64_t>::max();
|
||||
std::string dummy;
|
||||
pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLimit, dummy, false);
|
||||
|
||||
BOOST_FOREACH(CTxMemPool::txiter it, setAncestors) {
|
||||
if (SignalsOptInRBF(it->GetTx())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2016 The Bitcoin developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_POLICY_RBF_H
|
||||
#define BITCOIN_POLICY_RBF_H
|
||||
|
||||
#include "txmempool.h"
|
||||
|
||||
// Check whether the sequence numbers on this transaction are signaling
|
||||
// opt-in to replace-by-fee, according to BIP 125
|
||||
bool SignalsOptInRBF(const CTransaction &tx);
|
||||
|
||||
// Determine whether an in-mempool transaction is signaling opt-in to RBF
|
||||
// according to BIP 125
|
||||
// This involves checking sequence numbers of the transaction, as well
|
||||
// as the sequence numbers of all in-mempool ancestors.
|
||||
bool IsRBFOptIn(const CTxMemPoolEntry &entry, CTxMemPool &pool);
|
||||
|
||||
#endif // BITCOIN_POLICY_RBF_H
|
||||
+1
-33
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -102,35 +102,3 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params&
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
arith_uint256 GetBlockProof(const CBlockIndex& block)
|
||||
{
|
||||
arith_uint256 bnTarget;
|
||||
bool fNegative;
|
||||
bool fOverflow;
|
||||
bnTarget.SetCompact(block.nBits, &fNegative, &fOverflow);
|
||||
if (fNegative || fOverflow || bnTarget == 0)
|
||||
return 0;
|
||||
// We need to compute 2**256 / (bnTarget+1), but we can't represent 2**256
|
||||
// as it's too large for a arith_uint256. However, as 2**256 is at least as large
|
||||
// as bnTarget+1, it is equal to ((2**256 - bnTarget - 1) / (bnTarget+1)) + 1,
|
||||
// or ~bnTarget / (nTarget+1) + 1.
|
||||
return (~bnTarget / (bnTarget + 1)) + 1;
|
||||
}
|
||||
|
||||
int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params& params)
|
||||
{
|
||||
arith_uint256 r;
|
||||
int sign = 1;
|
||||
if (to.nChainWork > from.nChainWork) {
|
||||
r = to.nChainWork - from.nChainWork;
|
||||
} else {
|
||||
r = from.nChainWork - to.nChainWork;
|
||||
sign = -1;
|
||||
}
|
||||
r = r * arith_uint256(params.nPowTargetSpacing) / GetBlockProof(tip);
|
||||
if (r.bits() > 63) {
|
||||
return sign * std::numeric_limits<int64_t>::max();
|
||||
}
|
||||
return sign * r.GetLow64();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -13,16 +13,11 @@
|
||||
class CBlockHeader;
|
||||
class CBlockIndex;
|
||||
class uint256;
|
||||
class arith_uint256;
|
||||
|
||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params&);
|
||||
unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params&);
|
||||
|
||||
/** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
|
||||
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params&);
|
||||
arith_uint256 GetBlockProof(const CBlockIndex& block);
|
||||
|
||||
/** Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds. */
|
||||
int64_t GetBlockProofEquivalentTime(const CBlockIndex& to, const CBlockIndex& from, const CBlockIndex& tip, const Consensus::Params&);
|
||||
|
||||
#endif // BITCOIN_POW_H
|
||||
|
||||
+490
@@ -0,0 +1,490 @@
|
||||
// Copyright (c) 2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef _BITCOIN_PREVECTOR_H_
|
||||
#define _BITCOIN_PREVECTOR_H_
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <iterator>
|
||||
|
||||
#pragma pack(push, 1)
|
||||
/** Implements a drop-in replacement for std::vector<T> which stores up to N
|
||||
* elements directly (without heap allocation). The types Size and Diff are
|
||||
* used to store element counts, and can be any unsigned + signed type.
|
||||
*
|
||||
* Storage layout is either:
|
||||
* - Direct allocation:
|
||||
* - Size _size: the number of used elements (between 0 and N)
|
||||
* - T direct[N]: an array of N elements of type T
|
||||
* (only the first _size are initialized).
|
||||
* - Indirect allocation:
|
||||
* - Size _size: the number of used elements plus N + 1
|
||||
* - Size capacity: the number of allocated elements
|
||||
* - T* indirect: a pointer to an array of capacity elements of type T
|
||||
* (only the first _size are initialized).
|
||||
*
|
||||
* The data type T must be movable by memmove/realloc(). Once we switch to C++,
|
||||
* move constructors can be used instead.
|
||||
*/
|
||||
template<unsigned int N, typename T, typename Size = uint32_t, typename Diff = int32_t>
|
||||
class prevector {
|
||||
public:
|
||||
typedef Size size_type;
|
||||
typedef Diff difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
|
||||
class iterator {
|
||||
T* ptr;
|
||||
public:
|
||||
typedef Diff difference_type;
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
iterator(T* ptr_) : ptr(ptr_) {}
|
||||
T& operator*() const { return *ptr; }
|
||||
T* operator->() const { return ptr; }
|
||||
T& operator[](size_type pos) { return ptr[pos]; }
|
||||
const T& operator[](size_type pos) const { return ptr[pos]; }
|
||||
iterator& operator++() { ptr++; return *this; }
|
||||
iterator& operator--() { ptr--; return *this; }
|
||||
iterator operator++(int) { iterator copy(*this); ++(*this); return copy; }
|
||||
iterator operator--(int) { iterator copy(*this); --(*this); return copy; }
|
||||
difference_type friend operator-(iterator a, iterator b) { return (&(*a) - &(*b)); }
|
||||
iterator operator+(size_type n) { return iterator(ptr + n); }
|
||||
iterator& operator+=(size_type n) { ptr += n; return *this; }
|
||||
iterator operator-(size_type n) { return iterator(ptr - n); }
|
||||
iterator& operator-=(size_type n) { ptr -= n; return *this; }
|
||||
bool operator==(iterator x) const { return ptr == x.ptr; }
|
||||
bool operator!=(iterator x) const { return ptr != x.ptr; }
|
||||
bool operator>=(iterator x) const { return ptr >= x.ptr; }
|
||||
bool operator<=(iterator x) const { return ptr <= x.ptr; }
|
||||
bool operator>(iterator x) const { return ptr > x.ptr; }
|
||||
bool operator<(iterator x) const { return ptr < x.ptr; }
|
||||
};
|
||||
|
||||
class reverse_iterator {
|
||||
T* ptr;
|
||||
public:
|
||||
typedef Diff difference_type;
|
||||
typedef T value_type;
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
reverse_iterator(T* ptr_) : ptr(ptr_) {}
|
||||
T& operator*() { return *ptr; }
|
||||
const T& operator*() const { return *ptr; }
|
||||
T* operator->() { return ptr; }
|
||||
const T* operator->() const { return ptr; }
|
||||
reverse_iterator& operator--() { ptr++; return *this; }
|
||||
reverse_iterator& operator++() { ptr--; return *this; }
|
||||
reverse_iterator operator++(int) { reverse_iterator copy(*this); ++(*this); return copy; }
|
||||
reverse_iterator operator--(int) { reverse_iterator copy(*this); --(*this); return copy; }
|
||||
bool operator==(reverse_iterator x) const { return ptr == x.ptr; }
|
||||
bool operator!=(reverse_iterator x) const { return ptr != x.ptr; }
|
||||
};
|
||||
|
||||
class const_iterator {
|
||||
const T* ptr;
|
||||
public:
|
||||
typedef Diff difference_type;
|
||||
typedef const T value_type;
|
||||
typedef const T* pointer;
|
||||
typedef const T& reference;
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
const_iterator(const T* ptr_) : ptr(ptr_) {}
|
||||
const_iterator(iterator x) : ptr(&(*x)) {}
|
||||
const T& operator*() const { return *ptr; }
|
||||
const T* operator->() const { return ptr; }
|
||||
const T& operator[](size_type pos) const { return ptr[pos]; }
|
||||
const_iterator& operator++() { ptr++; return *this; }
|
||||
const_iterator& operator--() { ptr--; return *this; }
|
||||
const_iterator operator++(int) { const_iterator copy(*this); ++(*this); return copy; }
|
||||
const_iterator operator--(int) { const_iterator copy(*this); --(*this); return copy; }
|
||||
difference_type friend operator-(const_iterator a, const_iterator b) { return (&(*a) - &(*b)); }
|
||||
const_iterator operator+(size_type n) { return const_iterator(ptr + n); }
|
||||
const_iterator& operator+=(size_type n) { ptr += n; return *this; }
|
||||
const_iterator operator-(size_type n) { return const_iterator(ptr - n); }
|
||||
const_iterator& operator-=(size_type n) { ptr -= n; return *this; }
|
||||
bool operator==(const_iterator x) const { return ptr == x.ptr; }
|
||||
bool operator!=(const_iterator x) const { return ptr != x.ptr; }
|
||||
bool operator>=(const_iterator x) const { return ptr >= x.ptr; }
|
||||
bool operator<=(const_iterator x) const { return ptr <= x.ptr; }
|
||||
bool operator>(const_iterator x) const { return ptr > x.ptr; }
|
||||
bool operator<(const_iterator x) const { return ptr < x.ptr; }
|
||||
};
|
||||
|
||||
class const_reverse_iterator {
|
||||
const T* ptr;
|
||||
public:
|
||||
typedef Diff difference_type;
|
||||
typedef const T value_type;
|
||||
typedef const T* pointer;
|
||||
typedef const T& reference;
|
||||
typedef std::bidirectional_iterator_tag iterator_category;
|
||||
const_reverse_iterator(T* ptr_) : ptr(ptr_) {}
|
||||
const_reverse_iterator(reverse_iterator x) : ptr(&(*x)) {}
|
||||
const T& operator*() const { return *ptr; }
|
||||
const T* operator->() const { return ptr; }
|
||||
const_reverse_iterator& operator--() { ptr++; return *this; }
|
||||
const_reverse_iterator& operator++() { ptr--; return *this; }
|
||||
const_reverse_iterator operator++(int) { const_reverse_iterator copy(*this); ++(*this); return copy; }
|
||||
const_reverse_iterator operator--(int) { const_reverse_iterator copy(*this); --(*this); return copy; }
|
||||
bool operator==(const_reverse_iterator x) const { return ptr == x.ptr; }
|
||||
bool operator!=(const_reverse_iterator x) const { return ptr != x.ptr; }
|
||||
};
|
||||
|
||||
private:
|
||||
size_type _size;
|
||||
union direct_or_indirect {
|
||||
char direct[sizeof(T) * N];
|
||||
struct {
|
||||
size_type capacity;
|
||||
char* indirect;
|
||||
};
|
||||
} _union;
|
||||
|
||||
T* direct_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.direct) + pos; }
|
||||
const T* direct_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.direct) + pos; }
|
||||
T* indirect_ptr(difference_type pos) { return reinterpret_cast<T*>(_union.indirect) + pos; }
|
||||
const T* indirect_ptr(difference_type pos) const { return reinterpret_cast<const T*>(_union.indirect) + pos; }
|
||||
bool is_direct() const { return _size <= N; }
|
||||
|
||||
void change_capacity(size_type new_capacity) {
|
||||
if (new_capacity <= N) {
|
||||
if (!is_direct()) {
|
||||
T* indirect = indirect_ptr(0);
|
||||
T* src = indirect;
|
||||
T* dst = direct_ptr(0);
|
||||
memcpy(dst, src, size() * sizeof(T));
|
||||
free(indirect);
|
||||
_size -= N + 1;
|
||||
}
|
||||
} else {
|
||||
if (!is_direct()) {
|
||||
_union.indirect = static_cast<char*>(realloc(_union.indirect, ((size_t)sizeof(T)) * new_capacity));
|
||||
_union.capacity = new_capacity;
|
||||
} else {
|
||||
char* new_indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * new_capacity));
|
||||
T* src = direct_ptr(0);
|
||||
T* dst = reinterpret_cast<T*>(new_indirect);
|
||||
memcpy(dst, src, size() * sizeof(T));
|
||||
_union.indirect = new_indirect;
|
||||
_union.capacity = new_capacity;
|
||||
_size += N + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); }
|
||||
const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); }
|
||||
|
||||
public:
|
||||
void assign(size_type n, const T& val) {
|
||||
clear();
|
||||
if (capacity() < n) {
|
||||
change_capacity(n);
|
||||
}
|
||||
while (size() < n) {
|
||||
_size++;
|
||||
new(static_cast<void*>(item_ptr(size() - 1))) T(val);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename InputIterator>
|
||||
void assign(InputIterator first, InputIterator last) {
|
||||
size_type n = last - first;
|
||||
clear();
|
||||
if (capacity() < n) {
|
||||
change_capacity(n);
|
||||
}
|
||||
while (first != last) {
|
||||
_size++;
|
||||
new(static_cast<void*>(item_ptr(size() - 1))) T(*first);
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
prevector() : _size(0) {}
|
||||
|
||||
explicit prevector(size_type n) : _size(0) {
|
||||
resize(n);
|
||||
}
|
||||
|
||||
explicit prevector(size_type n, const T& val = T()) : _size(0) {
|
||||
change_capacity(n);
|
||||
while (size() < n) {
|
||||
_size++;
|
||||
new(static_cast<void*>(item_ptr(size() - 1))) T(val);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename InputIterator>
|
||||
prevector(InputIterator first, InputIterator last) : _size(0) {
|
||||
size_type n = last - first;
|
||||
change_capacity(n);
|
||||
while (first != last) {
|
||||
_size++;
|
||||
new(static_cast<void*>(item_ptr(size() - 1))) T(*first);
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
prevector(const prevector<N, T, Size, Diff>& other) : _size(0) {
|
||||
change_capacity(other.size());
|
||||
const_iterator it = other.begin();
|
||||
while (it != other.end()) {
|
||||
_size++;
|
||||
new(static_cast<void*>(item_ptr(size() - 1))) T(*it);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
prevector& operator=(const prevector<N, T, Size, Diff>& other) {
|
||||
if (&other == this) {
|
||||
return *this;
|
||||
}
|
||||
resize(0);
|
||||
change_capacity(other.size());
|
||||
const_iterator it = other.begin();
|
||||
while (it != other.end()) {
|
||||
_size++;
|
||||
new(static_cast<void*>(item_ptr(size() - 1))) T(*it);
|
||||
++it;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
size_type size() const {
|
||||
return is_direct() ? _size : _size - N - 1;
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
return size() == 0;
|
||||
}
|
||||
|
||||
iterator begin() { return iterator(item_ptr(0)); }
|
||||
const_iterator begin() const { return const_iterator(item_ptr(0)); }
|
||||
iterator end() { return iterator(item_ptr(size())); }
|
||||
const_iterator end() const { return const_iterator(item_ptr(size())); }
|
||||
|
||||
reverse_iterator rbegin() { return reverse_iterator(item_ptr(size() - 1)); }
|
||||
const_reverse_iterator rbegin() const { return const_reverse_iterator(item_ptr(size() - 1)); }
|
||||
reverse_iterator rend() { return reverse_iterator(item_ptr(-1)); }
|
||||
const_reverse_iterator rend() const { return const_reverse_iterator(item_ptr(-1)); }
|
||||
|
||||
size_t capacity() const {
|
||||
if (is_direct()) {
|
||||
return N;
|
||||
} else {
|
||||
return _union.capacity;
|
||||
}
|
||||
}
|
||||
|
||||
T& operator[](size_type pos) {
|
||||
return *item_ptr(pos);
|
||||
}
|
||||
|
||||
const T& operator[](size_type pos) const {
|
||||
return *item_ptr(pos);
|
||||
}
|
||||
|
||||
void resize(size_type new_size) {
|
||||
while (size() > new_size) {
|
||||
item_ptr(size() - 1)->~T();
|
||||
_size--;
|
||||
}
|
||||
if (new_size > capacity()) {
|
||||
change_capacity(new_size);
|
||||
}
|
||||
while (size() < new_size) {
|
||||
_size++;
|
||||
new(static_cast<void*>(item_ptr(size() - 1))) T();
|
||||
}
|
||||
}
|
||||
|
||||
void reserve(size_type new_capacity) {
|
||||
if (new_capacity > capacity()) {
|
||||
change_capacity(new_capacity);
|
||||
}
|
||||
}
|
||||
|
||||
void shrink_to_fit() {
|
||||
change_capacity(size());
|
||||
}
|
||||
|
||||
void clear() {
|
||||
resize(0);
|
||||
}
|
||||
|
||||
iterator insert(iterator pos, const T& value) {
|
||||
size_type p = pos - begin();
|
||||
size_type new_size = size() + 1;
|
||||
if (capacity() < new_size) {
|
||||
change_capacity(new_size + (new_size >> 1));
|
||||
}
|
||||
memmove(item_ptr(p + 1), item_ptr(p), (size() - p) * sizeof(T));
|
||||
_size++;
|
||||
new(static_cast<void*>(item_ptr(p))) T(value);
|
||||
return iterator(item_ptr(p));
|
||||
}
|
||||
|
||||
void insert(iterator pos, size_type count, const T& value) {
|
||||
size_type p = pos - begin();
|
||||
size_type new_size = size() + count;
|
||||
if (capacity() < new_size) {
|
||||
change_capacity(new_size + (new_size >> 1));
|
||||
}
|
||||
memmove(item_ptr(p + count), item_ptr(p), (size() - p) * sizeof(T));
|
||||
_size += count;
|
||||
for (size_type i = 0; i < count; i++) {
|
||||
new(static_cast<void*>(item_ptr(p + i))) T(value);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename InputIterator>
|
||||
void insert(iterator pos, InputIterator first, InputIterator last) {
|
||||
size_type p = pos - begin();
|
||||
difference_type count = last - first;
|
||||
size_type new_size = size() + count;
|
||||
if (capacity() < new_size) {
|
||||
change_capacity(new_size + (new_size >> 1));
|
||||
}
|
||||
memmove(item_ptr(p + count), item_ptr(p), (size() - p) * sizeof(T));
|
||||
_size += count;
|
||||
while (first != last) {
|
||||
new(static_cast<void*>(item_ptr(p))) T(*first);
|
||||
++p;
|
||||
++first;
|
||||
}
|
||||
}
|
||||
|
||||
iterator erase(iterator pos) {
|
||||
(*pos).~T();
|
||||
memmove(&(*pos), &(*pos) + 1, ((char*)&(*end())) - ((char*)(1 + &(*pos))));
|
||||
_size--;
|
||||
return pos;
|
||||
}
|
||||
|
||||
iterator erase(iterator first, iterator last) {
|
||||
iterator p = first;
|
||||
char* endp = (char*)&(*end());
|
||||
while (p != last) {
|
||||
(*p).~T();
|
||||
_size--;
|
||||
++p;
|
||||
}
|
||||
memmove(&(*first), &(*last), endp - ((char*)(&(*last))));
|
||||
return first;
|
||||
}
|
||||
|
||||
void push_back(const T& value) {
|
||||
size_type new_size = size() + 1;
|
||||
if (capacity() < new_size) {
|
||||
change_capacity(new_size + (new_size >> 1));
|
||||
}
|
||||
new(item_ptr(size())) T(value);
|
||||
_size++;
|
||||
}
|
||||
|
||||
void pop_back() {
|
||||
_size--;
|
||||
}
|
||||
|
||||
T& front() {
|
||||
return *item_ptr(0);
|
||||
}
|
||||
|
||||
const T& front() const {
|
||||
return *item_ptr(0);
|
||||
}
|
||||
|
||||
T& back() {
|
||||
return *item_ptr(size() - 1);
|
||||
}
|
||||
|
||||
const T& back() const {
|
||||
return *item_ptr(size() - 1);
|
||||
}
|
||||
|
||||
void swap(prevector<N, T, Size, Diff>& other) {
|
||||
if (_size & other._size & 1) {
|
||||
std::swap(_union.capacity, other._union.capacity);
|
||||
std::swap(_union.indirect, other._union.indirect);
|
||||
} else {
|
||||
std::swap(_union, other._union);
|
||||
}
|
||||
std::swap(_size, other._size);
|
||||
}
|
||||
|
||||
~prevector() {
|
||||
clear();
|
||||
if (!is_direct()) {
|
||||
free(_union.indirect);
|
||||
_union.indirect = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const prevector<N, T, Size, Diff>& other) const {
|
||||
if (other.size() != size()) {
|
||||
return false;
|
||||
}
|
||||
const_iterator b1 = begin();
|
||||
const_iterator b2 = other.begin();
|
||||
const_iterator e1 = end();
|
||||
while (b1 != e1) {
|
||||
if ((*b1) != (*b2)) {
|
||||
return false;
|
||||
}
|
||||
++b1;
|
||||
++b2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator!=(const prevector<N, T, Size, Diff>& other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
bool operator<(const prevector<N, T, Size, Diff>& other) const {
|
||||
if (size() < other.size()) {
|
||||
return true;
|
||||
}
|
||||
if (size() > other.size()) {
|
||||
return false;
|
||||
}
|
||||
const_iterator b1 = begin();
|
||||
const_iterator b2 = other.begin();
|
||||
const_iterator e1 = end();
|
||||
while (b1 != e1) {
|
||||
if ((*b1) < (*b2)) {
|
||||
return true;
|
||||
}
|
||||
if ((*b2) < (*b1)) {
|
||||
return false;
|
||||
}
|
||||
++b1;
|
||||
++b2;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t allocated_memory() const {
|
||||
if (is_direct()) {
|
||||
return 0;
|
||||
} else {
|
||||
return ((size_t)(sizeof(T))) * _union.capacity;
|
||||
}
|
||||
}
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -15,69 +15,6 @@ uint256 CBlockHeader::GetHash() const
|
||||
return SerializeHash(*this);
|
||||
}
|
||||
|
||||
uint256 CBlock::ComputeMerkleRoot(bool* fMutated) const
|
||||
{
|
||||
/* WARNING! If you're reading this because you're learning about crypto
|
||||
and/or designing a new system that will use merkle trees, keep in mind
|
||||
that the following merkle tree algorithm has a serious flaw related to
|
||||
duplicate txids, resulting in a vulnerability (CVE-2012-2459).
|
||||
|
||||
The reason is that if the number of hashes in the list at a given time
|
||||
is odd, the last one is duplicated before computing the next level (which
|
||||
is unusual in Merkle trees). This results in certain sequences of
|
||||
transactions leading to the same merkle root. For example, these two
|
||||
trees:
|
||||
|
||||
A A
|
||||
/ \ / \
|
||||
B C B C
|
||||
/ \ | / \ / \
|
||||
D E F D E F F
|
||||
/ \ / \ / \ / \ / \ / \ / \
|
||||
1 2 3 4 5 6 1 2 3 4 5 6 5 6
|
||||
|
||||
for transaction lists [1,2,3,4,5,6] and [1,2,3,4,5,6,5,6] (where 5 and
|
||||
6 are repeated) result in the same root hash A (because the hash of both
|
||||
of (F) and (F,F) is C).
|
||||
|
||||
The vulnerability results from being able to send a block with such a
|
||||
transaction list, with the same merkle root, and the same block hash as
|
||||
the original without duplication, resulting in failed validation. If the
|
||||
receiving node proceeds to mark that block as permanently invalid
|
||||
however, it will fail to accept further unmodified (and thus potentially
|
||||
valid) versions of the same block. We defend against this by detecting
|
||||
the case where we would hash two identical hashes at the end of the list
|
||||
together, and treating that identically to the block having an invalid
|
||||
merkle root. Assuming no double-SHA256 collisions, this will detect all
|
||||
known ways of changing the transactions without affecting the merkle
|
||||
root.
|
||||
*/
|
||||
std::vector<uint256> vMerkleTree;
|
||||
vMerkleTree.reserve(vtx.size() * 2 + 16); // Safe upper bound for the number of total nodes.
|
||||
for (std::vector<CTransaction>::const_iterator it(vtx.begin()); it != vtx.end(); ++it)
|
||||
vMerkleTree.push_back(it->GetHash());
|
||||
int j = 0;
|
||||
bool mutated = false;
|
||||
for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2)
|
||||
{
|
||||
for (int i = 0; i < nSize; i += 2)
|
||||
{
|
||||
int i2 = std::min(i+1, nSize-1);
|
||||
if (i2 == i + 1 && i2 + 1 == nSize && vMerkleTree[j+i] == vMerkleTree[j+i2]) {
|
||||
// Two identical hashes at the end of the list at a particular level.
|
||||
mutated = true;
|
||||
}
|
||||
vMerkleTree.push_back(Hash(BEGIN(vMerkleTree[j+i]), END(vMerkleTree[j+i]),
|
||||
BEGIN(vMerkleTree[j+i2]), END(vMerkleTree[j+i2])));
|
||||
}
|
||||
j += nSize;
|
||||
}
|
||||
if (fMutated) {
|
||||
*fMutated = mutated;
|
||||
}
|
||||
return (vMerkleTree.empty() ? uint256() : vMerkleTree.back());
|
||||
}
|
||||
|
||||
std::string CBlock::ToString() const
|
||||
{
|
||||
std::stringstream s;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -118,12 +118,6 @@ public:
|
||||
return block;
|
||||
}
|
||||
|
||||
// Build the merkle tree for this block and return the merkle root.
|
||||
// If non-NULL, *mutated is set to whether mutation was detected in the merkle
|
||||
// tree (a duplication of transactions in the block leading to an identical
|
||||
// merkle root).
|
||||
uint256 ComputeMerkleRoot(bool* mutated = NULL) const;
|
||||
|
||||
std::string ToString() const;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
READWRITE(prevout);
|
||||
READWRITE(scriptSig);
|
||||
READWRITE(*(CScriptBase*)(&scriptSig));
|
||||
READWRITE(nSequence);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
READWRITE(nValue);
|
||||
READWRITE(scriptPubKey);
|
||||
READWRITE(*(CScriptBase*)(&scriptPubKey));
|
||||
}
|
||||
|
||||
void SetNull()
|
||||
|
||||
+64
-5
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -12,14 +12,68 @@
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
namespace NetMsgType {
|
||||
const char *VERSION="version";
|
||||
const char *VERACK="verack";
|
||||
const char *ADDR="addr";
|
||||
const char *INV="inv";
|
||||
const char *GETDATA="getdata";
|
||||
const char *MERKLEBLOCK="merkleblock";
|
||||
const char *GETBLOCKS="getblocks";
|
||||
const char *GETHEADERS="getheaders";
|
||||
const char *TX="tx";
|
||||
const char *HEADERS="headers";
|
||||
const char *BLOCK="block";
|
||||
const char *GETADDR="getaddr";
|
||||
const char *MEMPOOL="mempool";
|
||||
const char *PING="ping";
|
||||
const char *PONG="pong";
|
||||
const char *ALERT="alert";
|
||||
const char *NOTFOUND="notfound";
|
||||
const char *FILTERLOAD="filterload";
|
||||
const char *FILTERADD="filteradd";
|
||||
const char *FILTERCLEAR="filterclear";
|
||||
const char *REJECT="reject";
|
||||
const char *SENDHEADERS="sendheaders";
|
||||
};
|
||||
|
||||
static const char* ppszTypeName[] =
|
||||
{
|
||||
"ERROR",
|
||||
"tx",
|
||||
"block",
|
||||
"filtered block"
|
||||
"ERROR", // Should never occur
|
||||
NetMsgType::TX,
|
||||
NetMsgType::BLOCK,
|
||||
"filtered block" // Should never occur
|
||||
};
|
||||
|
||||
/** All known message types. Keep this in the same order as the list of
|
||||
* messages above and in protocol.h.
|
||||
*/
|
||||
const static std::string allNetMessageTypes[] = {
|
||||
NetMsgType::VERSION,
|
||||
NetMsgType::VERACK,
|
||||
NetMsgType::ADDR,
|
||||
NetMsgType::INV,
|
||||
NetMsgType::GETDATA,
|
||||
NetMsgType::MERKLEBLOCK,
|
||||
NetMsgType::GETBLOCKS,
|
||||
NetMsgType::GETHEADERS,
|
||||
NetMsgType::TX,
|
||||
NetMsgType::HEADERS,
|
||||
NetMsgType::BLOCK,
|
||||
NetMsgType::GETADDR,
|
||||
NetMsgType::MEMPOOL,
|
||||
NetMsgType::PING,
|
||||
NetMsgType::PONG,
|
||||
NetMsgType::ALERT,
|
||||
NetMsgType::NOTFOUND,
|
||||
NetMsgType::FILTERLOAD,
|
||||
NetMsgType::FILTERADD,
|
||||
NetMsgType::FILTERCLEAR,
|
||||
NetMsgType::REJECT,
|
||||
NetMsgType::SENDHEADERS
|
||||
};
|
||||
const static std::vector<std::string> allNetMessageTypesVec(allNetMessageTypes, allNetMessageTypes+ARRAYLEN(allNetMessageTypes));
|
||||
|
||||
CMessageHeader::CMessageHeader(const MessageStartChars& pchMessageStartIn)
|
||||
{
|
||||
memcpy(pchMessageStart, pchMessageStartIn, MESSAGE_START_SIZE);
|
||||
@@ -140,3 +194,8 @@ std::string CInv::ToString() const
|
||||
{
|
||||
return strprintf("%s %s", GetCommand(), hash.ToString());
|
||||
}
|
||||
|
||||
const std::vector<std::string> &getAllNetMessageTypes()
|
||||
{
|
||||
return allNetMessageTypesVec;
|
||||
}
|
||||
|
||||
+160
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -65,6 +65,165 @@ public:
|
||||
unsigned int nChecksum;
|
||||
};
|
||||
|
||||
/**
|
||||
* Bitcoin protocol message types. When adding new message types, don't forget
|
||||
* to update allNetMessageTypes in protocol.cpp.
|
||||
*/
|
||||
namespace NetMsgType {
|
||||
|
||||
/**
|
||||
* The version message provides information about the transmitting node to the
|
||||
* receiving node at the beginning of a connection.
|
||||
* @see https://bitcoin.org/en/developer-reference#version
|
||||
*/
|
||||
extern const char *VERSION;
|
||||
/**
|
||||
* The verack message acknowledges a previously-received version message,
|
||||
* informing the connecting node that it can begin to send other messages.
|
||||
* @see https://bitcoin.org/en/developer-reference#verack
|
||||
*/
|
||||
extern const char *VERACK;
|
||||
/**
|
||||
* The addr (IP address) message relays connection information for peers on the
|
||||
* network.
|
||||
* @see https://bitcoin.org/en/developer-reference#addr
|
||||
*/
|
||||
extern const char *ADDR;
|
||||
/**
|
||||
* The inv message (inventory message) transmits one or more inventories of
|
||||
* objects known to the transmitting peer.
|
||||
* @see https://bitcoin.org/en/developer-reference#inv
|
||||
*/
|
||||
extern const char *INV;
|
||||
/**
|
||||
* The getdata message requests one or more data objects from another node.
|
||||
* @see https://bitcoin.org/en/developer-reference#getdata
|
||||
*/
|
||||
extern const char *GETDATA;
|
||||
/**
|
||||
* The merkleblock message is a reply to a getdata message which requested a
|
||||
* block using the inventory type MSG_MERKLEBLOCK.
|
||||
* @since protocol version 70001 as described by BIP37.
|
||||
* @see https://bitcoin.org/en/developer-reference#merkleblock
|
||||
*/
|
||||
extern const char *MERKLEBLOCK;
|
||||
/**
|
||||
* The getblocks message requests an inv message that provides block header
|
||||
* hashes starting from a particular point in the block chain.
|
||||
* @see https://bitcoin.org/en/developer-reference#getblocks
|
||||
*/
|
||||
extern const char *GETBLOCKS;
|
||||
/**
|
||||
* The getheaders message requests a headers message that provides block
|
||||
* headers starting from a particular point in the block chain.
|
||||
* @since protocol version 31800.
|
||||
* @see https://bitcoin.org/en/developer-reference#getheaders
|
||||
*/
|
||||
extern const char *GETHEADERS;
|
||||
/**
|
||||
* The tx message transmits a single transaction.
|
||||
* @see https://bitcoin.org/en/developer-reference#tx
|
||||
*/
|
||||
extern const char *TX;
|
||||
/**
|
||||
* The headers message sends one or more block headers to a node which
|
||||
* previously requested certain headers with a getheaders message.
|
||||
* @since protocol version 31800.
|
||||
* @see https://bitcoin.org/en/developer-reference#headers
|
||||
*/
|
||||
extern const char *HEADERS;
|
||||
/**
|
||||
* The block message transmits a single serialized block.
|
||||
* @see https://bitcoin.org/en/developer-reference#block
|
||||
*/
|
||||
extern const char *BLOCK;
|
||||
/**
|
||||
* The getaddr message requests an addr message from the receiving node,
|
||||
* preferably one with lots of IP addresses of other receiving nodes.
|
||||
* @see https://bitcoin.org/en/developer-reference#getaddr
|
||||
*/
|
||||
extern const char *GETADDR;
|
||||
/**
|
||||
* The mempool message requests the TXIDs of transactions that the receiving
|
||||
* node has verified as valid but which have not yet appeared in a block.
|
||||
* @since protocol version 60002.
|
||||
* @see https://bitcoin.org/en/developer-reference#mempool
|
||||
*/
|
||||
extern const char *MEMPOOL;
|
||||
/**
|
||||
* The ping message is sent periodically to help confirm that the receiving
|
||||
* peer is still connected.
|
||||
* @see https://bitcoin.org/en/developer-reference#ping
|
||||
*/
|
||||
extern const char *PING;
|
||||
/**
|
||||
* The pong message replies to a ping message, proving to the pinging node that
|
||||
* the ponging node is still alive.
|
||||
* @since protocol version 60001 as described by BIP31.
|
||||
* @see https://bitcoin.org/en/developer-reference#pong
|
||||
*/
|
||||
extern const char *PONG;
|
||||
/**
|
||||
* The alert message warns nodes of problems that may affect them or the rest
|
||||
* of the network.
|
||||
* @since protocol version 311.
|
||||
* @see https://bitcoin.org/en/developer-reference#alert
|
||||
*/
|
||||
extern const char *ALERT;
|
||||
/**
|
||||
* The notfound message is a reply to a getdata message which requested an
|
||||
* object the receiving node does not have available for relay.
|
||||
* @ince protocol version 70001.
|
||||
* @see https://bitcoin.org/en/developer-reference#notfound
|
||||
*/
|
||||
extern const char *NOTFOUND;
|
||||
/**
|
||||
* The filterload message tells the receiving peer to filter all relayed
|
||||
* transactions and requested merkle blocks through the provided filter.
|
||||
* @since protocol version 70001 as described by BIP37.
|
||||
* Only available with service bit NODE_BLOOM since protocol version
|
||||
* 70011 as described by BIP111.
|
||||
* @see https://bitcoin.org/en/developer-reference#filterload
|
||||
*/
|
||||
extern const char *FILTERLOAD;
|
||||
/**
|
||||
* The filteradd message tells the receiving peer to add a single element to a
|
||||
* previously-set bloom filter, such as a new public key.
|
||||
* @since protocol version 70001 as described by BIP37.
|
||||
* Only available with service bit NODE_BLOOM since protocol version
|
||||
* 70011 as described by BIP111.
|
||||
* @see https://bitcoin.org/en/developer-reference#filteradd
|
||||
*/
|
||||
extern const char *FILTERADD;
|
||||
/**
|
||||
* The filterclear message tells the receiving peer to remove a previously-set
|
||||
* bloom filter.
|
||||
* @since protocol version 70001 as described by BIP37.
|
||||
* Only available with service bit NODE_BLOOM since protocol version
|
||||
* 70011 as described by BIP111.
|
||||
* @see https://bitcoin.org/en/developer-reference#filterclear
|
||||
*/
|
||||
extern const char *FILTERCLEAR;
|
||||
/**
|
||||
* The reject message informs the receiving node that one of its previous
|
||||
* messages has been rejected.
|
||||
* @since protocol version 70002 as described by BIP61.
|
||||
* @see https://bitcoin.org/en/developer-reference#reject
|
||||
*/
|
||||
extern const char *REJECT;
|
||||
/**
|
||||
* Indicates that a node prefers to receive new block announcements via a
|
||||
* "headers" message rather than an "inv".
|
||||
* @since protocol version 70012 as described by BIP130.
|
||||
* @see https://bitcoin.org/en/developer-reference#sendheaders
|
||||
*/
|
||||
extern const char *SENDHEADERS;
|
||||
|
||||
};
|
||||
|
||||
/* Get a vector of all valid message types (see above) */
|
||||
const std::vector<std::string> &getAllNetMessageTypes();
|
||||
|
||||
/** nServices flags */
|
||||
enum {
|
||||
// NODE_NETWORK means that the node is capable of serving the block chain. It is currently
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2009-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ int BanTableModel::rowCount(const QModelIndex &parent) const
|
||||
int BanTableModel::columnCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return columns.length();;
|
||||
return columns.length();
|
||||
}
|
||||
|
||||
QVariant BanTableModel::data(const QModelIndex &index, int role) const
|
||||
@@ -178,4 +178,4 @@ bool BanTableModel::shouldShow()
|
||||
if (priv->size() > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
+15
-11
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#endif
|
||||
|
||||
#include "init.h"
|
||||
#include "rpcserver.h"
|
||||
#include "rpc/server.h"
|
||||
#include "scheduler.h"
|
||||
#include "ui_interface.h"
|
||||
#include "util.h"
|
||||
@@ -201,6 +201,8 @@ public:
|
||||
/// Create payment server
|
||||
void createPaymentServer();
|
||||
#endif
|
||||
/// parameter interaction/setup based on rules
|
||||
void parameterSetup();
|
||||
/// Create options model
|
||||
void createOptionsModel(bool resetSettings);
|
||||
/// Create main window
|
||||
@@ -309,14 +311,8 @@ BitcoinApplication::BitcoinApplication(int &argc, char **argv):
|
||||
// UI per-platform customization
|
||||
// This must be done inside the BitcoinApplication constructor, or after it, because
|
||||
// PlatformStyle::instantiate requires a QApplication
|
||||
#if defined(Q_OS_MAC)
|
||||
std::string platformName = "macosx";
|
||||
#elif defined(Q_OS_WIN)
|
||||
std::string platformName = "windows";
|
||||
#else
|
||||
std::string platformName = "other";
|
||||
#endif
|
||||
platformName = GetArg("-uiplatform", platformName);
|
||||
std::string platformName;
|
||||
platformName = GetArg("-uiplatform", BitcoinGUI::DEFAULT_UIPLATFORM);
|
||||
platformStyle = PlatformStyle::instantiate(QString::fromStdString(platformName));
|
||||
if (!platformStyle) // Fall back to "other" if specified name not found
|
||||
platformStyle = PlatformStyle::instantiate("other");
|
||||
@@ -397,6 +393,12 @@ void BitcoinApplication::startThread()
|
||||
coreThread->start();
|
||||
}
|
||||
|
||||
void BitcoinApplication::parameterSetup()
|
||||
{
|
||||
InitLogging();
|
||||
InitParameterInteraction();
|
||||
}
|
||||
|
||||
void BitcoinApplication::requestInitialize()
|
||||
{
|
||||
qDebug() << __func__ << ": Requesting initialize";
|
||||
@@ -644,13 +646,15 @@ int main(int argc, char *argv[])
|
||||
// Install qDebug() message handler to route to debug.log
|
||||
qInstallMessageHandler(DebugMessageHandler);
|
||||
#endif
|
||||
// Allow parameter interaction before we create the options model
|
||||
app.parameterSetup();
|
||||
// Load GUI settings from QSettings
|
||||
app.createOptionsModel(mapArgs.count("-resetguisettings") != 0);
|
||||
|
||||
// Subscribe to global signals from core
|
||||
uiInterface.InitMessage.connect(InitMessage);
|
||||
|
||||
if (GetBoolArg("-splash", true) && !GetBoolArg("-min", false))
|
||||
if (GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !GetBoolArg("-min", false))
|
||||
app.createSplashScreen(networkStyle.data());
|
||||
|
||||
try
|
||||
|
||||
@@ -46,6 +46,9 @@
|
||||
<file alias="about_qt">res/icons/about_qt.png</file>
|
||||
<file alias="verify">res/icons/verify.png</file>
|
||||
<file alias="warning">res/icons/warning.png</file>
|
||||
<file alias="fontbigger">res/icons/fontbigger.png</file>
|
||||
<file alias="fontsmaller">res/icons/fontsmaller.png</file>
|
||||
<file alias="prompticon">res/icons/chevron.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/movies">
|
||||
<file alias="spinner-000">res/movies/spinner-000.png</file>
|
||||
|
||||
@@ -1,36 +1,40 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource prefix="/translations">
|
||||
<file alias="ach">locale/bitcoin_ach.qm</file>
|
||||
<file alias="af_ZA">locale/bitcoin_af_ZA.qm</file>
|
||||
<file alias="ar">locale/bitcoin_ar.qm</file>
|
||||
<file alias="be_BY">locale/bitcoin_be_BY.qm</file>
|
||||
<file alias="bg_BG">locale/bitcoin_bg_BG.qm</file>
|
||||
<file alias="bg">locale/bitcoin_bg.qm</file>
|
||||
<file alias="bs">locale/bitcoin_bs.qm</file>
|
||||
<file alias="ca_ES">locale/bitcoin_ca_ES.qm</file>
|
||||
<file alias="ca">locale/bitcoin_ca.qm</file>
|
||||
<file alias="ca@valencia">locale/bitcoin_ca@valencia.qm</file>
|
||||
<file alias="cmn">locale/bitcoin_cmn.qm</file>
|
||||
<file alias="cs_CZ">locale/bitcoin_cs_CZ.qm</file>
|
||||
<file alias="cs">locale/bitcoin_cs.qm</file>
|
||||
<file alias="cy">locale/bitcoin_cy.qm</file>
|
||||
<file alias="da">locale/bitcoin_da.qm</file>
|
||||
<file alias="de">locale/bitcoin_de.qm</file>
|
||||
<file alias="el_GR">locale/bitcoin_el_GR.qm</file>
|
||||
<file alias="el">locale/bitcoin_el.qm</file>
|
||||
<file alias="en_GB">locale/bitcoin_en_GB.qm</file>
|
||||
<file alias="en">locale/bitcoin_en.qm</file>
|
||||
<file alias="eo">locale/bitcoin_eo.qm</file>
|
||||
<file alias="es_CL">locale/bitcoin_es_CL.qm</file>
|
||||
<file alias="es_DO">locale/bitcoin_es_DO.qm</file>
|
||||
<file alias="es_ES">locale/bitcoin_es_ES.qm</file>
|
||||
<file alias="es_MX">locale/bitcoin_es_MX.qm</file>
|
||||
<file alias="es">locale/bitcoin_es.qm</file>
|
||||
<file alias="es_UY">locale/bitcoin_es_UY.qm</file>
|
||||
<file alias="es_VE">locale/bitcoin_es_VE.qm</file>
|
||||
<file alias="et">locale/bitcoin_et.qm</file>
|
||||
<file alias="eu_ES">locale/bitcoin_eu_ES.qm</file>
|
||||
<file alias="fa_IR">locale/bitcoin_fa_IR.qm</file>
|
||||
<file alias="fa">locale/bitcoin_fa.qm</file>
|
||||
<file alias="fi">locale/bitcoin_fi.qm</file>
|
||||
<file alias="fr_CA">locale/bitcoin_fr_CA.qm</file>
|
||||
<file alias="fr_FR">locale/bitcoin_fr_FR.qm</file>
|
||||
<file alias="fr">locale/bitcoin_fr.qm</file>
|
||||
<file alias="gl">locale/bitcoin_gl.qm</file>
|
||||
<file alias="gu_IN">locale/bitcoin_gu_IN.qm</file>
|
||||
<file alias="he">locale/bitcoin_he.qm</file>
|
||||
<file alias="hi_IN">locale/bitcoin_hi_IN.qm</file>
|
||||
<file alias="hr">locale/bitcoin_hr.qm</file>
|
||||
@@ -45,6 +49,7 @@
|
||||
<file alias="la">locale/bitcoin_la.qm</file>
|
||||
<file alias="lt">locale/bitcoin_lt.qm</file>
|
||||
<file alias="lv_LV">locale/bitcoin_lv_LV.qm</file>
|
||||
<file alias="mk_MK">locale/bitcoin_mk_MK.qm</file>
|
||||
<file alias="mn">locale/bitcoin_mn.qm</file>
|
||||
<file alias="ms_MY">locale/bitcoin_ms_MY.qm</file>
|
||||
<file alias="nb">locale/bitcoin_nb.qm</file>
|
||||
@@ -54,14 +59,15 @@
|
||||
<file alias="pt_BR">locale/bitcoin_pt_BR.qm</file>
|
||||
<file alias="pt_PT">locale/bitcoin_pt_PT.qm</file>
|
||||
<file alias="ro_RO">locale/bitcoin_ro_RO.qm</file>
|
||||
<file alias="ru_RU">locale/bitcoin_ru_RU.qm</file>
|
||||
<file alias="ru">locale/bitcoin_ru.qm</file>
|
||||
<file alias="sah">locale/bitcoin_sah.qm</file>
|
||||
<file alias="sk">locale/bitcoin_sk.qm</file>
|
||||
<file alias="sl_SI">locale/bitcoin_sl_SI.qm</file>
|
||||
<file alias="sq">locale/bitcoin_sq.qm</file>
|
||||
<file alias="sr">locale/bitcoin_sr.qm</file>
|
||||
<file alias="sv">locale/bitcoin_sv.qm</file>
|
||||
<file alias="th_TH">locale/bitcoin_th_TH.qm</file>
|
||||
<file alias="tr_TR">locale/bitcoin_tr_TR.qm</file>
|
||||
<file alias="tr">locale/bitcoin_tr.qm</file>
|
||||
<file alias="uk">locale/bitcoin_uk.qm</file>
|
||||
<file alias="ur_PK">locale/bitcoin_ur_PK.qm</file>
|
||||
@@ -69,7 +75,7 @@
|
||||
<file alias="vi">locale/bitcoin_vi.qm</file>
|
||||
<file alias="vi_VN">locale/bitcoin_vi_VN.qm</file>
|
||||
<file alias="zh_CN">locale/bitcoin_zh_CN.qm</file>
|
||||
<file alias="zh_HK">locale/bitcoin_zh_HK.qm</file>
|
||||
<file alias="zh">locale/bitcoin_zh.qm</file>
|
||||
<file alias="zh_TW">locale/bitcoin_zh_TW.qm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2011-2013 The Bitcoin Core developers
|
||||
// Copyright (c) 2011-2015 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user