Exemplo n.º 1
0
// To push in order call with bucket = 0 and buckets = 1 (defaults).
bool data_base::push_transactions(const chain::block& block, size_t height,
    size_t bucket, size_t buckets)
{
    BITCOIN_ASSERT(bucket < buckets);
    const auto& txs = block.transactions();
    const auto count = txs.size();

    for (auto position = bucket; position < count; position += buckets)
    {
        const auto& tx = txs[position];

        transactions_->store(height, position, tx);

        if (height < settings_.index_start_height)
            continue;

        const auto tx_hash = tx.hash();

        if (position != 0)
            push_inputs(tx_hash, height, tx.inputs());

        push_outputs(tx_hash, height, tx.outputs());
        push_stealth(tx_hash, height, tx.outputs());
    }

    return true;
}
transaction random_tx(size_t fudge)
{
    static const auto settings = bc::settings(bc::config::settings::mainnet);
    static const chain::block genesis = settings.genesis_block;
    auto tx = genesis.transactions()[0];
    tx.inputs()[0].previous_output().set_index(fudge);
    tx.metadata.link = fudge;
    return tx;
}
Exemplo n.º 3
0
bool data_base::push_heights(const chain::block& block, size_t height)
{
    transactions_->synchronize();
    const auto& txs = block.transactions();

    // Skip coinbase as it has no previous output.
    for (auto tx = txs.begin() + 1; tx != txs.end(); ++tx)
        for (const auto& input: tx->inputs())
            if (!transactions_->update(input.previous_output(), height))
                return false;

    return true;
}