diff options
| author | jeffro256 <jeffro256@tutanota.com> | 2024-01-17 17:17:16 -0600 |
|---|---|---|
| committer | jeffro256 <jeffro256@tutanota.com> | 2025-03-10 01:32:08 -0500 |
| commit | 008ba966da88f073f226b299533faca905ceabf8 (patch) | |
| tree | 1be6c2f8d45b74ad0427e0117c67371c93974f7e /src/cryptonote_basic | |
| parent | d0118f4778db7e75d7ad2036076e5688cd6f3810 (diff) | |
| download | monzero-core-008ba966da88f073f226b299533faca905ceabf8.tar.gz monzero-core-008ba966da88f073f226b299533faca905ceabf8.tar.xz monzero-core-008ba966da88f073f226b299533faca905ceabf8.zip | |
blockchain sync: reduce disk writes from 2 to 1 per tx
Diffstat (limited to 'src/cryptonote_basic')
| -rw-r--r-- | src/cryptonote_basic/cryptonote_format_utils.cpp | 14 | ||||
| -rw-r--r-- | src/cryptonote_basic/cryptonote_format_utils.h | 1 | ||||
| -rw-r--r-- | src/cryptonote_basic/verification_context.h | 3 |
3 files changed, 17 insertions, 1 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) diff --git a/src/cryptonote_basic/cryptonote_format_utils.h b/src/cryptonote_basic/cryptonote_format_utils.h index b97c9d499..c242823c5 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.h +++ b/src/cryptonote_basic/cryptonote_format_utils.h @@ -137,6 +137,7 @@ namespace cryptonote uint64_t get_transaction_weight(const transaction &tx); uint64_t get_transaction_weight(const transaction &tx, size_t blob_size); uint64_t get_pruned_transaction_weight(const transaction &tx); + uint64_t get_transaction_blob_size(const transaction& tx); bool check_money_overflow(const transaction& tx); bool check_outs_overflow(const transaction& tx); diff --git a/src/cryptonote_basic/verification_context.h b/src/cryptonote_basic/verification_context.h index 9b496f0d8..822b9f622 100644 --- a/src/cryptonote_basic/verification_context.h +++ b/src/cryptonote_basic/verification_context.h @@ -69,6 +69,7 @@ namespace cryptonote bool m_marked_as_orphaned; bool m_already_exists; bool m_partial_block_reward; - bool m_bad_pow; // if bad pow, bad peer outright for DoS protection + bool m_bad_pow; // if bad pow, ban peer outright for DoS protection + bool m_missing_txs; // set if, during verif, we don't have all the necessary txs available }; } |
