cryptonote: don't serialize for blob size if already known

This commit is contained in:
moneromooo-monero 2018-11-29 22:01:48 +00:00
parent 7e957c162a
commit dbbb3ce9d8
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

View File

@ -378,12 +378,20 @@ namespace cryptonote
}
//---------------------------------------------------------------
uint64_t get_transaction_weight(const transaction &tx)
{
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));
const cryptonote::blobdata blob = s.str();
return get_transaction_weight(tx, blob.size());
blob_size = s.str().size();
}
return get_transaction_weight(tx, blob_size);
}
//---------------------------------------------------------------
bool get_tx_fee(const transaction& tx, uint64_t & fee)