Add LeakChecked qualifiers to key classes

This commit is contained in:
Vinnie Falco
2013-06-30 03:49:41 -07:00
parent c46b35732a
commit 68179cfce3
38 changed files with 93 additions and 67 deletions

View File

@@ -2,6 +2,8 @@
RIPPLE TODO
--------------------------------------------------------------------------------
- Merge ripple_Version.h and ripple_BuildVersion.h
- Restructure the ripple sources to have this directory structure:
/Source/ripple/ripple_core/ripple_core.h
etc...

View File

@@ -4,8 +4,8 @@
*/
//==============================================================================
#ifndef RIPPLE_KEYCACHE_H
#define RIPPLE_KEYCACHE_H
#ifndef RIPPLE_KEYCACHE_H_INCLUDED
#define RIPPLE_KEYCACHE_H_INCLUDED
/** Maintains a cache of keys with no associated data.
@@ -36,7 +36,10 @@ public:
*/
KeyCache (const std::string& name,
int size = 0,
int age = 120) : mName (name), mTargetSize (size), mTargetAge (age)
int age = 120)
: mName (name)
, mTargetSize (size)
, mTargetAge (age)
{
assert ((size >= 0) && (age > 2));
}
@@ -80,7 +83,7 @@ public:
/** Retrieve the name of this object.
*/
const std::string& getName ()
std::string const& getName ()
{
return mName;
}

View File

@@ -34,7 +34,7 @@ uint32 RangeSet::getFirst () const
const_iterator it = mRanges.begin ();
if (it == mRanges.end ())
return RangeSetAbsent;
return absent;
return it->first;
}
@@ -49,7 +49,7 @@ uint32 RangeSet::getNext (uint32 v) const
if (contains (it, v + 1))
return v + 1;
}
return RangeSetAbsent;
return absent;
}
uint32 RangeSet::getLast () const
@@ -57,7 +57,7 @@ uint32 RangeSet::getLast () const
const_reverse_iterator it = mRanges.rbegin ();
if (it == mRanges.rend ())
return RangeSetAbsent;
return absent;
return it->second;
}
@@ -72,7 +72,7 @@ uint32 RangeSet::getPrev (uint32 v) const
if (contains (it, v + 1))
return v - 1;
}
return RangeSetAbsent;
return absent;
}
uint32 RangeSet::prevMissing (uint32 v) const
@@ -86,7 +86,7 @@ uint32 RangeSet::prevMissing (uint32 v) const
if (it.first > (v + 1))
return v + 1;
}
return RangeSetAbsent;
return absent;
}
void RangeSet::setValue (uint32 v)

View File

@@ -4,8 +4,8 @@
*/
//==============================================================================
#ifndef RIPPLE_RANGESET_H
#define RIPPLE_RANGESET_H
#ifndef RIPPLE_RANGESET_H_INCLUDED
#define RIPPLE_RANGESET_H_INCLUDED
/** A sparse set of integers.
*/
@@ -13,39 +13,45 @@
class RangeSet
{
public:
static const uint32 RangeSetAbsent = static_cast<uint32> (-1);
protected:
std::map<uint32, uint32> mRanges; // First is lowest value in range, last is highest value in range
typedef std::map<uint32, uint32>::const_iterator const_iterator;
typedef std::map<uint32, uint32>::const_reverse_iterator const_reverse_iterator;
typedef std::map<uint32, uint32>::value_type value_type;
typedef std::map<uint32, uint32>::iterator iterator;
static bool contains (value_type const& it, uint32 v)
{
return (it.first <= v) && (it.second >= v);
}
void simplify ();
static const uint32 absent = static_cast <uint32> (-1);
public:
RangeSet () { }
bool hasValue (uint32) const;
uint32 getFirst () const;
uint32 getNext (uint32) const;
uint32 getLast () const;
uint32 getPrev (uint32) const;
uint32 prevMissing (uint32) const; // largest number not in the set that is less than the given number
// largest number not in the set that is less than the given number
uint32 prevMissing (uint32) const;
void setValue (uint32);
void setRange (uint32, uint32);
void clearValue (uint32);
std::string toString () const;
private:
void simplify ();
private:
typedef std::map <uint32, uint32> Map;
typedef Map::const_iterator const_iterator;
typedef Map::const_reverse_iterator const_reverse_iterator;
typedef Map::value_type value_type;
typedef Map::iterator iterator;
static bool contains (value_type const& it, uint32 v)
{
return (it.first <= v) && (it.second >= v);
}
// First is lowest value in range, last is highest value in range
Map mRanges;
};
#endif

