Exemple #1
0
bool bdb_common::reconstruct_block(txn_guard_ptr txn,
    const protobuf::Block& proto_block_header,
    message::block& result_block)
{
    result_block = protobuf_to_block_header(proto_block_header);
    for (const std::string& raw_tx_hash: proto_block_header.transactions())
    {
        protobuf::Transaction proto_tx;
        if (!proto_read(db_txs_, txn, raw_tx_hash, proto_tx))
            return false;
        result_block.transactions.push_back(protobuf_to_transaction(proto_tx));
    }
    return true;
}
bool reconstruct_block(leveldb_common_ptr common,
    const protobuf::Block& proto_block_header,
    block_type& result_block)
{
    result_block = protobuf_to_block_header(proto_block_header);
    for (const std::string& raw_tx_hash: proto_block_header.transactions())
    {
        // Convert protobuf hash string into internal hash format.
        hash_digest tx_hash;
        BITCOIN_ASSERT(raw_tx_hash.size() == tx_hash.max_size());
        std::copy(raw_tx_hash.begin(), raw_tx_hash.end(), tx_hash.begin());
        // Fetch the actual transaction.
        protobuf::Transaction proto_tx =
            common->fetch_proto_transaction(tx_hash);
        if (!proto_tx.IsInitialized())
            return false;
        result_block.transactions.push_back(protobuf_to_transaction(proto_tx));
    }
    return true;
}