Post-merge: std::variant fixes

This commit is contained in:
Jason Rhinelander 2020-06-21 22:42:32 -03:00
parent 0de3c64a77
commit 6e4a636c9a
3 changed files with 5 additions and 4 deletions

View file

@ -1344,7 +1344,7 @@ int main(int argc, char* argv[])
for (const auto &out: tx.vout)
{
++outs_total;
CHECK_AND_ASSERT_THROW_MES(out.target.type() == typeid(txout_to_key), "Out target type is not txout_to_key: height=" + std::to_string(height));
CHECK_AND_ASSERT_THROW_MES(std::holds_alternative<txout_to_key>(out.target), "Out target type is not txout_to_key: height=" + std::to_string(height));
uint64_t out_global_index = outs_per_amount[out.amount]++;
if (is_output_spent(cur, output_data(out.amount, out_global_index)))
++outs_spent;

View file

@ -32,6 +32,7 @@
#include <atomic>
#include <boost/algorithm/string.hpp>
#include <lokimq/hex.h>
#include <variant>
#include "wipeable_string.h"
#include "string_tools.h"
#include "common/i18n.h"
@ -452,7 +453,7 @@ namespace cryptonote
CHECK_AND_ASSERT_MES(tx.rct_signatures.type >= rct::RCTTypeBulletproof2,
std::numeric_limits<uint64_t>::max(), "get_pruned_transaction_weight does not support older range proof types");
CHECK_AND_ASSERT_MES(!tx.vin.empty(), std::numeric_limits<uint64_t>::max(), "empty vin");
CHECK_AND_ASSERT_MES(tx.vin[0].type() == typeid(cryptonote::txin_to_key), std::numeric_limits<uint64_t>::max(), "empty vin");
CHECK_AND_ASSERT_MES(std::holds_alternative<cryptonote::txin_to_key>(tx.vin[0]), std::numeric_limits<uint64_t>::max(), "empty vin");
// get pruned data size
uint64_t weight = serialization::dump_binary(const_cast<transaction&>(tx)).size();
@ -469,7 +470,7 @@ namespace cryptonote
weight += extra;
// calculate deterministic MLSAG data size
const size_t ring_size = boost::get<cryptonote::txin_to_key>(tx.vin[0]).key_offsets.size();
const size_t ring_size = std::get<cryptonote::txin_to_key>(tx.vin[0]).key_offsets.size();
extra = tx.vin.size() * (ring_size * (1 + 1) * 32 + 32 /* cc */);
weight += extra;

View file

@ -1857,7 +1857,7 @@ namespace cryptonote { namespace rpc {
throw rpc_error{ERROR_INTERNAL, "Internal error: can't get block by hash. Hash = " + hash + '.'};
if (blk.miner_tx.vin.size() != 1 || !std::holds_alternative<txin_gen>(blk.miner_tx.vin.front()))
throw rpc_error{ERROR_INTERNAL, "Internal error: coinbase transaction in the block has the wrong type"};
uint64_t block_height = boost::get<txin_gen>(blk.miner_tx.vin.front()).height;
uint64_t block_height = std::get<txin_gen>(blk.miner_tx.vin.front()).height;
fill_block_header_response(blk, orphan, block_height, block_hash, block_header, fill_pow_hash && admin);
};