aboutsummaryrefslogtreecommitdiff
path: root/src/blockchain_db
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2015-08-11 14:19:41 +0200
committerRiccardo Spagni <ric@spagni.net>2015-08-11 14:19:55 +0200
commit01e81205e07408da03340de9f2bd113e9801ca77 (patch)
tree1f636f1a59c16163b591a7555c988e10dabd31a7 /src/blockchain_db
parentMerge pull request #364 (diff)
parentblockchain_db: match tx addition semantics to original code (diff)
downloadmonero-01e81205e07408da03340de9f2bd113e9801ca77.tar.xz
Merge pull request #365
e63b854 blockchain_db: match tx addition semantics to original code (moneromooo-monero) 83bbea4 Add a is_key_image_spent daemon command and RPC call (moneromooo-monero) 35abef1 blockchain: remove dead code (moneromooo-monero)
Diffstat (limited to 'src/blockchain_db')
-rw-r--r--src/blockchain_db/blockchain_db.cpp32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/blockchain_db/blockchain_db.cpp b/src/blockchain_db/blockchain_db.cpp
index 41fee5dc7..9d865d4de 100644
--- a/src/blockchain_db/blockchain_db.cpp
+++ b/src/blockchain_db/blockchain_db.cpp
@@ -56,6 +56,30 @@ void BlockchainDB::add_transaction(const crypto::hash& blk_hash, const transacti
tx_hash = *tx_hash_ptr;
}
+ for (const txin_v& tx_input : tx.vin)
+ {
+ if (tx_input.type() == typeid(txin_to_key))
+ {
+ add_spent_key(boost::get<txin_to_key>(tx_input).k_image);
+ }
+ else if (tx_input.type() == typeid(txin_gen))
+ {
+ /* nothing to do here */
+ }
+ else
+ {
+ LOG_PRINT_L1("Unsupported input type, removing key images and aborting transaction addition");
+ for (const txin_v& tx_input : tx.vin)
+ {
+ if (tx_input.type() == typeid(txin_to_key))
+ {
+ remove_spent_key(boost::get<txin_to_key>(tx_input).k_image);
+ }
+ }
+ return;
+ }
+ }
+
add_transaction_data(blk_hash, tx, tx_hash);
// iterate tx.vout using indices instead of C++11 foreach syntax because
@@ -64,14 +88,6 @@ void BlockchainDB::add_transaction(const crypto::hash& blk_hash, const transacti
{
add_output(tx_hash, tx.vout[i], i, tx.unlock_time);
}
-
- for (const txin_v& tx_input : tx.vin)
- {
- if (tx_input.type() == typeid(txin_to_key))
- {
- add_spent_key(boost::get<txin_to_key>(tx_input).k_image);
- }
- }
}
uint64_t BlockchainDB::add_block( const block& blk