aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_basic/cryptonote_format_utils.cpp
diff options
context:
space:
mode:
authortobtoht <tob@featherwallet.org>2025-03-10 16:20:00 +0000
committertobtoht <tob@featherwallet.org>2025-03-10 16:20:00 +0000
commit3da68db9789697d30dc309df2f1da5d348bc4ce2 (patch)
tree68c98fab9146797007ab778cdb4a609e1e41f43c /src/cryptonote_basic/cryptonote_format_utils.cpp
parent0232839913b13cf0ab0bb7ad25fff0c05f37d2fe (diff)
parent008ba966da88f073f226b299533faca905ceabf8 (diff)
downloadmonzero-core-3da68db9789697d30dc309df2f1da5d348bc4ce2.tar.gz
monzero-core-3da68db9789697d30dc309df2f1da5d348bc4ce2.tar.xz
monzero-core-3da68db9789697d30dc309df2f1da5d348bc4ce2.zip
Merge pull request #9740
008ba966d blockchain sync: reduce disk writes from 2 to 1 per tx (jeffro256)
Diffstat (limited to 'src/cryptonote_basic/cryptonote_format_utils.cpp')
-rw-r--r--src/cryptonote_basic/cryptonote_format_utils.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp
index e6e424c71..2bade9659 100644
--- a/src/cryptonote_basic/cryptonote_format_utils.cpp
+++ b/src/cryptonote_basic/cryptonote_format_utils.cpp
@@ -257,6 +257,7 @@ namespace cryptonote
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");
tx.invalidate_hashes();
+ tx.set_blob_size(tx_blob.size());
//TODO: validate tx
return get_transaction_hash(tx, tx_hash);
@@ -520,6 +521,19 @@ namespace cryptonote
return get_transaction_weight(tx, blob_size);
}
//---------------------------------------------------------------
+ uint64_t get_transaction_blob_size(const transaction& tx)
+ {
+ if (!tx.is_blob_size_valid())
+ {
+ const cryptonote::blobdata tx_blob = tx_to_blob(tx);
+ tx.set_blob_size(tx_blob.size());
+ }
+
+ CHECK_AND_ASSERT_THROW_MES(tx.is_blob_size_valid(), "BUG: blob size valid not set");
+
+ return tx.blob_size;
+ }
+ //---------------------------------------------------------------
bool get_tx_fee(const transaction& tx, uint64_t & fee)
{
if (tx.version > 1)