提交 ed825191 编写于 作者: D Daniel Larimer

rename eos_assert to eosio_assert, implement is_account() api, and move...

rename eos_assert to eosio_assert, implement is_account() api, and move implementation from apply_context.hpp to .cpp
上级 e71af89d
......@@ -29,9 +29,9 @@ extern "C" {
}
// maybe assert?
eos_assert(def->condition, def->message);
eosio_assert(def->condition, def->message);
} else if( action == N(provereset) ) {
eos_assert(global_variable == 45, "Global Variable Initialized poorly");
eosio_assert(global_variable == 45, "Global Variable Initialized poorly");
global_variable = 100;
}
}
......
......@@ -2,7 +2,7 @@ file(GLOB ABI_FILES "*.abi")
configure_file("${ABI_FILES}" "${CMAKE_CURRENT_BINARY_DIR}" COPYONLY)
add_wast_executable(TARGET eosio.system
INCLUDE_FOLDERS ${STANDARD_INCLUDE_FOLDERS} /usr/local/include
INCLUDE_FOLDERS ${STANDARD_INCLUDE_FOLDERS} ${Boost_INCLUDE_DIR}
LIBRARIES libc++ libc eosiolib
DESTINATION_FOLDER ${CMAKE_CURRENT_BINARY_DIR}
)
......@@ -40,7 +40,7 @@ namespace eosio {
T current_action() {
T value;
auto read = read_action( &value, sizeof(value) );
eos_assert( read >= sizeof(value), "action shorter than expected" );
eosio_assert( read >= sizeof(value), "action shorter than expected" );
return value;
}
......
......@@ -34,7 +34,7 @@ class datastream {
* @param s the number of bytes to read
*/
inline bool read( char* d, size_t s ) {
eos_assert( size_t(_end - _pos) >= (size_t)s, "read" );
eosio_assert( size_t(_end - _pos) >= (size_t)s, "read" );
memcpy( d, _pos, s );
_pos += s;
return true;
......@@ -47,7 +47,7 @@ class datastream {
* @param s The number of bytes to write
*/
inline bool write( const char* d, size_t s ) {
eos_assert( _end - _pos >= (int32_t)s, "write" );
eosio_assert( _end - _pos >= (int32_t)s, "write" );
memcpy( _pos, d, s );
_pos += s;
return true;
......@@ -59,7 +59,7 @@ class datastream {
* @param c byte to write
*/
inline bool put(char c) {
eos_assert( _pos < _end, "put" );
eosio_assert( _pos < _end, "put" );
*_pos = c;
++_pos;
return true;
......@@ -73,7 +73,7 @@ class datastream {
inline bool get( unsigned char& c ) { return get( *(char*)&c ); }
inline bool get( char& c )
{
eos_assert( _pos < _end, "get" );
eosio_assert( _pos < _end, "get" );
c = *_pos;
++_pos;
return true;
......
......@@ -42,7 +42,7 @@ namespace eosio {
template<typename DataStream>
friend DataStream& operator >> ( DataStream& ds, transfer& t ){
ds >> t.from >> t.to >> t.quantity;
eos_assert( t.quantity.symbol== token_type::symbol, "unexpected asset type" );
eosio_assert( t.quantity.symbol== token_type::symbol, "unexpected asset type" );
return ds;
}
};
......
......@@ -102,7 +102,7 @@ namespace eosio {
}
explicit operator uint64_t()const {
eos_assert( !(value >> 64), "cast to 64 bit loss of precision" );
eosio_assert( !(value >> 64), "cast to 64 bit loss of precision" );
return uint64_t(value);
}
......
......@@ -27,7 +27,7 @@ namespace eosio {
char temp[1024+8];
*reinterpret_cast<uint64_t *>(temp) = SingletonName;
auto read = load_i64( Code, scope, SingletonName, temp, sizeof(temp) );
eos_assert( read > 0, "singleton does not exist" );
eosio_assert( read > 0, "singleton does not exist" );
return unpack<T>( temp + sizeof(SingletonName), read );
}
......@@ -58,7 +58,7 @@ namespace eosio {
auto size = pack_size( value );
char buf[size+ sizeof(SingletonName)];
eos_assert( sizeof(buf) <= 1024 + 8, "singleton too big to store" );
eosio_assert( sizeof(buf) <= 1024 + 8, "singleton too big to store" );
datastream<char*> ds( buf, size + sizeof(SingletonName) );
ds << SingletonName;
......
......@@ -29,7 +29,7 @@ extern "C" {
* @param cstr - a null terminated action to explain the reason for failure
*/
void eos_assert( uint32_t test, const char* cstr );
void eosio_assert( uint32_t test, const char* cstr );
/**
* Returns the time in seconds from 1970 of the last accepted block (not the block including this action)
......
......@@ -21,7 +21,7 @@ namespace eosio {
char temp[1024];
*reinterpret_cast<uint64_t *>(temp) = key;
auto read = load_i64( DefaultScope, scope , TableName, temp, sizeof(temp) );
eos_assert( read > 0, "key does not exist" );
eosio_assert( read > 0, "key does not exist" );
datastream<const char*> ds(temp, read);
T result;
......@@ -63,7 +63,7 @@ namespace eosio {
static void set( const T& value = T(), scope_name scope = DefaultScope, uint64_t bta = BillToAccount ) {
auto size = pack_size( value );
char buf[size];
eos_assert( size <= 1024, "singleton too big to store" );
eosio_assert( size <= 1024, "singleton too big to store" );
datastream<char*> ds( buf, size );
ds << value;
......
......@@ -41,7 +41,7 @@ namespace eosio {
operator asset()const { return asset( quantity, Symbol ); }
token( const asset& a ):quantity(a.amount) {
eos_assert( a.symbol == Symbol, "attempt to construct token from asset with different symbol" );
eosio_assert( a.symbol == Symbol, "attempt to construct token from asset with different symbol" );
}
/**
......@@ -65,7 +65,7 @@ namespace eosio {
* @return this token after subtraction
*/
token& operator-=( const token& a ) {
eos_assert( quantity >= a.quantity, "integer underflow subtracting token balance" );
eosio_assert( quantity >= a.quantity, "integer underflow subtracting token balance" );
quantity -= a.quantity;
return *this;
}
......@@ -78,7 +78,7 @@ namespace eosio {
* @return this token after addition
*/
token& operator+=( const token& a ) {
eos_assert( quantity + a.quantity >= a.quantity, "integer overflow adding token balance" );
eosio_assert( quantity + a.quantity >= a.quantity, "integer overflow adding token balance" );
quantity += a.quantity;
return *this;
}
......@@ -258,8 +258,8 @@ namespace eosio {
* @param quote - quote token
*/
price( BaseToken base, QuoteToken quote ) {
eos_assert( base >= BaseToken(1ul), "invalid price" );
eos_assert( quote >= QuoteToken(1ul), "invalid price" );
eosio_assert( base >= BaseToken(1ul), "invalid price" );
eosio_assert( quote >= QuoteToken(1ul), "invalid price" );
base_per_quote = base.quantity;
base_per_quote *= precision;
......
......@@ -307,8 +307,8 @@ namespace identity {
static void on( const create& c ) {
require_auth( c.creator );
eos_assert( !idents_table::exists( c.identity ), "identity already exists" );
eos_assert( c.identity != 0, "identity=0 is not allowed" );
eosio_assert( !idents_table::exists( c.identity ), "identity already exists" );
eosio_assert( c.identity != 0, "identity=0 is not allowed" );
idents_table::set( identrow{ .identity = c.identity,
.creator = c.creator } );
}
......@@ -318,7 +318,7 @@ namespace identity {
if( cert.bill_storage_to != cert.certifier )
require_auth( cert.bill_storage_to );
eos_assert( idents_table::exists( cert.identity ), "identity does not exist" );
eosio_assert( idents_table::exists( cert.identity ), "identity does not exist" );
/// the table exists in the scope of the identity
certs_table certs( cert.identity );
......@@ -330,7 +330,7 @@ namespace identity {
row.trusted = is_trusted( cert.certifier );
row.certifier = cert.certifier;
row.confidence = value.confidence;
eos_assert(value.type.size() <= 32, "certrow::type should be not longer than 32 bytes");
eosio_assert(value.type.size() <= 32, "certrow::type should be not longer than 32 bytes");
row.type = value.type;
row.data = value.data;
......@@ -340,7 +340,7 @@ namespace identity {
//special handling for owner
if (value.property == N(owner)) {
eos_assert(sizeof(account_name) == value.data.size(), "data size doesn't match account_name size");
eosio_assert(sizeof(account_name) == value.data.size(), "data size doesn't match account_name size");
account_name acnt = *reinterpret_cast<const account_name*>(value.data.data());
if (cert.certifier == acnt) { //only self-certitication affects accounts_table
accounts_table::set( cert.identity, acnt );
......@@ -352,7 +352,7 @@ namespace identity {
certs.remove(value.property, 1, cert.certifier);
//special handling for owner
if (value.property == N(owner)) {
eos_assert(sizeof(account_name) == value.data.size(), "data size doesn't match account_name size");
eosio_assert(sizeof(account_name) == value.data.size(), "data size doesn't match account_name size");
account_name acnt = *reinterpret_cast<const account_name*>(value.data.data());
if (cert.certifier == acnt) { //only self-certitication affects accounts_table
accounts_table::remove( acnt );
......
......@@ -29,11 +29,11 @@ namespace proxy {
config code_config;
const auto self = current_receiver();
auto get_res = configs::get(code_config, self);
eos_assert(get_res, "Attempting to use unconfigured proxy");
eosio_assert(get_res, "Attempting to use unconfigured proxy");
if (transfer.from == self) {
eos_assert(transfer.to == code_config.owner, "proxy may only pay its owner" );
eosio_assert(transfer.to == code_config.owner, "proxy may only pay its owner" );
} else {
eos_assert(transfer.to == self, "proxy is not involved in this transfer");
eosio_assert(transfer.to == self, "proxy is not involved in this transfer");
T new_transfer = T(transfer);
new_transfer.from = self;
new_transfer.to = code_config.owner;
......@@ -62,7 +62,7 @@ namespace proxy {
eosio::print("starting onerror\n");
const auto self = current_receiver();
config code_config;
eos_assert(configs::get(code_config, self), "Attempting use of unconfigured proxy");
eosio_assert(configs::get(code_config, self), "Attempting use of unconfigured proxy");
auto id = code_config.next_id++;
configs::store(code_config, self);
......
......@@ -11,26 +11,26 @@ void test_action::read_action_normal() {
char buffer[100];
uint32_t total = 0;
eos_assert( current_receiver() == N(testapi), "current_receiver() == N(testapi)" );
eosio_assert( current_receiver() == N(testapi), "current_receiver() == N(testapi)" );
eos_assert(action_size() == sizeof(dummy_action), "action_size() == sizeof(dummy_action)");
eosio_assert(action_size() == sizeof(dummy_action), "action_size() == sizeof(dummy_action)");
total = read_action(buffer, 30);
eos_assert(total == sizeof(dummy_action) , "read_action(30)" );
eosio_assert(total == sizeof(dummy_action) , "read_action(30)" );
total = read_action(buffer, 100);
eos_assert(total == sizeof(dummy_action) , "read_action(100)" );
eosio_assert(total == sizeof(dummy_action) , "read_action(100)" );
total = read_action(buffer, 5);
eos_assert(total == 5 , "read_action(5)" );
eosio_assert(total == 5 , "read_action(5)" );
total = read_action(buffer, sizeof(dummy_action) );
eos_assert(total == sizeof(dummy_action), "read_action(sizeof(dummy_action))" );
eosio_assert(total == sizeof(dummy_action), "read_action(sizeof(dummy_action))" );
dummy_action *dummy13 = reinterpret_cast<dummy_action *>(buffer);
eos_assert(dummy13->a == DUMMY_MESSAGE_DEFAULT_A, "dummy13->a == DUMMY_MESSAGE_DEFAULT_A");
eos_assert(dummy13->b == DUMMY_MESSAGE_DEFAULT_B, "dummy13->b == DUMMY_MESSAGE_DEFAULT_B");
eos_assert(dummy13->c == DUMMY_MESSAGE_DEFAULT_C, "dummy13->c == DUMMY_MESSAGE_DEFAULT_C");
eosio_assert(dummy13->a == DUMMY_MESSAGE_DEFAULT_A, "dummy13->a == DUMMY_MESSAGE_DEFAULT_A");
eosio_assert(dummy13->b == DUMMY_MESSAGE_DEFAULT_B, "dummy13->b == DUMMY_MESSAGE_DEFAULT_B");
eosio_assert(dummy13->c == DUMMY_MESSAGE_DEFAULT_C, "dummy13->c == DUMMY_MESSAGE_DEFAULT_C");
}
......@@ -61,11 +61,11 @@ void test_action::read_action_to_64k() {
//}
void test_action::assert_false() {
eos_assert(false, "test_action::assert_false");
eosio_assert(false, "test_action::assert_false");
}
void test_action::assert_true() {
eos_assert(true, "test_action::assert_true");
eosio_assert(true, "test_action::assert_true");
}
//unsigned int test_action::now() {
......
......@@ -154,7 +154,7 @@ extern "C" {
// WASM_TEST_HANDLER(test_account, test_balance_acc1);
//
//unhandled test call
eos_assert(false, "Unknown Test");
eosio_assert(false, "Unknown Test");
}
}
......@@ -109,6 +109,10 @@ void apply_context::exec()
} /// exec()
bool apply_context::is_account( const account_name& account )const {
return nullptr != db.find<account_object,by_name>( account );
}
void apply_context::require_authorization( const account_name& account )const {
for( const auto& auth : act.authorization )
if( auth.actor == account ) return;
......@@ -292,6 +296,164 @@ void apply_context::validate_or_add_table_key( const table_id_object& t_id, cont
("code",t_id.code)("scope",t_id.scope)("table",t_id.table)("act_type",to_string(t_id.key_type))("exp_type", to_string(key_type)) );
}
void apply_context::update_db_usage( const account_name& payer, int64_t delta ) {
require_write_lock( payer );
if( (delta > 0) && payer != account_name(receiver) ) {
require_authorization( payer );
}
}
int apply_context::db_store_i64( uint64_t scope, uint64_t table, const account_name& payer, uint64_t id, const char* buffer, size_t buffer_size ) {
require_write_lock( scope );
const auto& tab = find_or_create_table( receiver, scope, table );
auto tableid = tab.id;
validate_or_add_table_key(tab, contracts::table_key_type::type_i64);
FC_ASSERT( payer != account_name(), "must specify a valid account to pay for new record" );
const auto& obj = mutable_db.create<key_value_object>( [&]( auto& o ) {
o.t_id = tableid;
o.primary_key = id;
o.value.resize( buffer_size );
o.payer = payer;
memcpy( o.value.data(), buffer, buffer_size );
});
mutable_db.modify( tab, [&]( auto& t ) {
++t.count;
});
update_db_usage( payer, buffer_size + 200 );
keyval_cache.cache_table( tab );
return keyval_cache.add( obj );
}
void apply_context::db_update_i64( int iterator, account_name payer, const char* buffer, size_t buffer_size ) {
const key_value_object& obj = keyval_cache.get( iterator );
require_write_lock( keyval_cache.get_table( obj.t_id ).scope );
int64_t old_size = obj.value.size();
if( payer == account_name() ) payer = obj.payer;
if( account_name(obj.payer) == payer ) {
update_db_usage( obj.payer, buffer_size + 200 - old_size );
} else {
update_db_usage( obj.payer, -(old_size+200) );
update_db_usage( payer, (buffer_size+200) );
}
mutable_db.modify( obj, [&]( auto& o ) {
o.value.resize( buffer_size );
memcpy( o.value.data(), buffer, buffer_size );
o.payer = payer;
});
}
void apply_context::db_remove_i64( int iterator ) {
const key_value_object& obj = keyval_cache.get( iterator );
update_db_usage( obj.payer, -(obj.value.size()+200) );
const auto& table_obj = keyval_cache.get_table( obj.t_id );
require_write_lock( table_obj.scope );
mutable_db.modify( table_obj, [&]( auto& t ) {
--t.count;
});
mutable_db.remove( obj );
keyval_cache.remove( iterator, obj );
}
int apply_context::db_get_i64( int iterator, char* buffer, size_t buffer_size ) {
const key_value_object& obj = keyval_cache.get( iterator );
if( buffer_size >= obj.value.size() )
memcpy( buffer, obj.value.data(), obj.value.size() );
return obj.value.size();
}
int apply_context::db_next_i64( int iterator, uint64_t& primary ) {
const auto& obj = keyval_cache.get( iterator );
const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>();
auto itr = idx.iterator_to( obj );
++itr;
if( itr == idx.end() ) return -1;
if( itr->t_id != obj.t_id ) return -1;
primary = itr->primary_key;
return keyval_cache.add( *itr );
}
int apply_context::db_previous_i64( int iterator, uint64_t& primary ) {
const auto& obj = keyval_cache.get(iterator);
const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>();
auto itr = idx.iterator_to(obj);
if (itr == idx.end() || itr == idx.begin()) return -1;
--itr;
if (itr->t_id != obj.t_id) return -1;
primary = itr->primary_key;
return keyval_cache.add(*itr);
}
int apply_context::db_find_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ) {
require_read_lock( code, scope );
const auto* tab = find_table( code, scope, table );
if( !tab ) return -1;
validate_table_key(*tab, contracts::table_key_type::type_i64);
const key_value_object* obj = db.find<key_value_object, contracts::by_scope_primary>( boost::make_tuple( tab->id, id ) );
if( !obj ) return -1;
keyval_cache.cache_table( *tab );
return keyval_cache.add( *obj );
}
int apply_context::db_lowerbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ) {
require_read_lock( code, scope );
const auto* tab = find_table( code, scope, table );
if( !tab ) return -1;
validate_table_key(*tab, contracts::table_key_type::type_i64);
const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>();
auto itr = idx.lower_bound( boost::make_tuple( tab->id, id ) );
if( itr == idx.end() ) return -1;
if( itr->t_id != tab->id ) return -1;
keyval_cache.cache_table( *tab );
return keyval_cache.add( *itr );
}
int apply_context::db_upperbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ) {
require_read_lock( code, scope );
const auto* tab = find_table( code, scope, table );
if( !tab ) return -1;
validate_table_key(*tab, contracts::table_key_type::type_i64);
const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>();
auto itr = idx.upper_bound( boost::make_tuple( tab->id, id ) );
if( itr == idx.end() ) return -1;
if( itr->t_id != tab->id ) return -1;
keyval_cache.cache_table( *tab );
return keyval_cache.add( *itr );
}
template<>
contracts::table_key_type apply_context::get_key_type<contracts::key_value_object>() {
return contracts::table_key_type::type_i64;
......
......@@ -362,6 +362,11 @@ class apply_context {
void require_write_lock(const scope_name& scope);
void require_read_lock(const account_name& account, const scope_name& scope);
/**
* @return true if account exists, false if it does not
*/
bool is_account(const account_name& account)const;
/**
* Requires that the current action be delivered to account
*/
......@@ -395,51 +400,6 @@ class apply_context {
const transaction_metadata& trx_meta;
///< pending transaction construction
/*
typedef uint32_t pending_transaction_handle;
struct pending_transaction : public transaction {
typedef uint32_t handle_type;
pending_transaction(const handle_type& _handle, const apply_context& _context, const uint16_t& block_num, const uint32_t& block_ref, const time_point& expiration )
: transaction(block_num, block_ref, expiration, vector<account_name>(), vector<account_name>(), vector<action>())
, handle(_handle)
, context(_context) {}
handle_type handle;
const apply_context& context;
void check_size() const;
};
pending_transaction::handle_type next_pending_transaction_serial;
vector<pending_transaction> pending_transactions;
pending_transaction& get_pending_transaction(pending_transaction::handle_type handle);
pending_transaction& create_pending_transaction();
void release_pending_transaction(pending_transaction::handle_type handle);
///< pending message construction
typedef uint32_t pending_message_handle;
struct pending_message : public action {
typedef uint32_t handle_type;
pending_message(const handle_type& _handle, const account_name& code, const action_name& type, const vector<char>& data)
: action(code, type, vector<permission_level>(), data)
, handle(_handle) {}
handle_type handle;
};
pending_transaction::handle_type next_pending_message_serial;
vector<pending_message> pending_messages;
pending_message& get_pending_message(pending_message::handle_type handle);
pending_message& create_pending_message(const account_name& code, const action_name& type, const vector<char>& data);
void release_pending_message(pending_message::handle_type handle);
*/
struct apply_results {
vector<action_trace> applied_actions;
vector<deferred_transaction> generated_transactions;
......@@ -465,164 +425,16 @@ class apply_context {
void checktime(uint32_t instruction_count) const;
void update_db_usage( const account_name& payer, int64_t delta ) {
require_write_lock( payer );
if( (delta > 0) && payer != account_name(receiver) ) {
require_authorization( payer );
}
}
int db_store_i64( uint64_t scope, uint64_t table, const account_name& payer, uint64_t id, const char* buffer, size_t buffer_size ) {
require_write_lock( scope );
const auto& tab = find_or_create_table( receiver, scope, table );
auto tableid = tab.id;
validate_or_add_table_key(tab, contracts::table_key_type::type_i64);
FC_ASSERT( payer != account_name(), "must specify a valid account to pay for new record" );
const auto& obj = mutable_db.create<key_value_object>( [&]( auto& o ) {
o.t_id = tableid;
o.primary_key = id;
o.value.resize( buffer_size );
o.payer = payer;
memcpy( o.value.data(), buffer, buffer_size );
});
mutable_db.modify( tab, [&]( auto& t ) {
++t.count;
});
update_db_usage( payer, buffer_size + 200 );
keyval_cache.cache_table( tab );
return keyval_cache.add( obj );
}
void db_update_i64( int iterator, account_name payer, const char* buffer, size_t buffer_size ) {
const key_value_object& obj = keyval_cache.get( iterator );
require_write_lock( keyval_cache.get_table( obj.t_id ).scope );
int64_t old_size = obj.value.size();
if( payer == account_name() ) payer = obj.payer;
if( account_name(obj.payer) == payer ) {
update_db_usage( obj.payer, buffer_size + 200 - old_size );
} else {
update_db_usage( obj.payer, -(old_size+200) );
update_db_usage( payer, (buffer_size+200) );
}
mutable_db.modify( obj, [&]( auto& o ) {
o.value.resize( buffer_size );
memcpy( o.value.data(), buffer, buffer_size );
o.payer = payer;
});
}
void db_remove_i64( int iterator ) {
const key_value_object& obj = keyval_cache.get( iterator );
update_db_usage( obj.payer, -(obj.value.size()+200) );
const auto& table_obj = keyval_cache.get_table( obj.t_id );
require_write_lock( table_obj.scope );
mutable_db.modify( table_obj, [&]( auto& t ) {
--t.count;
});
mutable_db.remove( obj );
keyval_cache.remove( iterator, obj );
}
int db_get_i64( int iterator, char* buffer, size_t buffer_size ) {
const key_value_object& obj = keyval_cache.get( iterator );
if( buffer_size >= obj.value.size() )
memcpy( buffer, obj.value.data(), obj.value.size() );
return obj.value.size();
}
int db_next_i64( int iterator, uint64_t& primary ) {
const auto& obj = keyval_cache.get( iterator );
const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>();
auto itr = idx.iterator_to( obj );
++itr;
if( itr == idx.end() ) return -1;
if( itr->t_id != obj.t_id ) return -1;
primary = itr->primary_key;
return keyval_cache.add( *itr );
}
int db_previous_i64( int iterator, uint64_t& primary ) {
const auto& obj = keyval_cache.get(iterator);
const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>();
auto itr = idx.iterator_to(obj);
if (itr == idx.end() || itr == idx.begin()) return -1;
--itr;
if (itr->t_id != obj.t_id) return -1;
primary = itr->primary_key;
return keyval_cache.add(*itr);
}
int db_find_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ) {
require_read_lock( code, scope );
const auto* tab = find_table( code, scope, table );
if( !tab ) return -1;
validate_table_key(*tab, contracts::table_key_type::type_i64);
const key_value_object* obj = db.find<key_value_object, contracts::by_scope_primary>( boost::make_tuple( tab->id, id ) );
if( !obj ) return -1;
keyval_cache.cache_table( *tab );
return keyval_cache.add( *obj );
}
int db_lowerbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ) {
require_read_lock( code, scope );
const auto* tab = find_table( code, scope, table );
if( !tab ) return -1;
validate_table_key(*tab, contracts::table_key_type::type_i64);
const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>();
auto itr = idx.lower_bound( boost::make_tuple( tab->id, id ) );
if( itr == idx.end() ) return -1;
if( itr->t_id != tab->id ) return -1;
keyval_cache.cache_table( *tab );
return keyval_cache.add( *itr );
}
int db_upperbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id ) {
require_read_lock( code, scope );
const auto* tab = find_table( code, scope, table );
if( !tab ) return -1;
validate_table_key(*tab, contracts::table_key_type::type_i64);
const auto& idx = db.get_index<contracts::key_value_index, contracts::by_scope_primary>();
auto itr = idx.upper_bound( boost::make_tuple( tab->id, id ) );
if( itr == idx.end() ) return -1;
if( itr->t_id != tab->id ) return -1;
keyval_cache.cache_table( *tab );
return keyval_cache.add( *itr );
}
void update_db_usage( const account_name& payer, int64_t delta );
int db_store_i64( uint64_t scope, uint64_t table, const account_name& payer, uint64_t id, const char* buffer, size_t buffer_size );
void db_update_i64( int iterator, account_name payer, const char* buffer, size_t buffer_size );
void db_remove_i64( int iterator );
int db_get_i64( int iterator, char* buffer, size_t buffer_size );
int db_next_i64( int iterator, uint64_t& primary );
int db_previous_i64( int iterator, uint64_t& primary );
int db_find_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id );
int db_lowerbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id );
int db_upperbound_i64( uint64_t code, uint64_t scope, uint64_t table, uint64_t id );
generic_index<contracts::index64_object> idx64;
generic_index<contracts::index128_object> idx128;
......
......@@ -609,7 +609,7 @@ class system_api : public context_aware_api {
FC_ASSERT( false, "abort() called");
}
void eos_assert(bool condition, null_terminated_ptr str) {
void eosio_assert(bool condition, null_terminated_ptr str) {
std::string message( str );
if( !condition ) edump((message));
FC_ASSERT( condition, "assertion failed: ${s}", ("s",message));
......@@ -1082,8 +1082,8 @@ REGISTER_INTRINSICS(string_api,
);
REGISTER_INTRINSICS(system_api,
(abort, void())
(eos_assert, void(int, int))
(abort, void())
(eosio_assert, void(int, int))
(now, int())
);
......@@ -1096,10 +1096,11 @@ REGISTER_INTRINSICS(action_api,
);
REGISTER_INTRINSICS(apply_context,
(require_write_lock, void(int64_t) )
(require_write_lock, void(int64_t) )
(require_read_lock, void(int64_t, int64_t) )
(require_recipient, void(int64_t) )
(require_recipient, void(int64_t) )
(require_authorization, void(int64_t), "require_auth", void(apply_context::*)(const account_name&)const)
(is_account, int(int64_t) )
);
REGISTER_INTRINSICS(console_api,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册