コード例 #1
0
void transaction_fetched(const code& ec, const chain::transaction& tx,
    const message& request, send_handler handler)
{
    const auto result = build_chunk(
    {
        message::to_bytes(ec),
        tx.to_data()
    });

    handler(message(request, result));
}
コード例 #2
0
void transaction_database::store(size_t height, size_t index,
    const chain::transaction& tx)
{
    // Write block data.
    const hash_digest key = tx.hash();
    const size_t value_size = 4 + 4 + tx.serialized_size();
    auto write = [&height, &index, &tx](uint8_t* data)
    {
        auto serial = make_serializer(data);
        serial.write_4_bytes_little_endian(height);
        serial.write_4_bytes_little_endian(index);
        data_chunk tx_data = tx.to_data();
        serial.write_data(tx_data);
    };
    map_.store(key, write, value_size);
}