mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Bring in backends from the dead branch
This commit is contained in:
88
modules/ripple_app/node/ripple_HashedObject.h
Normal file
88
modules/ripple_app/node/ripple_HashedObject.h
Normal 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
|
||||
Reference in New Issue
Block a user