Bitcoin full node and query server

Mar 7, 2025

View in context in the libbitcoin Slack #general mirror.

evoskuil08:28
// Expand synchronizes keys with ins_fk, entries dropped into same offset.
// Allocate contiguous points (at sequential keys matching ins_fk).
if (!store_.point.expand(ins_fk + inputs))
    return error::tx_point_allocate;

const auto ptr = store_.point.get_memory();

if (tx.is_coinbase())
{
    for (const auto& in: *ins)
        if (!store_.point.put(ptr, ins_fk++,
            table::point::compose(in->point()), table::point::record{}))
            return error::tx_point_put;
}
else
{
    // Write all table elements (row not linked).
    auto fk = ins_fk;
    for (const auto& in: *ins)
        if (!store_.point.set(ptr, fk++,
            table::point::compose(in->point()), table::point::record{}))
            return error::tx_point_set;

    // Exclusive search and index commit.
    std::unique_lock lock{ mutex_ };

    // TODO: write a record for every match found.
    fk = ins_fk;
    for (const auto& in: *ins)
        if (store_.point.exists(ptr,
            table::point::compose(in->point())))
            return error::confirmed_double_spend;

    // Link all table elements (row linked).
    fk = ins_fk;
    for (const auto& in: *ins)
        if (!store_.point.commit(ptr, fk++,
            table::point::compose(in->point())))
            return error::tx_point_commit;
}