Exemple #1
0
void responder::send_inventory_not_found(inventory_type_id type_id,
    const hash_digest& hash, channel::ptr node, proxy::result_handler handler)
{
    const inventory_vector block_inventory
    {
        type_id,
        hash
    };

    const not_found lost{ { block_inventory } };
    node->send(lost, handler);
}
Exemple #2
0
void responder::send_tx(const transaction& tx, const hash_digest& hash,
    channel::ptr node)
{
    const auto send_handler = [hash, node](const code& ec)
    {
        if (ec)
            log::debug(LOG_RESPONDER)
                << "Failure sending tx for ["
                << node->authority() << "]";
        else
            log::debug(LOG_RESPONDER)
                << "Sent tx for [" << node->authority()
                << "] " << encode_hash(hash);
    };

    node->send(tx, send_handler);
}
Exemple #3
0
// Should we look in the orphan pool first?
void responder::send_block(const code& ec, const block& block,
    const hash_digest& block_hash, channel::ptr node)
{
    if (ec == error::service_stopped)
        return;

    if (ec == error::not_found)
    {
        log::debug(LOG_RESPONDER)
            << "Block for [" << node->authority()
            << "] not in blockchain [" << encode_hash(block_hash) << "]";

        // It wasn't in the blockchain, so send notfound.
        send_block_not_found(block_hash, node);
    }

    if (ec)
    {
        log::error(LOG_RESPONDER)
            << "Failure fetching block data for ["
            << node->authority() << "] " << ec.message();
        node->stop(ec);
        return;
    }

    const auto send_handler = [block_hash, node](const code& ec)
    {
        if (ec)
            log::debug(LOG_RESPONDER)
                << "Failure sending block for ["
                << node->authority() << "]";
        else
            log::debug(LOG_RESPONDER)
                << "Sent block for [" << node->authority()
                << "] " << encode_hash(block_hash);
    };

    node->send(block, send_handler);
}