Browse Source

Merge pull request #300 from dryabov/bitcoin-ndebug

Fix support of NDEBUG
miguelfreitas
miguelfreitas 10 years ago
parent
commit
4019d5cfba
  1. 2
      configure.ac
  2. 9
      src/key.cpp
  3. 6
      src/main.cpp

2
configure.ac

@ -442,7 +442,7 @@ AS_CASE(["$ARG_ENABLE_DEBUG"], @@ -442,7 +442,7 @@ AS_CASE(["$ARG_ENABLE_DEBUG"],
],
["no"], [
AC_MSG_RESULT([no])
#AC_DEFINE([NDEBUG],[1],[Define to disable debug code.])
AC_DEFINE([NDEBUG],[1],[Define to disable debug code.])
#COMPILETIME_OPTIONS="$COMPILETIME_OPTIONS -DNDEBUG "
DEBUGFLAGS="-Os"
],

9
src/key.cpp

@ -164,8 +164,10 @@ public: @@ -164,8 +164,10 @@ public:
void SetSecretBytes(const unsigned char vch[32]) {
BIGNUM bn;
BN_init(&bn);
assert(BN_bin2bn(vch, 32, &bn));
assert(EC_KEY_regenerate_key(pkey, &bn));
bool check = BN_bin2bn(vch, 32, &bn);
assert(check);
check = EC_KEY_regenerate_key(pkey, &bn);
assert(check);
BN_clear_free(&bn);
}
@ -210,7 +212,8 @@ public: @@ -210,7 +212,8 @@ public:
bool Sign(const uint256 &hash, std::vector<unsigned char>& vchSig) {
unsigned int nSize = ECDSA_size(pkey);
vchSig.resize(nSize); // Make sure it is big enough
assert(ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey));
bool check = ECDSA_sign(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], &nSize, pkey);
assert(check);
vchSig.resize(nSize); // Shrink to fit actual size
return true;
}

6
src/main.cpp

@ -1264,7 +1264,8 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C @@ -1264,7 +1264,8 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
}
// add this block to the view's block chain
assert(view.SetBestBlock(pindex));
bool check = view.SetBestBlock(pindex);
assert(check);
// Watch for transactions paying to me
for (unsigned int i = 0; i < block.vtx.size(); i++)
@ -1368,7 +1369,8 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew) @@ -1368,7 +1369,8 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew)
// Flush changes to global coin state
int64 nStart = GetTimeMicros();
int nModified = view.GetCacheSize();
assert(view.Flush());
bool check = view.Flush();
assert(check);
int64 nTime = GetTimeMicros() - nStart;
if (fBenchmark)
printf("- Flush %i transactions: %.2fms (%.4fms/tx)\n", nModified, 0.001 * nTime, 0.001 * nTime / nModified);

Loading…
Cancel
Save