14
14
#include < eosio/chain/kv_chainbase_objects.hpp>
15
15
16
16
using boost::container::flat_set;
17
+ using namespace eosio ::chain::backing_store;
17
18
18
19
namespace eosio { namespace chain {
19
20
20
- using db_context = backing_store::db_context;
21
-
22
21
static inline void print_debug (account_name receiver, const action_trace& ar) {
23
22
if (!ar.console .empty ()) {
24
23
auto prefix = fc::format_string (
@@ -51,7 +50,6 @@ apply_context::apply_context(controller& con, transaction_context& trx_ctx, uint
51
50
act = &trace.act ;
52
51
receiver = trace.receiver ;
53
52
context_free = trace.context_free ;
54
- _db_context = control.kv_db ().create_db_context (*this , receiver);
55
53
}
56
54
57
55
template <typename Exception>
@@ -104,7 +102,7 @@ void apply_context::exec_one()
104
102
kv_iterators.resize (1 );
105
103
kv_destroyed_iterators.clear ();
106
104
if (!context_free) {
107
- kv_backing_store = control. kv_db (). create_kv_context (receiver, create_kv_resource_manager (*this ), control.get_global_properties ().kv_configuration );
105
+ kv_backing_store = db_util:: create_kv_context (control, receiver, create_kv_resource_manager (*this ), control.get_global_properties ().kv_configuration );
108
106
}
109
107
receiver_account = &db.get <account_metadata_object,by_name>( receiver );
110
108
if ( !(context_free && control.skip_trx_checks ()) ) {
@@ -222,7 +220,6 @@ void apply_context::exec()
222
220
increment_action_id ();
223
221
for ( uint32_t i = 1 ; i < _notified.size (); ++i ) {
224
222
std::tie ( receiver, action_ordinal ) = _notified[i];
225
- _db_context->receiver = receiver;
226
223
exec_one ();
227
224
increment_action_id ();
228
225
}
@@ -846,7 +843,7 @@ int apply_context::get_context_free_data( uint32_t index, char* buffer, size_t b
846
843
return copy_size;
847
844
}
848
845
849
- int apply_context::db_store_i64_chainbase ( name scope, name table, const account_name& payer, uint64_t id, const char * buffer, size_t buffer_size ) {
846
+ int apply_context::db_store_i64 ( name scope, name table, const account_name& payer, uint64_t id, const char * buffer, size_t buffer_size ) {
850
847
// require_write_lock( scope );
851
848
const auto & tab = find_or_create_table ( receiver, scope, table, payer );
852
849
auto tableid = tab.id ;
@@ -881,7 +878,7 @@ int apply_context::db_store_i64_chainbase( name scope, name table, const account
881
878
return db_iter_store.add ( obj );
882
879
}
883
880
884
- void apply_context::db_update_i64_chainbase ( int iterator, account_name payer, const char * buffer, size_t buffer_size ) {
881
+ void apply_context::db_update_i64 ( int iterator, account_name payer, const char * buffer, size_t buffer_size ) {
885
882
const key_value_object& obj = db_iter_store.get ( iterator );
886
883
887
884
const auto & table_obj = db_iter_store.get_table ( obj.t_id );
@@ -922,7 +919,7 @@ void apply_context::db_update_i64_chainbase( int iterator, account_name payer, c
922
919
});
923
920
}
924
921
925
- void apply_context::db_remove_i64_chainbase ( int iterator ) {
922
+ void apply_context::db_remove_i64 ( int iterator ) {
926
923
const key_value_object& obj = db_iter_store.get ( iterator );
927
924
928
925
const auto & table_obj = db_iter_store.get_table ( obj.t_id );
@@ -953,7 +950,7 @@ void apply_context::db_remove_i64_chainbase( int iterator ) {
953
950
db_iter_store.remove ( iterator );
954
951
}
955
952
956
- int apply_context::db_get_i64_chainbase ( int iterator, char * buffer, size_t buffer_size ) {
953
+ int apply_context::db_get_i64 ( int iterator, char * buffer, size_t buffer_size ) {
957
954
const key_value_object& obj = db_iter_store.get ( iterator );
958
955
959
956
auto s = obj.value .size ();
@@ -965,7 +962,7 @@ int apply_context::db_get_i64_chainbase( int iterator, char* buffer, size_t buff
965
962
return copy_size;
966
963
}
967
964
968
- int apply_context::db_next_i64_chainbase ( int iterator, uint64_t & primary ) {
965
+ int apply_context::db_next_i64 ( int iterator, uint64_t & primary ) {
969
966
if ( iterator < -1 ) return -1 ; // cannot increment past end iterator of table
970
967
971
968
const auto & obj = db_iter_store.get ( iterator ); // Check for iterator != -1 happens in this call
@@ -980,7 +977,7 @@ int apply_context::db_next_i64_chainbase( int iterator, uint64_t& primary ) {
980
977
return db_iter_store.add ( *itr );
981
978
}
982
979
983
- int apply_context::db_previous_i64_chainbase ( int iterator, uint64_t & primary ) {
980
+ int apply_context::db_previous_i64 ( int iterator, uint64_t & primary ) {
984
981
const auto & idx = db.get_index <key_value_index, by_scope_primary>();
985
982
986
983
if ( iterator < -1 ) // is end iterator
@@ -1012,7 +1009,7 @@ int apply_context::db_previous_i64_chainbase( int iterator, uint64_t& primary )
1012
1009
return db_iter_store.add (*itr);
1013
1010
}
1014
1011
1015
- int apply_context::db_find_i64_chainbase ( name code, name scope, name table, uint64_t id ) {
1012
+ int apply_context::db_find_i64 ( name code, name scope, name table, uint64_t id ) {
1016
1013
// require_read_lock( code, scope ); // redundant?
1017
1014
1018
1015
const auto * tab = find_table ( code, scope, table );
@@ -1026,7 +1023,7 @@ int apply_context::db_find_i64_chainbase( name code, name scope, name table, uin
1026
1023
return db_iter_store.add ( *obj );
1027
1024
}
1028
1025
1029
- int apply_context::db_lowerbound_i64_chainbase ( name code, name scope, name table, uint64_t id ) {
1026
+ int apply_context::db_lowerbound_i64 ( name code, name scope, name table, uint64_t id ) {
1030
1027
// require_read_lock( code, scope ); // redundant?
1031
1028
1032
1029
const auto * tab = find_table ( code, scope, table );
@@ -1042,7 +1039,7 @@ int apply_context::db_lowerbound_i64_chainbase( name code, name scope, name tabl
1042
1039
return db_iter_store.add ( *itr );
1043
1040
}
1044
1041
1045
- int apply_context::db_upperbound_i64_chainbase ( name code, name scope, name table, uint64_t id ) {
1042
+ int apply_context::db_upperbound_i64 ( name code, name scope, name table, uint64_t id ) {
1046
1043
// require_read_lock( code, scope ); // redundant?
1047
1044
1048
1045
const auto * tab = find_table ( code, scope, table );
@@ -1058,7 +1055,7 @@ int apply_context::db_upperbound_i64_chainbase( name code, name scope, name tabl
1058
1055
return db_iter_store.add ( *itr );
1059
1056
}
1060
1057
1061
- int apply_context::db_end_i64_chainbase ( name code, name scope, name table ) {
1058
+ int apply_context::db_end_i64 ( name code, name scope, name table ) {
1062
1059
// require_read_lock( code, scope ); // redundant?
1063
1060
1064
1061
const auto * tab = find_table ( code, scope, table );
@@ -1068,19 +1065,19 @@ int apply_context::db_end_i64_chainbase( name code, name scope, name table ) {
1068
1065
}
1069
1066
1070
1067
int64_t apply_context::kv_erase (uint64_t contract, const char * key, uint32_t key_size) {
1071
- return kv_get_backing_store ().kv_erase (contract, key, key_size);
1068
+ return get_kv_context ().kv_erase (contract, key, key_size);
1072
1069
}
1073
1070
1074
1071
int64_t apply_context::kv_set (uint64_t contract, const char * key, uint32_t key_size, const char * value, uint32_t value_size, account_name payer) {
1075
- return kv_get_backing_store ().kv_set (contract, key, key_size, value, value_size, payer);
1072
+ return get_kv_context ().kv_set (contract, key, key_size, value, value_size, payer);
1076
1073
}
1077
1074
1078
1075
bool apply_context::kv_get (uint64_t contract, const char * key, uint32_t key_size, uint32_t & value_size) {
1079
- return kv_get_backing_store ().kv_get (contract, key, key_size, value_size);
1076
+ return get_kv_context ().kv_get (contract, key, key_size, value_size);
1080
1077
}
1081
1078
1082
1079
uint32_t apply_context::kv_get_data (uint32_t offset, char * data, uint32_t data_size) {
1083
- return kv_get_backing_store ().kv_get_data (offset, data, data_size);
1080
+ return get_kv_context ().kv_get_data (offset, data, data_size);
1084
1081
}
1085
1082
1086
1083
uint32_t apply_context::kv_it_create (uint64_t contract, const char * prefix, uint32_t size) {
@@ -1094,7 +1091,7 @@ uint32_t apply_context::kv_it_create(uint64_t contract, const char* prefix, uint
1094
1091
itr = kv_iterators.size ();
1095
1092
kv_iterators.emplace_back ();
1096
1093
}
1097
- kv_iterators[itr] = kv_get_backing_store ().kv_it_create (contract, prefix, size);
1094
+ kv_iterators[itr] = get_kv_context ().kv_it_create (contract, prefix, size);
1098
1095
return itr;
1099
1096
}
1100
1097
@@ -1201,10 +1198,4 @@ uint32_t apply_context::get_action_id() const {
1201
1198
void apply_context::increment_action_id () {
1202
1199
trx_context.action_id .increment ();
1203
1200
}
1204
-
1205
- db_context& apply_context::db_get_context () {
1206
- EOS_ASSERT ( _db_context, action_validate_exception,
1207
- " context-free actions cannot access state" );
1208
- return *_db_context;
1209
- }
1210
1201
} } // / eosio::chain
0 commit comments