Bring in backends from the dead branch

This commit is contained in:
Vinnie Falco
2013-07-10 10:21:42 -07:00
parent dd65bd8a72
commit 4b5daa70c9
14 changed files with 431 additions and 47 deletions

View File

@@ -0,0 +1,88 @@
//------------------------------------------------------------------------------
/*
Copyright (c) 2011-2013, OpenCoin, Inc.
*/
//==============================================================================
#ifndef RIPPLE_HASHEDOBJECT_H
#define RIPPLE_HASHEDOBJECT_H
/** The types of hashed objects.
*/
enum HashedObjectType
{
hotUNKNOWN = 0,
hotLEDGER = 1,
hotTRANSACTION = 2,
hotACCOUNT_NODE = 3,
hotTRANSACTION_NODE = 4
};
/** A blob of data with associated metadata, referenced by hash.
The metadata includes the following:
- Type of the blob
- The ledger index in which it appears
- The SHA 256 hash
@note No checking is performed to make sure the hash matches the data.
@see SHAMap
*/
// VFALCO TODO consider making the instance a private member of SHAMap
// since its the primary user.
//
class HashedObject
: public CountedObject <HashedObject>
{
public:
static char const* getCountedObjectName () { return "HashedObject"; }
typedef boost::shared_ptr <HashedObject> pointer;
typedef pointer const& ref;
/** Create from a vector of data.
@note A copy of the data is created.
*/
HashedObject (HashedObjectType type,
LedgerIndex ledgerIndex,
Blob const & binaryDataToCopy,
uint256 const & hash);
/** Create from an area of memory.
@note A copy of the data is created.
*/
HashedObject (HashedObjectType type,
LedgerIndex ledgerIndex,
void const * bufferToCopy,
int bytesInBuffer,
uint256 const & hash);
/** Retrieve the type of this object.
*/
HashedObjectType getType () const;
/** Retrieve the hash metadata.
*/
uint256 const& getHash () const;
/** Retrieve the ledger index in which this object appears.
*/
// VFALCO TODO rename to getLedgerIndex or getLedgerId
LedgerIndex getIndex () const;
/** Retrieve the binary data.
*/
Blob const& getData () const;
private:
HashedObjectType const mType;
uint256 const mHash;
LedgerIndex const mLedgerIndex;
Blob const mData;
};
#endif
// vim:ts=4