mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-12-03 12:33:13 +00:00
cryptonote: don't serialize for blob size if already known
This commit is contained in:
parent
7e957c162a
commit
dbbb3ce9d8
1 changed files with 13 additions and 5 deletions
|
@ -379,11 +379,19 @@ namespace cryptonote
|
||||||
//---------------------------------------------------------------
|
//---------------------------------------------------------------
|
||||||
uint64_t get_transaction_weight(const transaction &tx)
|
uint64_t get_transaction_weight(const transaction &tx)
|
||||||
{
|
{
|
||||||
std::ostringstream s;
|
size_t blob_size;
|
||||||
binary_archive<true> a(s);
|
if (tx.is_blob_size_valid())
|
||||||
::serialization::serialize(a, const_cast<transaction&>(tx));
|
{
|
||||||
const cryptonote::blobdata blob = s.str();
|
blob_size = tx.blob_size;
|
||||||
return get_transaction_weight(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)
|
bool get_tx_fee(const transaction& tx, uint64_t & fee)
|
||||||
|
|
Loading…
Reference in a new issue