View File

@@ -4,8 +4,8 @@
*/
//==============================================================================
#ifndef RIPPLE_SECUREALLOCATOR_H
#define RIPPLE_SECUREALLOCATOR_H
#ifndef RIPPLE_SECUREALLOCATOR_H_INCLUDED
#define RIPPLE_SECUREALLOCATOR_H_INCLUDED
//
// Allocator that locks its contents from being paged

View File

@@ -14,8 +14,7 @@
done by seeding the hashing function with a random number generated
at program startup.
*/
// VFALCO TODO derive from Uncopyable
class HashMaps // : beast::Uncopayble
class HashMaps : Uncopyable
{
public:
/** Golden ratio constant used in hashing functions.

View File

@@ -83,7 +83,7 @@ private:
@ingroup ripple_basics
*/
template <class Object>
class CountedObject
class CountedObject : LeakChecked <CountedObject <Object> >
{
public:
CountedObject ()

View File

@@ -11,7 +11,9 @@
// Async https client.
//
class HttpsClient : public boost::enable_shared_from_this<HttpsClient>
class HttpsClient
: public boost::enable_shared_from_this <HttpsClient>
, LeakChecked <HttpsClient>
{
public:
HttpsClient (

View File

@@ -179,7 +179,7 @@ bool LedgerMaster::haveLedgerRange (uint32 from, uint32 to)
{
boost::recursive_mutex::scoped_lock sl (mLock);
uint32 prevMissing = mCompleteLedgers.prevMissing (to + 1);
return (prevMissing == RangeSet::RangeSetAbsent) || (prevMissing < from);
return (prevMissing == RangeSet::absent) || (prevMissing < from);
}
bool LedgerMaster::haveLedger (uint32 seq)
@@ -202,7 +202,7 @@ bool LedgerMaster::getValidatedRange (uint32& minVal, uint32& maxVal)
minVal = mCompleteLedgers.prevMissing (maxVal);
if (minVal == RangeSet::RangeSetAbsent)
if (minVal == RangeSet::absent)
minVal = 0;
else
++minVal;
@@ -440,7 +440,7 @@ void LedgerMaster::resumeAcquiring ()
uint32 prevMissing = mCompleteLedgers.prevMissing (mFinalizedLedger->getLedgerSeq ());
if (prevMissing == RangeSet::RangeSetAbsent)
if (prevMissing == RangeSet::absent)
{
WriteLog (lsDEBUG, LedgerMaster) << "no prior missing ledger, not resuming";
return;
@@ -564,7 +564,7 @@ void LedgerMaster::setFullLedger (Ledger::pointer ledger)
{
uint32 prevMissing = mCompleteLedgers.prevMissing (ledger->getLedgerSeq ());
if (prevMissing == RangeSet::RangeSetAbsent)
if (prevMissing == RangeSet::absent)
{
WriteLog (lsDEBUG, LedgerMaster) << "no prior missing ledger";
return;

View File

@@ -14,7 +14,7 @@
// VFALCO TODO Rename to Ledgers
// It sounds like this holds all the ledgers...
//
class LedgerMaster
class LedgerMaster : LeakChecked <LedgerMaster>
{
public:
typedef FUNCTION_TYPE <void (Ledger::ref)> callback;

View File

@@ -13,7 +13,7 @@
class Peer;
class LedgerConsensus;
class NetworkOPs
class NetworkOPs : LeakChecked <NetworkOPs>
{
public:
enum Fault

View File

@@ -34,7 +34,7 @@ private:
boost::recursive_mutex mLock;
};
class OrderBookDB
class OrderBookDB : LeakChecked <OrderBookDB>
{
public:
OrderBookDB ();

View File

@@ -11,7 +11,7 @@
Handles incoming connections from other Peers
*/
class PeerDoor
class PeerDoor : LeakChecked <PeerDoor>
{
public:
PeerDoor (boost::asio::io_service& io_service);

View File

@@ -11,7 +11,7 @@
Handles incoming connections from people making RPC Requests
*/
class RPCDoor
class RPCDoor : LeakChecked <RPCDoor>
{
public:
explicit RPCDoor (boost::asio::io_service& io_service);

View File

@@ -7,7 +7,9 @@
#ifndef __RPCSERVER__
#define __RPCSERVER__
class RPCServer : public boost::enable_shared_from_this<RPCServer>
class RPCServer
: public boost::enable_shared_from_this<RPCServer>
, LeakChecked <RPCServer>
{
public:

View File

@@ -10,7 +10,9 @@
#define RPC_EVENT_QUEUE_MAX 32
// Subscription object for JSON-RPC
class RPCSub : public InfoSub
class RPCSub
: public InfoSub
, LeakChecked <RPCSub>
{
public:
typedef boost::shared_ptr<RPCSub> pointer;

View File

@@ -20,7 +20,7 @@ public:
}
};
class SNTPClient
class SNTPClient : LeakChecked <SNTPClient>
{
public:
SNTPClient (boost::asio::io_service& service);

View File

@@ -9,7 +9,7 @@
// Tracks all transactions in memory
class TransactionMaster
class TransactionMaster : LeakChecked <TransactionMaster>
{
public:
TransactionMaster ();

View File

@@ -7,7 +7,7 @@
#ifndef RIPPLE_TRANSACTIONMETA_H
#define RIPPLE_TRANSACTIONMETA_H
class TransactionMetaSet
class TransactionMetaSet : LeakChecked <TransactionMetaSet>
{
public:
typedef boost::shared_ptr<TransactionMetaSet> pointer;

View File

@@ -53,7 +53,7 @@ private:
void addCallbacks (const TXQEntry& otherEntry);
};
class TXQueue
class TXQueue : LeakChecked <TXQueue>
{
public:
TXQueue () : mRunning (false)

View File

@@ -7,7 +7,7 @@
#ifndef RIPPLE_WSDOOR_RIPPLEHEADER
#define RIPPLE_WSDOOR_RIPPLEHEADER
class WSDoor
class WSDoor : LeakChecked <WSDoor>
{
private:
websocketpp::server_autotls* mSEndpoint;

View File

@@ -23,7 +23,9 @@ struct WSServerHandlerLog;
// This instance dispatches all events. There is no per connection persistence.
template <typename endpoint_type>
class WSServerHandler : public endpoint_type::handler
class WSServerHandler
: public endpoint_type::handler
, LeakChecked <WSServerHandler <endpoint_type> >
{
public:
typedef typename endpoint_type::handler::connection_ptr connection_ptr;

View File

@@ -9,7 +9,7 @@
/** A set of AccountItem objects.
*/
class AccountItems
class AccountItems : LeakChecked <AccountItems>
{
public:
typedef boost::shared_ptr <AccountItems> pointer;

View File

@@ -11,7 +11,7 @@
// Provide abstract access to an account's state, such that access to the serialized format is hidden.
//
class AccountState
class AccountState : LeakChecked <AccountState>
{
public:
typedef boost::shared_ptr<AccountState> pointer;

View File

@@ -15,7 +15,7 @@
*/
// VFALCO TODO rename to SortedTxSet
class CanonicalTXSet
class CanonicalTXSet : LeakChecked <CanonicalTXSet>
{
public:
class Key

View File

@@ -10,7 +10,7 @@
/** Persistency layer for hashed objects.
*/
// VFALCO TODO Move all definitions to the .cpp
class HashedObjectStore
class HashedObjectStore : LeakChecked <HashedObjectStore>
{
public:
HashedObjectStore (int cacheSize, int cacheAge);

View File

@@ -20,7 +20,7 @@ enum POWResult
// VFALCO TODO move this to the class as a static member and rename it
bool powResultInfo (POWResult powCode, std::string& strToken, std::string& strHuman);
class IProofOfWorkFactory
class IProofOfWorkFactory : LeakChecked <IProofOfWorkFactory>
{
public:
typedef boost::bimap< boost::bimaps::multiset_of<time_t>, boost::bimaps::unordered_set_of<uint256> > powMap_t;

View File

@@ -11,7 +11,7 @@
typedef boost::unordered_map<uint160, SerializedValidation::pointer> ValidationSet;
typedef std::pair<int, uint160> currentValidationCount; // nodes validating and highest node ID validating
class IValidations
class IValidations : LeakChecked <IValidations>
{
public:
static IValidations* New ();

View File

@@ -13,7 +13,7 @@
*/
// VFALCO TODO Rename to InboundLedgers
// VFALCO TODO Create abstract interface
class InboundLedgers
class InboundLedgers : LeakChecked <InboundLedger>
{
public:
// How long before we try again to acquire the same ledger

View File

@@ -8,7 +8,7 @@
#define RIPPLE_LEDGERHISTORY_H
// VFALCO TODO Rename to OldLedgers ?
class LedgerHistory
class LedgerHistory : LeakChecked <LedgerHistory>
{
public:
LedgerHistory ();

View File

@@ -9,7 +9,7 @@
/** Holds the cryptographic credentials identifying this instance of the server.
*/
class LocalCredentials // derive from Uncopyable
class LocalCredentials : Uncopyable
{
public:
LocalCredentials ();

View File

@@ -10,7 +10,7 @@
/** Describes a serialized ledger entry for an order book.
*/
class OrderBook
class OrderBook : LeakChecked <OrderBook>
{
public:
typedef boost::shared_ptr <OrderBook> pointer;

View File

@@ -10,7 +10,9 @@
// VFALCO TODO Couldn't this be a struct?
typedef std::pair <std::string, int> ipPort;
class Peer : public boost::enable_shared_from_this <Peer>
class Peer
: public boost::enable_shared_from_this <Peer>
, LeakChecked <Peer>
{
public:
typedef boost::shared_ptr<Peer> pointer;

View File

@@ -11,7 +11,7 @@
A peer set is used to acquire a ledger or a transaction set.
*/
class PeerSet
class PeerSet : LeakChecked <PeerSet>
{
public:
uint256 const& getHash () const

View File

@@ -14,7 +14,9 @@ class Peers;
SETUP_LOG (Peers)
class Peers : public IPeers
class Peers
: public IPeers
, LeakChecked <Peers>
{
public:
explicit Peers (boost::asio::io_service& io_service)

View File

@@ -7,7 +7,7 @@
#ifndef RIPPLE_PROOFOFWORK_H
#define RIPPLE_PROOFOFWORK_H
class ProofOfWork
class ProofOfWork : LeakChecked <ProofOfWork>
{
public:
static const int sMaxDifficulty;

View File

@@ -9,7 +9,9 @@
// PRIVATE HEADER
class ProofOfWorkFactory : public IProofOfWorkFactory
class ProofOfWorkFactory
: public IProofOfWorkFactory
, LeakChecked <ProofOfWorkFactory>
{
public:
ProofOfWorkFactory ();

View File

@@ -6,10 +6,12 @@
#ifndef RIPPLE_VERSION_H
#define RIPPLE_VERSION_H
//
// Versions
//
// VFALCO TODO Roll this together into ripple_BuildVersion
#define SERVER_VERSION_MAJOR 0
#define SERVER_VERSION_MINOR 9
#define SERVER_VERSION_SUB "-b"