Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #9635 from EOSIO/rocksdb_ship
Browse files Browse the repository at this point in the history
Update SHiP to work with RocksDB
  • Loading branch information
brianjohnson5972 authored Nov 11, 2020
2 parents 94c98f1 + c8cf8d8 commit 2077111
Show file tree
Hide file tree
Showing 23 changed files with 1,609 additions and 580 deletions.
2 changes: 1 addition & 1 deletion libraries/abieos
14 changes: 2 additions & 12 deletions libraries/chain/backing_store/db_key_value_format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,6 @@ namespace eosio { namespace chain { namespace backing_store { namespace db_key_v
return { std::get<0>(intermittent), std::get<1>(intermittent), key_loc, kt };
}

char get_rocksdb_contract_db_prefix_as_char() {
const auto prefix = make_rocksdb_contract_db_prefix();
// current design for rocksdb key format doesn't account for writing a variable width db prefix, so no
// point in designing code to write out a 1 char field as a varied length field.
EOS_ASSERT(prefix.size() == 1, bad_composite_key_exception,
"DB intrinsic key-value has been writing out the db_prefix as a defined 1 byte wide, it cannot be "
"changed to a new size without design changes");
return prefix[0];
}

// NOTE: very limited use till redesign
constexpr uint64_t db_type_and_code_size = detail::prefix_size<eosio::session::shared_bytes>() - detail::prefix_size<b1::chain_kv::bytes>(); // 1 (db type) + 8 (contract)
static_assert(db_type_and_code_size == sizeof(char) + sizeof(name), "Some assumptions on formatting have been broken");
Expand Down Expand Up @@ -215,7 +205,7 @@ namespace eosio { namespace chain { namespace backing_store { namespace db_key_v
}

eosio::session::shared_bytes create_full_key(const b1::chain_kv::bytes& composite_key, name code) {
static const char db_type_prefix = detail::get_rocksdb_contract_db_prefix_as_char();
static const char db_type_prefix = make_rocksdb_contract_db_prefix();
b1::chain_kv::bytes code_as_bytes;
b1::chain_kv::append_key(code_as_bytes, code.to_uint64_t());
auto ret = eosio::session::make_shared_bytes<std::string_view, 3>({std::string_view{&db_type_prefix, 1},
Expand Down Expand Up @@ -244,7 +234,7 @@ namespace eosio { namespace chain { namespace backing_store { namespace db_key_v
}

full_key_data parse_full_key(const eosio::session::shared_bytes& full_key) {
static const char db_type_prefix = detail::get_rocksdb_contract_db_prefix_as_char();
static const char db_type_prefix = make_rocksdb_contract_db_prefix();
EOS_ASSERT( full_key.size() >= 1, db_rocksdb_invalid_operation_exception,
"parse_full_key was passed an empty key.");
full_key_data data;
Expand Down
349 changes: 83 additions & 266 deletions libraries/chain/combined_database.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions libraries/chain/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ struct controller_impl {
reversible_blocks.add_index<reversible_block_index>();

controller_index_set::add_indices(db);
db.add_index<kv_index>();
contract_database_index_set::add_indices(db);

authorization.add_indices();
Expand Down
Loading

0 comments on commit 2077111

Please sign in to comment.