예제 #1
0
void fullnode::new_unconfirm_valid_tx(
    const std::error_code& ec, const index_list& unconfirmed,
    const transaction_type& tx)
{
    auto handle_index = [](const std::error_code& ec)
        {
            if (ec)
                log_error() << "Index error: " << ec.message();
        };
    const hash_digest& tx_hash = hash_transaction(tx);
    if (ec)
    {
        log_warning()
            << "Error storing memory pool transaction "
            << tx_hash << ": " << ec.message();
    }
    else
    {
        auto l = log_debug();
        l << "Accepted transaction ";
        if (!unconfirmed.empty())
        {
            l << "(Unconfirmed inputs";
            for (auto idx: unconfirmed)
                l << " " << idx;
            l << ") ";
        }
        l << tx_hash;
        txidx_.index(tx, handle_index);
    }
}
void transaction_pool::validation_complete(
    const std::error_code& ec, const index_list& unconfirmed,
    const hash_digest& tx_hash, validate_handler handle_validate)
{
    if (ec == error::input_not_found || ec == error::validate_inputs_failed)
    {
        BITCOIN_ASSERT(unconfirmed.size() == 1);
        //BITCOIN_ASSERT(unconfirmed[0] < tx.inputs.size());
        handle_validate(ec, unconfirmed);
    }
    else if (ec)
    {
        BITCOIN_ASSERT(unconfirmed.empty());
        handle_validate(ec, index_list());
    }
    // Re-check as another transaction might have been added in the interim.
    else if (tx_exists(tx_hash))
        handle_validate(error::duplicate, index_list());
    else
        handle_validate(bc::error::success, unconfirmed);
}
예제 #3
0
void transaction_validated(
    const std::error_code& ec, const index_list& unconfirmed,
    const incoming_message& request, queue_send_callback queue_send)
{
    data_chunk result(4 + unconfirmed.size() * 4);
    auto serial = make_serializer(result.begin());
    write_error_code(serial, ec);
    BITCOIN_ASSERT(serial.iterator() == result.begin() + 4);
    for (uint32_t unconfirm_index: unconfirmed)
        serial.write_4_bytes(unconfirm_index);
    BITCOIN_ASSERT(serial.iterator() == result.end());
    log_debug(LOG_WORKER)
            << "transaction_pool.validate() finished. Sending response: "
            << "ec=" << ec.message();
    outgoing_message response(request, result);
    queue_send(response);
}
예제 #4
0
void handle_mempool_store(
    const std::error_code& ec, const index_list& unconfirmed,
    const transaction_type& tx, channel_ptr node)
{
    const hash_digest& tx_hash = hash_transaction(tx);
    // Decided against this. Spammers can abuse us more easily.
    /*if (ec == error::input_not_found)
    {
        BITCOIN_ASSERT(unconfirmed.size() == 1);
        BITCOIN_ASSERT(unconfirmed[0] < tx.inputs.size());
        const auto& prevout = tx.inputs[unconfirmed[0]].previous_output;
        log_info() << "Requesting dependency " << encode_hex(prevout.hash)
            << " for " << encode_hex(tx_hash);
        message::get_data getdat;
        getdat.inventories.push_back(
            {message::inventory_type::transaction, prevout.hash});
        //getdat.inventories.push_back(
        //    {message::inventory_type::transaction, tx_hash});
        node->send(getdat, depends_requested);
    }
    else if (ec)*/
    if (ec)
    {
        //BITCOIN_ASSERT(unconfirmed.size() == 0);
        log_error()
            << "Error storing memory pool transaction "
            << encode_hex(tx_hash) << ": " << ec.message();
    }
    else
    {
        auto l = log_info();
        l << "Accepted transaction ";
        if (!unconfirmed.empty())
        {
            l << "(Unconfirmed inputs";
            for (auto idx: unconfirmed)
                l << " " << idx;
            l << ") ";
        }
        l << encode_hex(tx_hash);
    }
}