提交 213fa8dc 编写于 作者: A Anton Perkov

rename assert to eos_assert

上级 2cf8fcc2
......@@ -61,8 +61,8 @@ extern "C" {
* account_name code = current_receiver();
* print(Name(code)); // Output: eos
*
* assert(Name(current_receiver()) === "eos", "This action expects to be received by eos"); // Do nothing
* assert(Name(current_receiver()) === "inita", "This action expects to be received by inita"); // Throws exception and roll back transfer transaction
* eos_assert(Name(current_receiver()) === "eos", "This action expects to be received by eos"); // Do nothing
* eos_assert(Name(current_receiver()) === "inita", "This action expects to be received by inita"); // Throws exception and roll back transfer transaction
*
* print(now()); // Output: timestamp of last accepted block
*
......
......@@ -39,7 +39,7 @@ namespace eosio {
T current_action() {
T value;
auto read = read_action( &value, sizeof(value) );
assert( read >= sizeof(value), "action shorter than expected" );
eos_assert( read >= sizeof(value), "action shorter than expected" );
return value;
}
......
......@@ -51,7 +51,7 @@
if( action == N(transfer) )
currency::apply_currency_transfer( current_action< currency::transfer >() );
} else {
assert( false, "rejecting unexpected event" );
eos_assert( false, "rejecting unexpected event" );
}
}
}
......
......@@ -10,14 +10,14 @@ extern "C" {
*
* checksum calc_hash;
* sha256( data, length, &calc_hash );
* assert( calc_hash == hash, "invalid hash" );
* eos_assert( calc_hash == hash, "invalid hash" );
*
* This method is optimized to a NO-OP when in fast evaluation mode
*/
void assert_sha256( char* data, uint32_t length, const checksum* hash );
void eos_assert_sha256( char* data, uint32_t length, const checksum* hash );
/**
* Calculates sha256( data,length) and stores result in memory pointed to by hash
*/
void sha256( char* data, uint32_t length, checksum* hash );
}
\ No newline at end of file
}
......@@ -30,7 +30,7 @@ class datastream {
* @param s the number of bytes to read
*/
inline bool read( char* d, size_t s ) {
assert( size_t(_end - _pos) >= (size_t)s, "read" );
eos_assert( size_t(_end - _pos) >= (size_t)s, "read" );
memcpy( d, _pos, s );
_pos += s;
return true;
......@@ -43,7 +43,7 @@ class datastream {
* @param s The number of bytes to write
*/
inline bool write( const char* d, size_t s ) {
assert( _end - _pos >= (int32_t)s, "write" );
eos_assert( _end - _pos >= (int32_t)s, "write" );
memcpy( _pos, d, s );
_pos += s;
return true;
......@@ -55,7 +55,7 @@ class datastream {
* @param c byte to write
*/
inline bool put(char c) {
assert( _pos < _end, "put" );
eos_assert( _pos < _end, "put" );
*_pos = c;
++_pos;
return true;
......@@ -69,7 +69,7 @@ class datastream {
inline bool get( unsigned char& c ) { return get( *(char*)&c ); }
inline bool get( char& c )
{
assert( _pos < _end, "get" );
eos_assert( _pos < _end, "get" );
c = *_pos;
++_pos;
return true;
......@@ -380,4 +380,4 @@ inline datastream<Stream>& operator>>(datastream<Stream>& ds, uint8_t& d) {
return ds;
}
}
\ No newline at end of file
}
......@@ -388,7 +388,7 @@ struct table {
* @return true if successful store.
*/
static bool store( const Record& r, uint64_t s = scope ) {
assert( impl::store( s, table_n, &r, sizeof(r) ), "error storing record" );
eos_assert( impl::store( s, table_n, &r, sizeof(r) ), "error storing record" );
return true;
}
......@@ -401,7 +401,7 @@ struct table {
* @return true if successful update.
*/
static bool update( const Record& r, uint64_t s = scope ) {
assert( impl::update( s, table_n, &r, sizeof(r) ), "error updating record" );
eos_assert( impl::update( s, table_n, &r, sizeof(r) ), "error updating record" );
return true;
}
......
......@@ -44,7 +44,7 @@ namespace eosio {
template<typename DataStream>
friend DataStream& operator >> ( DataStream& ds, transfer& t ){
ds >> t.from >> t.to >> t.quantity;
assert( t.quantity.symbol== token_type::symbol, "unexpected asset type" );
eos_assert( t.quantity.symbol== token_type::symbol, "unexpected asset type" );
return ds;
}
};
......@@ -223,7 +223,7 @@ class relay_contract {
save_and_send( trans.from, state, output, args.min_return );
}
else {
assert( false, "invalid to currency" );
eos_assert( false, "invalid to currency" );
}
}
......@@ -259,7 +259,7 @@ class relay_contract {
template<typename CurrencyType>
static void start_convert( const CurrencyType::transfer& trans ) {
auto args = unpack<relay_args>( trans.memo );
assert( args.to_currency_type != trans.quantity.token_type(), "cannot convert to self" );
eos_assert( args.to_currency_type != trans.quantity.token_type(), "cannot convert to self" );
auto state = read_relay_state();
on_convert( trans, args, state );
......@@ -289,14 +289,14 @@ class relay_contract {
if( trans.to == RelayAccount ) {
start_convert( trans );
} else {
assert( trans.from == RelayAccount,
eos_assert( trans.from == RelayAccount,
"received unexpected notification of transfer" );
}
}
static void apply( account_name code, action_name action ) {
if( !dispatch<Currency, transfer_memo, issue>( code, action ) )
assert( false, "received unexpected action" );
eos_assert( false, "received unexpected action" );
}
};
......
......@@ -35,4 +35,4 @@ Welcome to the EOS.IO Documentation
- @ref transactionapi - Define API for sending transactions and inline messages
- @ref types - Specifies typedefs and aliases
\ No newline at end of file
......@@ -102,7 +102,7 @@ namespace eosio {
}
explicit operator uint64_t()const {
assert( !(value >> 64), "cast to 64 bit loss of precision" );
eos_assert( !(value >> 64), "cast to 64 bit loss of precision" );
return uint64_t(value);
}
......
......@@ -215,7 +215,7 @@ namespace eosio {
template<typename Stream>
void unpack( Stream& s, fixed_string32& v) {
unsigned_int size; eosio::raw::unpack( s, size );
assert(size.value <= 32, "unpack fixed_string32");
eos_assert(size.value <= 32, "unpack fixed_string32");
s.read( (char *)v.str, size );
v.len = size;
}
......@@ -241,7 +241,7 @@ namespace eosio {
template<typename Stream>
void unpack( Stream& s, fixed_string16& v) {
unsigned_int size; eosio::raw::unpack( s, size );
assert(size.value <= 16, "unpack fixed_string16");
eos_assert(size.value <= 16, "unpack fixed_string16");
s.read( (char *)v.str, size );
v.len = size;
}
......@@ -286,7 +286,7 @@ namespace eosio {
unsigned_int packed_count;
eosio::raw::unpack( s, packed_count );
count = packed_count.value;
assert(count <= max_count, "array too large to read");
eos_assert(count <= max_count, "array too large to read");
for (size_t idx = 0; idx < count; idx++) {
eosio::raw::unpack( s, varr[idx] );
......@@ -306,7 +306,7 @@ namespace eosio {
unsigned_int packed_len;
eosio::raw::unpack( s, packed_len );
len = packed_len.value;
assert(len <= max_len, "raw string too large to read");
eos_assert(len <= max_len, "raw string too large to read");
if( len )
s.read( str, len );
}
......@@ -321,7 +321,7 @@ namespace eosio {
{
uint8_t b;
eosio::raw::unpack( s, b );
assert( (b & ~1) == 0, "unpack bool" );
eos_assert( (b & ~1) == 0, "unpack bool" );
v=(b!=0);
}
......
......@@ -27,7 +27,7 @@ namespace eosio {
char temp[1024+8];
*reinterpret_cast<uint64_t *>(temp) = SingletonName;
auto read = load_i64( scope, Code, singleton_table_name, temp, sizeof(temp) );
assert( read > 0, "singleton does not exist" );
eos_assert( read > 0, "singleton does not exist" );
datastream<const char*> ds(temp + sizeof(SingletonName), read);
T result;
......@@ -56,7 +56,7 @@ namespace eosio {
auto size = raw::pack_size( value );
char buf[size+ sizeof(SingletonName)];
assert( sizeof(buf) <= 1024 + 8, "singleton too big to store" );
eos_assert( sizeof(buf) <= 1024 + 8, "singleton too big to store" );
datastream<char*> ds( buf, size + sizeof(SingletonName) );
ds << SingletonName;
......
......@@ -198,12 +198,12 @@ namespace eosio {
* @return substring of the current string
*/
string substr(size_t offset, size_t substr_size, bool copy) {
assert((offset < size) && (offset + substr_size < size), "out of bound");
eos_assert((offset < size) && (offset + substr_size < size), "out of bound");
return string(data + offset, substr_size, copy);
}
char operator [] (const size_t index) {
assert(index < size, "index out of bound");
eos_assert(index < size, "index out of bound");
return *(data + index);
}
......@@ -238,7 +238,7 @@ namespace eosio {
}
string& operator += (const string& str){
assert((size + str.size > size) && (size + str.size > str.size), "overflow");
eos_assert((size + str.size > size) && (size + str.size > str.size), "overflow");
char* new_data;
size_t new_size;
......
......@@ -29,7 +29,7 @@ extern "C" {
* @param cstr - a null terminated action to explain the reason for failure
*/
void assert( uint32_t test, const char* cstr );
void eos_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)
......
......@@ -41,7 +41,7 @@ namespace eosio {
operator asset()const { return asset( quantity, Symbol ); }
token( const asset& a ):quantity(a.amount) {
assert( a.symbol == Symbol, "attempt to construct token from asset with different symbol" );
eos_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 ) {
assert( quantity >= a.quantity, "integer underflow subtracting token balance" );
eos_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 ) {
assert( quantity + a.quantity >= a.quantity, "integer overflow adding token balance" );
eos_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 ) {
assert( base >= BaseToken(1ul), "invalid price" );
assert( quote >= QuoteToken(1ul), "invalid price" );
eos_assert( base >= BaseToken(1ul), "invalid price" );
eos_assert( quote >= QuoteToken(1ul), "invalid price" );
base_per_quote = base.quantity;
base_per_quote *= precision;
......
......@@ -85,4 +85,4 @@ namespace eosio {
} // namespace eos
EOSLIB_REFLECT( eosio::transaction, (expiration)(region)(ref_block_num)(ref_block_id) )
EOSLIB_REFLECT_DERIVED( eosio::deferred_transaction, (eosio::transaction), (sender_id)(sender)(delay_until))
\ No newline at end of file
EOSLIB_REFLECT_DERIVED( eosio::deferred_transaction, (eosio::transaction), (sender_id)(sender)(delay_until))
......@@ -126,4 +126,4 @@ struct signed_int {
}
};
/// @}
\ No newline at end of file
/// @}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册