diff options
author | luigi1111 <luigi1111w@gmail.com> | 2018-12-31 16:26:22 -0600 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2018-12-31 16:26:22 -0600 |
commit | 61c0083105eec483553ebaac269187cb07b02a98 (patch) | |
tree | a99dc69a5d0217d58ee517c5e5257aae4b4316c9 /src | |
parent | Merge pull request #4948 (diff) | |
parent | cryptonote: don't serialize for blob size if already known (diff) | |
download | monero-61c0083105eec483553ebaac269187cb07b02a98.tar.xz |
Merge pull request #4953
dbbb3ce cryptonote: don't serialize for blob size if already known (moneromooo-monero)
Diffstat (limited to 'src')
-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 3a328407d..82428f196 100644 --- a/src/cryptonote_basic/cryptonote_format_utils.cpp +++ b/src/cryptonote_basic/cryptonote_format_utils.cpp @@ -380,11 +380,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) |