Merge pull request #4946

6644b9b blockchain_db: remove a couple unused functions (moneromooo-monero)
ce594f5 blockchain_db: allocate known size vector only once (moneromooo-monero)
8332698 db_lmdb: inline check_open, it's trivial and called everywhere (moneromooo-monero)
5511563 db_lmdb: avoid pointless division (moneromooo-monero)
d1efe3d cryptonote: set tx hash on newly parsed txes when known (moneromooo-monero)
9cc68a2 tx_pool: add a few std::move where it can make a difference (moneromooo-monero)
This commit is contained in:
luigi1111 2018-12-31 16:06:50 -06:00
commit 69e8567c0e
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
8 changed files with 31 additions and 104 deletions

View file

@ -480,6 +480,10 @@ namespace cryptonote
MERROR("Failed to parse tx from txpool");
return false;
}
else
{
tx.set_hash(id);
}
tx_weight = meta.weight;
fee = meta.fee;
relayed = meta.relayed;
@ -659,7 +663,8 @@ namespace cryptonote
// continue
return true;
}
txs.push_back(tx);
tx.set_hash(txid);
txs.push_back(std::move(tx));
return true;
}, true, include_unrelayed_txes);
}
@ -782,6 +787,7 @@ namespace cryptonote
// continue
return true;
}
tx.set_hash(txid);
txi.tx_json = obj_to_json_str(tx);
txi.blob_size = bd->size();
txi.weight = meta.weight;
@ -798,7 +804,7 @@ namespace cryptonote
txi.last_relayed_time = include_sensitive_data ? meta.last_relayed_time : 0;
txi.do_not_relay = meta.do_not_relay;
txi.double_spend_seen = meta.double_spend_seen;
tx_infos.push_back(txi);
tx_infos.push_back(std::move(txi));
return true;
}, true, include_sensitive_data);
@ -847,14 +853,13 @@ namespace cryptonote
m_blockchain.for_all_txpool_txes([&tx_infos, key_image_infos](const crypto::hash &txid, const txpool_tx_meta_t &meta, const cryptonote::blobdata *bd){
cryptonote::rpc::tx_in_pool txi;
txi.tx_hash = txid;
transaction tx;
if (!parse_and_validate_tx_from_blob(*bd, tx))
if (!parse_and_validate_tx_from_blob(*bd, txi.tx))
{
MERROR("Failed to parse tx from txpool");
// continue
return true;
}
txi.tx = tx;
txi.tx.set_hash(txid);
txi.blob_size = bd->size();
txi.weight = meta.weight;
txi.fee = meta.fee;
@ -881,7 +886,7 @@ namespace cryptonote
}
const crypto::key_image& k_image = kee.first;
key_image_infos[k_image] = tx_hashes;
key_image_infos[k_image] = std::move(tx_hashes);
}
return true;
}
@ -990,21 +995,23 @@ namespace cryptonote
{
struct transction_parser
{
transction_parser(const cryptonote::blobdata &txblob, transaction &tx): txblob(txblob), tx(tx), parsed(false) {}
transction_parser(const cryptonote::blobdata &txblob, const crypto::hash &txid, transaction &tx): txblob(txblob), txid(txid), tx(tx), parsed(false) {}
cryptonote::transaction &operator()()
{
if (!parsed)
{
if (!parse_and_validate_tx_from_blob(txblob, tx))
throw std::runtime_error("failed to parse transaction blob");
tx.set_hash(txid);
parsed = true;
}
return tx;
}
const cryptonote::blobdata &txblob;
const crypto::hash &txid;
transaction &tx;
bool parsed;
} lazy_tx(txblob, tx);
} lazy_tx(txblob, txid, tx);
//not the best implementation at this time, sorry :(
//check is ring_signature already checked ?