Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 51 additions & 40 deletions include/bitcoin/database/impl/store.ipp

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions include/bitcoin/database/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ struct BCD_API settings
/// Caches.
/// -----------------------------------------------------------------------

uint32_t prevout_buckets;
uint64_t prevout_size;
uint16_t prevout_rate;

uint32_t validated_bk_buckets;
uint64_t validated_bk_size;
uint16_t validated_bk_rate;
Expand All @@ -109,10 +113,6 @@ struct BCD_API settings

////uint32_t bootstrap_size;
////uint16_t bootstrap_rate;

////uint32_t buffer_buckets;
////uint64_t buffer_size;
////uint16_t buffer_rate;
};

} // namespace database
Expand Down
10 changes: 5 additions & 5 deletions include/bitcoin/database/store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ class store
table::strong_tx strong_tx;

/// Caches.
table::prevout prevout;
table::validated_bk validated_bk;
table::validated_tx validated_tx;

/// Optionals.
table::address address;
table::neutrino neutrino;
////table::bootstrap bootstrap;
////table::buffer buffer;

protected:
code open_load(const event_handler& handler) NOEXCEPT;
Expand Down Expand Up @@ -185,6 +185,10 @@ class store
/// Caches.
/// -----------------------------------------------------------------------

// record arraymap
Storage prevout_head_;
Storage prevout_body_;

// record hashmap
Storage validated_bk_head_;
Storage validated_bk_body_;
Expand All @@ -208,10 +212,6 @@ class store
////Storage bootstrap_head_;
////Storage bootstrap_body_;

////// slab hashmap
////Storage buffer_head_;
////Storage buffer_body_;

/// Locks.
/// -----------------------------------------------------------------------

Expand Down
8 changes: 4 additions & 4 deletions include/bitcoin/database/tables/archives/header.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct header
bits = source.read_little_endian<uint32_t>();
nonce = source.read_little_endian<uint32_t>();
merkle_root = source.read_hash();
BC_ASSERT(source.get_read_position() == minrow);
BC_ASSERT(!source || source.get_read_position() == minrow);
return source;
}

Expand All @@ -64,7 +64,7 @@ struct header
sink.write_little_endian<uint32_t>(bits);
sink.write_little_endian<uint32_t>(nonce);
sink.write_bytes(merkle_root);
BC_ASSERT(sink.get_write_position() == minrow);
BC_ASSERT(!sink || sink.get_write_position() == minrow);
return sink;
}

Expand Down Expand Up @@ -105,7 +105,7 @@ struct header
sink.write_little_endian<uint32_t>(header->bits());
sink.write_little_endian<uint32_t>(header->nonce());
sink.write_bytes(header->merkle_root());
BC_ASSERT(sink.get_write_position() == minrow);
BC_ASSERT(!sink || sink.get_write_position() == minrow);
return sink;
}

Expand All @@ -130,7 +130,7 @@ struct header
sink.write_little_endian<uint32_t>(header.bits());
sink.write_little_endian<uint32_t>(header.nonce());
sink.write_bytes(header.merkle_root());
BC_ASSERT(sink.get_write_position() == minrow);
BC_ASSERT(!sink || sink.get_write_position() == minrow);
return sink;
}

Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/database/tables/archives/input.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ struct input
{
script = system::chain::script{ source, true };
witness = system::chain::witness{ source, true };
BC_ASSERT(source.get_read_position() == count());
BC_ASSERT(!source || source.get_read_position() == count());
return source;
}

inline bool to_data(flipper& sink) const NOEXCEPT
{
script.to_data(sink, true);
witness.to_data(sink, true);
BC_ASSERT(sink.get_write_position() == count());
BC_ASSERT(!sink || sink.get_write_position() == count());
return sink;
}

Expand Down Expand Up @@ -105,7 +105,7 @@ struct input
{
input.script().to_data(sink, true);
input.witness().to_data(sink, true);
BC_ASSERT(sink.get_write_position() == count());
BC_ASSERT(!sink || sink.get_write_position() == count());
return sink;
}

Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/database/tables/archives/output.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct output
parent_fk = source.read_little_endian<tx::integer, tx::size>();
value = source.read_variable();
script = chain::script{ source, true };
BC_ASSERT(source.get_read_position() == count());
BC_ASSERT(!source || source.get_read_position() == count());
return source;
}

Expand All @@ -66,7 +66,7 @@ struct output
sink.write_little_endian<tx::integer, tx::size>(parent_fk);
sink.write_variable(value);
script.to_data(sink, true);
BC_ASSERT(sink.get_write_position() == count());
BC_ASSERT(!sink || sink.get_write_position() == count());
return sink;
}

