mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-27 13:23:29 +01:00
cryptonote: set tx hash on newly parsed txes when known
This commit is contained in:
parent
5511563e92
commit
d1efe3d91c
@ -203,6 +203,8 @@ namespace cryptonote
|
|||||||
void set_hash_valid(bool v) const { hash_valid.store(v,std::memory_order_release); }
|
void set_hash_valid(bool v) const { hash_valid.store(v,std::memory_order_release); }
|
||||||
bool is_blob_size_valid() const { return blob_size_valid.load(std::memory_order_acquire); }
|
bool is_blob_size_valid() const { return blob_size_valid.load(std::memory_order_acquire); }
|
||||||
void set_blob_size_valid(bool v) const { blob_size_valid.store(v,std::memory_order_release); }
|
void set_blob_size_valid(bool v) const { blob_size_valid.store(v,std::memory_order_release); }
|
||||||
|
void set_hash(const crypto::hash &h) { hash = h; set_hash_valid(true); }
|
||||||
|
void set_blob_size(size_t sz) { blob_size = sz; set_blob_size_valid(true); }
|
||||||
|
|
||||||
BEGIN_SERIALIZE_OBJECT()
|
BEGIN_SERIALIZE_OBJECT()
|
||||||
if (!typename Archive<W>::is_saving())
|
if (!typename Archive<W>::is_saving())
|
||||||
|
@ -184,6 +184,7 @@ namespace cryptonote
|
|||||||
CHECK_AND_ASSERT_MES(r, false, "Failed to parse transaction from blob");
|
CHECK_AND_ASSERT_MES(r, false, "Failed to parse transaction from blob");
|
||||||
CHECK_AND_ASSERT_MES(expand_transaction_1(tx, false), false, "Failed to expand transaction data");
|
CHECK_AND_ASSERT_MES(expand_transaction_1(tx, false), false, "Failed to expand transaction data");
|
||||||
tx.invalidate_hashes();
|
tx.invalidate_hashes();
|
||||||
|
tx.set_blob_size(tx_blob.size());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
|
@ -480,6 +480,10 @@ namespace cryptonote
|
|||||||
MERROR("Failed to parse tx from txpool");
|
MERROR("Failed to parse tx from txpool");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tx.set_hash(id);
|
||||||
|
}
|
||||||
tx_weight = meta.weight;
|
tx_weight = meta.weight;
|
||||||
fee = meta.fee;
|
fee = meta.fee;
|
||||||
relayed = meta.relayed;
|
relayed = meta.relayed;
|
||||||
@ -782,6 +786,7 @@ namespace cryptonote
|
|||||||
// continue
|
// continue
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
tx.set_hash(txid);
|
||||||
txi.tx_json = obj_to_json_str(tx);
|
txi.tx_json = obj_to_json_str(tx);
|
||||||
txi.blob_size = bd->size();
|
txi.blob_size = bd->size();
|
||||||
txi.weight = meta.weight;
|
txi.weight = meta.weight;
|
||||||
@ -847,14 +852,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){
|
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;
|
cryptonote::rpc::tx_in_pool txi;
|
||||||
txi.tx_hash = txid;
|
txi.tx_hash = txid;
|
||||||
transaction tx;
|
if (!parse_and_validate_tx_from_blob(*bd, txi.tx))
|
||||||
if (!parse_and_validate_tx_from_blob(*bd, tx))
|
|
||||||
{
|
{
|
||||||
MERROR("Failed to parse tx from txpool");
|
MERROR("Failed to parse tx from txpool");
|
||||||
// continue
|
// continue
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
txi.tx = tx;
|
txi.tx.set_hash(txid);
|
||||||
txi.blob_size = bd->size();
|
txi.blob_size = bd->size();
|
||||||
txi.weight = meta.weight;
|
txi.weight = meta.weight;
|
||||||
txi.fee = meta.fee;
|
txi.fee = meta.fee;
|
||||||
@ -990,21 +994,23 @@ namespace cryptonote
|
|||||||
{
|
{
|
||||||
struct transction_parser
|
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()()
|
cryptonote::transaction &operator()()
|
||||||
{
|
{
|
||||||
if (!parsed)
|
if (!parsed)
|
||||||
{
|
{
|
||||||
if (!parse_and_validate_tx_from_blob(txblob, tx))
|
if (!parse_and_validate_tx_from_blob(txblob, tx))
|
||||||
throw std::runtime_error("failed to parse transaction blob");
|
throw std::runtime_error("failed to parse transaction blob");
|
||||||
|
tx.set_hash(txid);
|
||||||
parsed = true;
|
parsed = true;
|
||||||
}
|
}
|
||||||
return tx;
|
return tx;
|
||||||
}
|
}
|
||||||
const cryptonote::blobdata &txblob;
|
const cryptonote::blobdata &txblob;
|
||||||
|
const crypto::hash &txid;
|
||||||
transaction &tx;
|
transaction &tx;
|
||||||
bool parsed;
|
bool parsed;
|
||||||
} lazy_tx(txblob, tx);
|
} lazy_tx(txblob, txid, tx);
|
||||||
|
|
||||||
//not the best implementation at this time, sorry :(
|
//not the best implementation at this time, sorry :(
|
||||||
//check is ring_signature already checked ?
|
//check is ring_signature already checked ?
|
||||||
|
Loading…
Reference in New Issue
Block a user