refactor mixin condition

pull/88/head
wowario 6 years ago
parent 4a55d6eaea
commit f58de1e817
No known key found for this signature in database
GPG Key ID: 24DCBE762DE9C111

@ -2613,7 +2613,7 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
{
size_t n_unmixable = 0, n_mixable = 0;
size_t mixin = std::numeric_limits<size_t>::max();
const size_t min_mixin = hf_version >= HF_VERSION_MIN_MIXIN_7 ? 7 : hf_version >= HF_VERSION_MIN_MIXIN_4 ? 4 : 2;
const size_t min_mixin = hf_version >= HF_VERSION_MIN_MIXIN_9 ? 9 : hf_version >= HF_VERSION_MIN_MIXIN_7 ? 7 : hf_version >= HF_VERSION_MIN_MIXIN_4 ? 4 : 2;
for (const auto& txin : tx.vin)
{
// non txin_to_key inputs will be rejected below
@ -2642,9 +2642,6 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
}
}
// from v9, mixin is static
if (hf_version < HF_VERSION_MIN_MIXIN_9)
{
if (mixin < min_mixin)
{
if (n_unmixable == 0)
@ -2660,18 +2657,18 @@ bool Blockchain::check_tx_inputs(transaction& tx, tx_verification_context &tvc,
return false;
}
}
else
// from v9, all transactions must have the same ring size
if (hf_version >= HF_VERSION_MIN_MIXIN_9)
{
const size_t mixin = DEFAULT_MIXIN;
const size_t min_mixin = DEFAULT_MIXIN;
if (mixin != min_mixin)
{
MERROR_VER("Tx " << get_transaction_hash(tx) << " has invalid ring size");
tvc.m_low_mixin = true;
return false;
}
}
}
// min/max tx version based on HF, and we accept v1 txes if having a non mixable
const size_t max_tx_version = (hf_version <= 3) ? 1 : 2;
if (tx.version > max_tx_version)

Loading…
Cancel
Save