void transaction_pool::handle_validated(const code& ec,
    const transaction& tx, const hash_digest& hash,
    const point::indexes& unconfirmed, validate_handler handler)
{
    if (stopped())
    {
        handler(error::service_stopped, tx, hash, {});
        return;
    }

    if (ec == error::input_not_found || ec == error::validate_inputs_failed)
    {
        BITCOIN_ASSERT(unconfirmed.size() == 1);
        handler(ec, tx, hash, unconfirmed);
        return;
    }

    if (ec)
    {
        BITCOIN_ASSERT(unconfirmed.empty());
        handler(ec, tx, hash, {});
        return;
    }

    // Recheck the memory pool, as a duplicate may have been added.
    if (is_in_pool(hash))
        handler(error::duplicate, tx, hash, {});
    else
        handler(error::success, tx, hash, unconfirmed);
}