diff options
Diffstat (limited to 'src/cryptonote_core')
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 6 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.h | 3 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.cpp | 16 | ||||
-rw-r--r-- | src/cryptonote_core/cryptonote_core.h | 2 |
4 files changed, 22 insertions, 5 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 8f1f0b260..789687ce0 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -636,7 +636,7 @@ crypto::hash Blockchain::get_block_id_by_height(uint64_t height) const return null_hash; } //------------------------------------------------------------------ -bool Blockchain::get_block_by_hash(const crypto::hash &h, block &blk) const +bool Blockchain::get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan) const { LOG_PRINT_L3("Blockchain::" << __func__); CRITICAL_REGION_LOCAL(m_blockchain_lock); @@ -645,6 +645,8 @@ bool Blockchain::get_block_by_hash(const crypto::hash &h, block &blk) const try { blk = m_db->get_block(h); + if (orphan) + *orphan = false; return true; } // try to find block in alternative chain @@ -654,6 +656,8 @@ bool Blockchain::get_block_by_hash(const crypto::hash &h, block &blk) const if (m_alternative_chains.end() != it_alt) { blk = it_alt->second.bl; + if (orphan) + *orphan = true; return true; } } diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h index 245dc6e73..ca665e1d4 100644 --- a/src/cryptonote_core/blockchain.h +++ b/src/cryptonote_core/blockchain.h @@ -197,10 +197,11 @@ namespace cryptonote * * @param h the hash to look for * @param blk return-by-reference variable to put result block in + * @param orphan if non-NULL, will be set to true if not in the main chain, false otherwise * * @return true if the block was found, else false */ - bool get_block_by_hash(const crypto::hash &h, block &blk) const; + bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan = NULL) const; /** * @brief get all block hashes (main chain, alt chains, and invalid blocks) diff --git a/src/cryptonote_core/cryptonote_core.cpp b/src/cryptonote_core/cryptonote_core.cpp index a92cd2df3..f33a4f253 100644 --- a/src/cryptonote_core/cryptonote_core.cpp +++ b/src/cryptonote_core/cryptonote_core.cpp @@ -503,6 +503,18 @@ namespace cryptonote return false; } + if(m_mempool.have_tx(tx_hash)) + { + LOG_PRINT_L2("tx " << tx_hash << "already have transaction in tx_pool"); + return true; + } + + if(m_blockchain_storage.have_tx(tx_hash)) + { + LOG_PRINT_L2("tx " << tx_hash << " already have transaction in blockchain"); + return true; + } + if(!check_tx_syntax(tx)) { LOG_PRINT_L1("WRONG TRANSACTION BLOB, Failed to check tx " << tx_hash << " syntax, rejected"); @@ -985,9 +997,9 @@ namespace cryptonote return m_blockchain_storage.get_block_id_by_height(height); } //----------------------------------------------------------------------------------------------- - bool core::get_block_by_hash(const crypto::hash &h, block &blk) const + bool core::get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan) const { - return m_blockchain_storage.get_block_by_hash(h, blk); + return m_blockchain_storage.get_block_by_hash(h, blk, orphan); } //----------------------------------------------------------------------------------------------- std::string core::print_pool(bool short_format) const diff --git a/src/cryptonote_core/cryptonote_core.h b/src/cryptonote_core/cryptonote_core.h index 12d436e99..1b9518c96 100644 --- a/src/cryptonote_core/cryptonote_core.h +++ b/src/cryptonote_core/cryptonote_core.h @@ -330,7 +330,7 @@ namespace cryptonote * * @note see Blockchain::get_block_by_hash */ - bool get_block_by_hash(const crypto::hash &h, block &blk) const; + bool get_block_by_hash(const crypto::hash &h, block &blk, bool *orphan = NULL) const; /** * @copydoc Blockchain::get_alternative_blocks |