Expand Down Expand Up @@ -143,7 +143,7 @@ struct output
sink.write_little_endian<tx::integer, tx::size>(parent_fk);
sink.write_variable(output.value());
output.script().to_data(sink, true);
BC_ASSERT(sink.get_write_position() == count());
BC_ASSERT(!sink || sink.get_write_position() == count());
return sink;
}

Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/tables/archives/puts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct puts
fk = source.read_little_endian<out::integer, out::size>();
});

BC_ASSERT(source.get_read_position() == count());
BC_ASSERT(!source || source.get_read_position() == count());
return source;
}

Expand All @@ -83,7 +83,7 @@ struct puts
sink.write_little_endian<out::integer, out::size>(fk);
});

BC_ASSERT(sink.get_write_position() == count());
BC_ASSERT(!sink || sink.get_write_position() == count());
return sink;
}

Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/database/tables/archives/spend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct spend
parent_fk = source.read_little_endian<tx::integer, tx::size>();
sequence = source.read_little_endian<uint32_t>();
input_fk = source.read_little_endian<in::integer, in::size>();
BC_ASSERT(source.get_read_position() == minrow);
BC_ASSERT(!source || source.get_read_position() == minrow);
return source;
}

Expand All @@ -75,7 +75,7 @@ struct spend
sink.write_little_endian<tx::integer, tx::size>(parent_fk);
sink.write_little_endian<uint32_t>(sequence);
sink.write_little_endian<in::integer, in::size>(input_fk);
BC_ASSERT(sink.get_write_position() == minrow);
BC_ASSERT(!sink || sink.get_write_position() == minrow);
return sink;
}

Expand Down Expand Up @@ -106,7 +106,7 @@ struct spend
source.skip_bytes(tx::size);
sequence = source.read_little_endian<uint32_t>();
input_fk = source.read_little_endian<in::integer, in::size>();
BC_ASSERT(source.get_read_position() == minrow);
BC_ASSERT(!source || source.get_read_position() == minrow);
return source;
}

Expand Down
8 changes: 4 additions & 4 deletions include/bitcoin/database/tables/archives/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct transaction
ins_count = source.read_little_endian<ix::integer, ix::size>();
outs_count = source.read_little_endian<ix::integer, ix::size>();
puts_fk = source.read_little_endian<puts::integer, puts::size>();
BC_ASSERT(source.get_read_position() == minrow);
BC_ASSERT(!source || source.get_read_position() == minrow);
return source;
}

Expand All @@ -83,7 +83,7 @@ struct transaction
sink.write_little_endian<ix::integer, ix::size>(ins_count);
sink.write_little_endian<ix::integer, ix::size>(outs_count);
sink.write_little_endian<puts::integer, puts::size>(puts_fk);
BC_ASSERT(sink.get_write_position() == minrow);
BC_ASSERT(!sink || sink.get_write_position() == minrow);
return sink;
}

Expand Down Expand Up @@ -125,7 +125,7 @@ struct transaction
ins_count = source.read_little_endian<ix::integer, ix::size>();
outs_count = source.read_little_endian<ix::integer, ix::size>();
puts_fk = source.read_little_endian<puts::integer, puts::size>();
BC_ASSERT(source.get_read_position() == minrow);
BC_ASSERT(!source || source.get_read_position() == minrow);
return source;
}

Expand All @@ -152,7 +152,7 @@ struct transaction
sink.write_little_endian<ix::integer, ix::size>(ins_count);
sink.write_little_endian<ix::integer, ix::size>(outs_count);
sink.write_little_endian<puts::integer, puts::size>(puts_fk);
BC_ASSERT(sink.get_write_position() == minrow);
BC_ASSERT(!sink || sink.get_write_position() == minrow);
return sink;
}

Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/tables/archives/txs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct txs
fk = source.read_little_endian<tx::integer, tx::size>();
});

BC_ASSERT(source.get_read_position() == count());
BC_ASSERT(!source || source.get_read_position() == count());
return source;
}

Expand All @@ -74,7 +74,7 @@ struct txs
sink.write_little_endian<tx::integer, tx::size>(fk);
});

BC_ASSERT(sink.get_write_position() == count());
BC_ASSERT(!sink || sink.get_write_position() == count());
return sink;
}

Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/tables/caches/prevout.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct prevout
coinbase = source.read_byte();
spend_fk = source.read_little_endian<spend::integer, spend::size>();
output_tx_fk = source.read_little_endian<tx::integer, tx::size>();
BC_ASSERT(source.get_read_position() == count());
BC_ASSERT(!source || source.get_read_position() == minrow);
return source;
}

