// Copyright (c) 2012-2015, The CryptoNote developers, The Bytecoin developers // // This file is part of Bytecoin. // // Bytecoin is free software: you can redistribute it and/or modify // it under the terms of the GNU Lesser General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Bytecoin is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public License // along with Bytecoin. If not, see . #pragma once #include #include #include #include "crypto/hash.h" #include "CryptoNoteBasic.h" namespace CryptoNote { class ISerializer; class PaymentIdIndex { public: PaymentIdIndex() = default; bool add(const Transaction& transaction); bool remove(const Transaction& transaction); bool find(const Crypto::Hash& paymentId, std::vector& transactionHashes); void clear(); void serialize(ISerializer& s); template void serialize(Archive& archive, unsigned int version) { archive & index; } private: std::unordered_multimap index; }; class TimestampBlocksIndex { public: TimestampBlocksIndex() = default; bool add(uint64_t timestamp, const Crypto::Hash& hash); bool remove(uint64_t timestamp, const Crypto::Hash& hash); bool find(uint64_t timestampBegin, uint64_t timestampEnd, uint32_t hashesNumberLimit, std::vector& hashes, uint32_t& hashesNumberWithinTimestamps); void clear(); void serialize(ISerializer& s); template void serialize(Archive& archive, unsigned int version) { archive & index; } private: std::multimap index; }; class TimestampTransactionsIndex { public: TimestampTransactionsIndex() = default; bool add(uint64_t timestamp, const Crypto::Hash& hash); bool remove(uint64_t timestamp, const Crypto::Hash& hash); bool find(uint64_t timestampBegin, uint64_t timestampEnd, uint64_t hashesNumberLimit, std::vector& hashes, uint64_t& hashesNumberWithinTimestamps); void clear(); void serialize(ISerializer& s); template void serialize(Archive& archive, unsigned int version) { archive & index; } private: std::multimap index; }; class GeneratedTransactionsIndex { public: GeneratedTransactionsIndex(); bool add(const Block& block); bool remove(const Block& block); bool find(uint32_t height, uint64_t& generatedTransactions); void clear(); void serialize(ISerializer& s); template void serialize(Archive& archive, unsigned int version) { archive & index; archive & lastGeneratedTxNumber; } private: std::unordered_map index; uint64_t lastGeneratedTxNumber; }; class OrphanBlocksIndex { public: OrphanBlocksIndex() = default; bool add(const Block& block); bool remove(const Block& block); bool find(uint32_t height, std::vector& blockHashes); void clear(); private: std::unordered_multimap index; }; }