aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db/blockchain_db.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/blockchain_db/blockchain_db.h')
-rw-r--r--src/blockchain_db/blockchain_db.h82
1 files changed, 66 insertions, 16 deletions
diff --git a/src/blockchain_db/blockchain_db.h b/src/blockchain_db/blockchain_db.h
index 5b6a793d8..f5710550b 100644
--- a/src/blockchain_db/blockchain_db.h
+++ b/src/blockchain_db/blockchain_db.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2014-2016, The Monero Project
+// Copyright (c) 2014-2017, The Monero Project
//
// All rights reserved.
//
@@ -34,9 +34,10 @@
#include <string>
#include <exception>
#include "crypto/hash.h"
-#include "cryptonote_core/cryptonote_basic.h"
-#include "cryptonote_core/difficulty.h"
-#include "cryptonote_core/hardfork.h"
+#include "cryptonote_protocol/blobdatatype.h"
+#include "cryptonote_basic/cryptonote_basic.h"
+#include "cryptonote_basic/difficulty.h"
+#include "cryptonote_basic/hardfork.h"
/** \file
* Cryptonote Blockchain Database Interface
@@ -655,16 +656,17 @@ public:
* been called. In either case, it should end the batch and write to its
* backing store.
*
- * If a batch is already in-progress, this function should throw a DB_ERROR.
- * This exception may change in the future if it is deemed necessary to
- * have a more granular exception type for this scenario.
+ * If a batch is already in-progress, this function must return false.
+ * If a batch was started by this call, it must return true.
*
* If any of this cannot be done, the subclass should throw the corresponding
* subclass of DB_EXCEPTION
*
* @param batch_num_blocks number of blocks to batch together
+ *
+ * @return true if we started the batch, false if already started
*/
- virtual void batch_start(uint64_t batch_num_blocks=0) = 0;
+ virtual bool batch_start(uint64_t batch_num_blocks=0) = 0;
/**
* @brief ends a batch transaction
@@ -753,7 +755,20 @@ public:
*
* @return the block requested
*/
- virtual block get_block(const crypto::hash& h) const = 0;
+ virtual cryptonote::blobdata get_block_blob(const crypto::hash& h) const = 0;
+
+ /**
+ * @brief fetches the block with the given hash
+ *
+ * Returns the requested block.
+ *
+ * If the block does not exist, the subclass should throw BLOCK_DNE
+ *
+ * @param h the hash to look for
+ *
+ * @return the block requested
+ */
+ virtual block get_block(const crypto::hash& h) const;
/**
* @brief gets the height of the block with a given hash
@@ -783,7 +798,7 @@ public:
virtual block_header get_block_header(const crypto::hash& h) const = 0;
/**
- * @brief fetch a block by height
+ * @brief fetch a block blob by height
*
* The subclass should return the block at the given height.
*
@@ -792,9 +807,21 @@ public:
*
* @param height the height to look for
*
+ * @return the block blob
+ */
+ virtual cryptonote::blobdata get_block_blob_from_height(const uint64_t& height) const = 0;
+
+ /**
+ * @brief fetch a block by height
+ *
+ * If the block does not exist, that is to say if the blockchain is not
+ * that high, then the subclass should throw BLOCK_DNE
+ *
+ * @param height the height to look for
+ *
* @return the block
*/
- virtual block get_block_from_height(const uint64_t& height) const = 0;
+ virtual block get_block_from_height(const uint64_t& height) const;
/**
* @brief fetch a block's timestamp
@@ -1008,16 +1035,38 @@ public:
/**
* @brief fetches the transaction with the given hash
*
+ * If the transaction does not exist, the subclass should throw TX_DNE.
+ *
+ * @param h the hash to look for
+ *
+ * @return the transaction with the given hash
+ */
+ virtual transaction get_tx(const crypto::hash& h) const;
+
+ /**
+ * @brief fetches the transaction with the given hash
+ *
+ * If the transaction does not exist, the subclass should return false.
+ *
+ * @param h the hash to look for
+ *
+ * @return true iff the transaction was found
+ */
+ virtual bool get_tx(const crypto::hash& h, transaction &tx) const;
+
+ /**
+ * @brief fetches the transaction blob with the given hash
+ *
* The subclass should return the transaction stored which has the given
* hash.
*
- * If the transaction does not exist, the subclass should throw TX_DNE.
+ * If the transaction does not exist, the subclass should return false.
*
* @param h the hash to look for
*
- * @return the transaction with the given hash
+ * @return true iff the transaction was found
*/
- virtual transaction get_tx(const crypto::hash& h) const = 0;
+ virtual bool get_tx_blob(const crypto::hash& h, cryptonote::blobdata &tx) const = 0;
/**
* @brief fetches the total number of transactions ever
@@ -1169,7 +1218,7 @@ public:
* @param offsets a list of amount-specific output indices
* @param outputs return-by-reference a list of outputs' metadata
*/
- virtual void get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs) = 0;
+ virtual void get_output_key(const uint64_t &amount, const std::vector<uint64_t> &offsets, std::vector<output_data_t> &outputs, bool allow_partial = false) = 0;
/*
* FIXME: Need to check with git blame and ask what this does to
@@ -1309,10 +1358,11 @@ public:
*
* @param amounts optional set of amounts to lookup
* @param unlocked whether to restrict count to unlocked outputs
+ * @param recent_cutoff timestamp to determine whether an output is recent
*
* @return a set of amount/instances
*/
- virtual std::map<uint64_t, uint64_t> get_output_histogram(const std::vector<uint64_t> &amounts, bool unlocked) const = 0;
+ virtual std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t>> get_output_histogram(const std::vector<uint64_t> &amounts, bool unlocked, uint64_t recent_cutoff) const = 0;
/**
* @brief is BlockchainDB in read-only mode?