Some tiny bugfixes:

* Don't let ledger idle interval get too short
* Fix CBigNum::setuint256
* Fix SqliteStatement::isError
* Remove dead code, fix incorrect comments
* Check for NULL earlier in CKey constructors
* Prevent expire times from underflowing in TaggedCache
This commit is contained in:
JoelKatz
2014-01-06 23:47:24 -08:00
committed by Vinnie Falco
parent e3a67b13ff
commit e25a83bb39
7 changed files with 14 additions and 10 deletions

View File

@@ -228,7 +228,7 @@ void CBigNum::setuint64 (uint64 n)
void CBigNum::setuint256 (uint256 const& n) void CBigNum::setuint256 (uint256 const& n)
{ {
BN_bin2bn (n.begin (), n.size (), NULL); BN_bin2bn (n.begin (), n.size (), this);
} }
uint256 CBigNum::getuint256 () uint256 CBigNum::getuint256 ()

View File

@@ -606,6 +606,9 @@ public:
idleInterval = LEDGER_IDLE_INTERVAL; idleInterval = LEDGER_IDLE_INTERVAL;
} }
idleInterval = std::max (idleInterval, LEDGER_IDLE_INTERVAL);
idleInterval = std::max (idleInterval, 2 * mPreviousLedger->getCloseResolution ());
if (ContinuousLedgerTiming::shouldClose (anyTransactions if (ContinuousLedgerTiming::shouldClose (anyTransactions
, mPreviousProposers, proposersClosed, proposersValidated , mPreviousProposers, proposersClosed, proposersValidated
, mPreviousMSeconds, sinceClose, mCurrentMSeconds , mPreviousMSeconds, sinceClose, mCurrentMSeconds

View File

@@ -471,10 +471,10 @@ bool SqliteStatement::isError (int j)
case SQLITE_OK: case SQLITE_OK:
case SQLITE_ROW: case SQLITE_ROW:
case SQLITE_DONE: case SQLITE_DONE:
return true; return false;
default: default:
return false; return true;
} }
} }

View File

@@ -1488,7 +1488,7 @@ uint256 Ledger::getLedgerFeeIndex ()
uint256 Ledger::getLedgerFeatureIndex () uint256 Ledger::getLedgerFeatureIndex ()
{ {
// get the index of the node that holds the last 256 ledgers // get the index of the node that holds the enabled features
Serializer s (2); Serializer s (2);
s.add16 (spaceFeature); s.add16 (spaceFeature);
return s.getSHA512Half (); return s.getSHA512Half ();

View File

@@ -63,7 +63,6 @@ public:
uint32 mLastValidateSeq; uint32 mLastValidateSeq;
std::list<callback> mOnValidate; // Called when a ledger has enough validations std::list<callback> mOnValidate; // Called when a ledger has enough validations
std::list<Ledger::pointer> mPubLedgers; // List of ledgers to publish
bool mAdvanceThread; // Publish thread is running bool mAdvanceThread; // Publish thread is running
bool mAdvanceWork; // Publish thread has work to do bool mAdvanceWork; // Publish thread has work to do
int mFillInProgress; int mFillInProgress;
@@ -297,7 +296,7 @@ public:
{ {
TransactionEngineParams tepFlags = tapOPEN_LEDGER; TransactionEngineParams tepFlags = tapOPEN_LEDGER;
if (getApp().getHashRouter ().addSuppressionPeer (it->first.getTXID (), SF_SIGGOOD)) if (getApp().getHashRouter ().addSuppressionFlags (it->first.getTXID (), SF_SIGGOOD))
tepFlags = static_cast<TransactionEngineParams> (tepFlags | tapNO_CHECK_SIGN); tepFlags = static_cast<TransactionEngineParams> (tepFlags | tapNO_CHECK_SIGN);
bool didApply; bool didApply;

View File

@@ -301,13 +301,13 @@ void TaggedCacheType<c_Key, c_Data, Timer>::sweep ()
ScopedLockType sl (mLock, __FILE__, __LINE__); ScopedLockType sl (mLock, __FILE__, __LINE__);
int const now = Timer::getElapsedSeconds (); int const now = Timer::getElapsedSeconds ();
int target = now - mTargetAge; int target = (now < mTargetAge) ? 0 : (now - mTargetAge);
if ((mTargetSize != 0) && (static_cast<int> (mCache.size ()) > mTargetSize)) if ((mTargetSize != 0) && (static_cast<int> (mCache.size ()) > mTargetSize))
{ {
target = now - (mTargetAge * mTargetSize / mCache.size ()); target = now - (mTargetAge * mTargetSize / mCache.size ());
if (target > (now - 2)) if ((now > 2) && (target > (now - 2)))
target = now - 2; target = now - 2;
WriteLog (lsINFO, TaggedCacheLog) << mName << " is growing fast " << WriteLog (lsINFO, TaggedCacheLog) << mName << " is growing fast " <<

View File

@@ -92,22 +92,24 @@ public:
CKey () CKey ()
{ {
pkey = EC_KEY_new_by_curve_name (NID_secp256k1); pkey = EC_KEY_new_by_curve_name (NID_secp256k1);
EC_KEY_set_conv_form (pkey, POINT_CONVERSION_COMPRESSED);
if (pkey == NULL) if (pkey == NULL)
throw key_error ("CKey::CKey() : EC_KEY_new_by_curve_name failed"); throw key_error ("CKey::CKey() : EC_KEY_new_by_curve_name failed");
EC_KEY_set_conv_form (pkey, POINT_CONVERSION_COMPRESSED);
fSet = false; fSet = false;
} }
CKey (const CKey& b) CKey (const CKey& b)
{ {
pkey = EC_KEY_dup (b.pkey); pkey = EC_KEY_dup (b.pkey);
EC_KEY_set_conv_form (pkey, POINT_CONVERSION_COMPRESSED);
if (pkey == NULL) if (pkey == NULL)
throw key_error ("CKey::CKey(const CKey&) : EC_KEY_dup failed"); throw key_error ("CKey::CKey(const CKey&) : EC_KEY_dup failed");
EC_KEY_set_conv_form (pkey, POINT_CONVERSION_COMPRESSED);
fSet = b.fSet; fSet = b.fSet;
} }