Expand All @@ -53,7 +53,7 @@ struct prevout
sink.write_byte(coinbase);
sink.write_little_endian<spend::integer, spend::size>(spend_fk);
sink.write_little_endian<tx::integer, tx::size>(output_tx_fk);
BC_ASSERT(sink.get_write_position() == count());
BC_ASSERT(!sink || sink.get_write_position() == minrow);
return sink;
}

Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/tables/caches/validated_bk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ struct validated_bk
{
code = source.read_little_endian<coding::integer, coding::size>();
fees = source.read_variable();
BC_ASSERT(source.get_read_position() == count());
BC_ASSERT(!source || source.get_read_position() == count());
return source;
}

inline bool to_data(finalizer& sink) const NOEXCEPT
{
sink.write_little_endian<coding::integer, coding::size>(code);
sink.write_variable(fees);
BC_ASSERT(sink.get_write_position() == count());
BC_ASSERT(!sink || sink.get_write_position() == count());
return sink;
}

Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/tables/caches/validated_tx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct validated_tx
code = source.read_little_endian<coding::integer, coding::size>();
fee = source.read_variable();
sigops = possible_narrow_cast<sigop::integer>(source.read_variable());
BC_ASSERT(source.get_read_position() == count());
BC_ASSERT(!source || source.get_read_position() == count());
return source;
}

Expand All @@ -68,7 +68,7 @@ struct validated_tx
sink.write_little_endian<coding::integer, coding::size>(code);
sink.write_variable(fee);
sink.write_variable(sigops);
BC_ASSERT(sink.get_write_position() == count());
BC_ASSERT(!sink || sink.get_write_position() == count());
return sink;
}

Expand Down
2 changes: 2 additions & 0 deletions include/bitcoin/database/tables/indexes/height.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ struct height
inline bool from_data(reader& source) NOEXCEPT
{
header_fk = source.read_little_endian<block::integer, block::size>();
BC_ASSERT(!source || source.get_read_position() == minrow);
return source;
}

inline bool to_data(flipper& sink) const NOEXCEPT
{
sink.write_little_endian<block::integer, block::size>(header_fk);
BC_ASSERT(!sink || sink.get_write_position() == minrow);
return sink;
}

Expand Down
2 changes: 2 additions & 0 deletions include/bitcoin/database/tables/indexes/strong_tx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ struct strong_tx
{
header_fk = source.read_little_endian<block::integer, block::size>();
positive = to_bool(source.read_byte());
BC_ASSERT(!source || source.get_read_position() == minrow);
return source;
}

inline bool to_data(finalizer& sink) const NOEXCEPT
{
sink.write_little_endian<block::integer, block::size>(header_fk);
sink.write_byte(to_int<uint8_t>(positive));
BC_ASSERT(!sink || sink.get_write_position() == minrow);
return sink;
}

Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/database/tables/optionals/bootstrap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
//// hash = source.read_hash();
//// });
////
//// BC_ASSERT(source.get_read_position() == count() * schema::hash);
//// BC_ASSERT(!source || source.get_read_position() == count() * schema::hash);
//// return source;
//// }
////
Expand All @@ -71,7 +71,7 @@
//// sink.write_bytes(hash);
//// });
////
//// BC_ASSERT(sink.get_write_position() == count() * schema::hash);
//// BC_ASSERT(!sink || sink.get_write_position() == count() * schema::hash);
//// return sink;
//// }
////
Expand Down
8 changes: 4 additions & 4 deletions include/bitcoin/database/tables/optionals/neutrino.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct neutrino
{
filter_head = source.read_hash();
filter = source.read_bytes(source.read_size());
BC_ASSERT(source.get_read_position() == count());
BC_ASSERT(!source || source.get_read_position() == count());
return source;
}

Expand All @@ -58,7 +58,7 @@ struct neutrino
sink.write_bytes(filter_head);
sink.write_variable(filter.size());
sink.write_bytes(filter);
BC_ASSERT(sink.get_write_position() == count());
BC_ASSERT(!sink || sink.get_write_position() == count());
return sink;
}

Expand Down Expand Up @@ -87,7 +87,7 @@ struct neutrino
{
source.skip_bytes(schema::hash);
filter = source.read_bytes(source.read_size());
BC_ASSERT(source.get_read_position() == count());
BC_ASSERT(!source || source.get_read_position() == count());
return source;
}

Expand Down Expand Up @@ -122,7 +122,7 @@ struct neutrino
sink.write_bytes(filter_head);
sink.write_variable(filter.size());
sink.write_bytes(filter);
BC_ASSERT(sink.get_write_position() == count());
BC_ASSERT(!sink || sink.get_write_position() == count());
return sink;
}

Expand Down
Loading
Loading