diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-11-29 22:01:48 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-12-07 14:07:26 +0000 |
commit | dbbb3ce9d8075eae564b6c62db81e063958ea065 (patch) | |
tree | 620474a0c1111c5666a87151abfc46d02c36501b /src/cryptonote_basic | |
parent | Merge pull request #4879 (diff) | |
download | monero-dbbb3ce9d8075eae564b6c62db81e063958ea065.tar.xz |
cryptonote: don't serialize for blob size if already known
Diffstat (limited to 'src/cryptonote_basic')
-rw-r--r-- | src/cryptonote_basic/cryptonote_format_utils.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/cryptonote_basic/cryptonote_format_utils.cpp b/src/cryptonote_basic/cryptonote_format_utils.cpp index 55d7d23f8..f11031ed3 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -379,11 +379,19 @@ namespace cryptonote //--------------------------------------------------------------- uint64_t get_transaction_weight(const transaction &tx) { - std::ostringstream s; - binary_archive<true> a(s); - ::serialization::serialize(a, const_cast<transaction&>(tx)); - const cryptonote::blobdata blob = s.str(); - return get_transaction_weight(tx, blob.size()); + size_t blob_size; + if (tx.is_blob_size_valid()) + { + blob_size = tx.blob_size; + } + else + { + std::ostringstream s; + binary_archive<true> a(s); + ::serialization::serialize(a, const_cast<transaction&>(tx)); + blob_size = s.str().size(); + } + return get_transaction_weight(tx, blob_size); } //--------------------------------------------------------------- bool get_tx_fee(const transaction& tx, uint64_t & fee) |