#ifndef __HASHEDOBJECT__ #define __HASHEDOBJECT__ #include #include "types.h" #include "uint256.h" #include "ScopedLock.h" #include "TaggedCache.h" enum HashedObjectType { UNKNOWN = 0, LEDGER = 1, TRANSACTION = 2, ACCOUNT_NODE = 3, TRANSACTION_NODE = 4 }; class HashedObject { public: typedef boost::shared_ptr pointer; HashedObjectType mType; uint256 mHash; uint32 mLedgerIndex; std::vector mData; HashedObject(HashedObjectType type, uint32 index, const std::vector& data, const uint256& hash) : mType(type), mHash(hash), mLedgerIndex(index), mData(data) { ; } const std::vector& getData() { return mData; } const uint256& getHash() { return mHash; } HashedObjectType getType() { return mType; } uint32 getIndex() { return mLedgerIndex; } }; class HashedObjectStore { protected: TaggedCache mCache; boost::recursive_mutex mWriteMutex; std::vector< boost::shared_ptr > mWriteSet; bool mWritePending; public: HashedObjectStore(int cacheSize, int cacheAge); bool store(HashedObjectType type, uint32 index, const std::vector& data, const uint256& hash); HashedObject::pointer retrieve(const uint256& hash); void bulkWrite(); }; #endif