提交 895aac08 编写于 作者: K Khaled Al-Hassanieh

Added bill-to-account

上级 84553e02
...@@ -124,7 +124,7 @@ extern "C" { ...@@ -124,7 +124,7 @@ extern "C" {
* @throw if called with an invalid precondition execution will be aborted * @throw if called with an invalid precondition execution will be aborted
* *
*/ */
int32_t store_i64( account_name scope, table_name table, const void* data, uint32_t datalen ); int32_t store_i64( account_name scope, table_name table, account_name bta, const void* data, uint32_t datalen );
/** /**
* @param scope - the account scope that will be read, must exist in the transaction scopes list * @param scope - the account scope that will be read, must exist in the transaction scopes list
...@@ -143,7 +143,7 @@ int32_t store_i64( account_name scope, table_name table, const void* data, uint3 ...@@ -143,7 +143,7 @@ int32_t store_i64( account_name scope, table_name table, const void* data, uint3
* @throw if called with an invalid precondition execution will be aborted * @throw if called with an invalid precondition execution will be aborted
* *
*/ */
int32_t update_i64( account_name scope, table_name table, const void* data, uint32_t datalen ); int32_t update_i64( account_name scope, table_name table, account_name bta, const void* data, uint32_t datalen );
/** /**
* @param scope - the account scope that will be read, must exist in the transaction scopes list * @param scope - the account scope that will be read, must exist in the transaction scopes list
...@@ -229,7 +229,7 @@ int32_t upper_bound_i64( account_name scope, account_name code, table_name table ...@@ -229,7 +229,7 @@ int32_t upper_bound_i64( account_name scope, account_name code, table_name table
* *
* @return 1 if a record was removed, and 0 if no record with key was found * @return 1 if a record was removed, and 0 if no record with key was found
*/ */
int32_t remove_i64( account_name scope, table_name table, void* data ); int32_t remove_i64( account_name scope, table_name table, account_name bta, void* data );
///@} db_i64 ///@} db_i64
...@@ -263,7 +263,7 @@ int32_t remove_i64( account_name scope, table_name table, void* data ); ...@@ -263,7 +263,7 @@ int32_t remove_i64( account_name scope, table_name table, void* data );
* @throw if called with an invalid precondition execution will be aborted * @throw if called with an invalid precondition execution will be aborted
* *
*/ */
int32_t store_str( account_name scope, table_name table, char* key, uint32_t keylen, char* value, uint32_t valuelen ); int32_t store_str( account_name scope, table_name table, account_name bta, char* key, uint32_t keylen, char* value, uint32_t valuelen );
/** /**
* @param scope - the account scope that will be read, must exist in the transaction scopes list * @param scope - the account scope that will be read, must exist in the transaction scopes list
...@@ -285,7 +285,7 @@ int32_t remove_i64( account_name scope, table_name table, void* data ); ...@@ -285,7 +285,7 @@ int32_t remove_i64( account_name scope, table_name table, void* data );
* @throw if called with an invalid precondition execution will be aborted * @throw if called with an invalid precondition execution will be aborted
* *
*/ */
int32_t update_str( account_name scope, table_name table, char* key, uint32_t keylen, char* value, uint32_t valuelen ); int32_t update_str( account_name scope, table_name table, account_name bta, char* key, uint32_t keylen, char* value, uint32_t valuelen );
/** /**
* @param scope - the account scope that will be read, must exist in the transaction scopes list * @param scope - the account scope that will be read, must exist in the transaction scopes list
...@@ -378,7 +378,7 @@ int32_t remove_i64( account_name scope, table_name table, void* data ); ...@@ -378,7 +378,7 @@ int32_t remove_i64( account_name scope, table_name table, void* data );
* *
* @return 1 if a record was removed, and 0 if no record with key was found * @return 1 if a record was removed, and 0 if no record with key was found
*/ */
int32_t remove_str( account_name scope, table_name table, char* key, uint32_t keylen ); int32_t remove_str( account_name scope, table_name table, account_name bta, char* key, uint32_t keylen );
///@} dbstr ///@} dbstr
...@@ -651,7 +651,7 @@ int32_t lower_bound_secondary_i128i128( account_name scope, account_name code, t ...@@ -651,7 +651,7 @@ int32_t lower_bound_secondary_i128i128( account_name scope, account_name code, t
* *
* @return 1 if a record was removed, and 0 if no record with key was found * @return 1 if a record was removed, and 0 if no record with key was found
*/ */
int32_t remove_i128i128( account_name scope, table_name table, const void* data ); int32_t remove_i128i128( account_name scope, table_name table, account_name bta, const void* data );
/** /**
* @param scope - the account scope that will be read, must exist in the transaction scopes list * @param scope - the account scope that will be read, must exist in the transaction scopes list
* @param table - the ID/name of the table within the scope/code context to query * @param table - the ID/name of the table within the scope/code context to query
...@@ -659,7 +659,7 @@ int32_t remove_i128i128( account_name scope, table_name table, const void* data ...@@ -659,7 +659,7 @@ int32_t remove_i128i128( account_name scope, table_name table, const void* data
* @param len - the length of the data * @param len - the length of the data
* @return 1 if a new record was created, 0 if an existing record was updated * @return 1 if a new record was created, 0 if an existing record was updated
*/ */
int32_t store_i128i128( account_name scope, table_name table, const void* data, uint32_t len ); int32_t store_i128i128( account_name scope, table_name table, account_name bta, const void* data, uint32_t len );
/** /**
* @param scope - the account scope that will be read, must exist in the transaction scopes list * @param scope - the account scope that will be read, must exist in the transaction scopes list
...@@ -668,7 +668,7 @@ int32_t store_i128i128( account_name scope, table_name table, const void* data, ...@@ -668,7 +668,7 @@ int32_t store_i128i128( account_name scope, table_name table, const void* data,
* @param len - the length of the data * @param len - the length of the data
* @return 1 if the record was updated, 0 if no record with key was found * @return 1 if the record was updated, 0 if no record with key was found
*/ */
int32_t update_i128i128( account_name scope, table_name table, const void* data, uint32_t len ); int32_t update_i128i128( account_name scope, table_name table, account_name bta, const void* data, uint32_t len );
///@} dbi128i128 ///@} dbi128i128
...@@ -1009,7 +1009,7 @@ int32_t lower_bound_tertiary_i64i64i64( account_name scope, account_name code, t ...@@ -1009,7 +1009,7 @@ int32_t lower_bound_tertiary_i64i64i64( account_name scope, account_name code, t
* *
* @return 1 if a record was removed, and 0 if no record with key was found * @return 1 if a record was removed, and 0 if no record with key was found
*/ */
int32_t remove_i64i64i64( account_name scope, table_name table, const void* data ); int32_t remove_i64i64i64( account_name scope, table_name table, account_name bta, const void* data );
/** /**
* @param scope - the account scope that will be read, must exist in the transaction scopes list * @param scope - the account scope that will be read, must exist in the transaction scopes list
* @param table - the name of table where record is stored * @param table - the name of table where record is stored
...@@ -1017,7 +1017,7 @@ int32_t remove_i64i64i64( account_name scope, table_name table, const void* data ...@@ -1017,7 +1017,7 @@ int32_t remove_i64i64i64( account_name scope, table_name table, const void* data
* @param len - length of the data * @param len - length of the data
* @return 1 if a new record was created, 0 if an existing record was updated * @return 1 if a new record was created, 0 if an existing record was updated
*/ */
int32_t store_i64i64i64( account_name scope, table_name table, const void* data, uint32_t len ); int32_t store_i64i64i64( account_name scope, table_name table, account_name bta, const void* data, uint32_t len );
/** /**
* @param scope - the account scope that will be read, must exist in the transaction scopes list * @param scope - the account scope that will be read, must exist in the transaction scopes list
...@@ -1026,7 +1026,7 @@ int32_t store_i64i64i64( account_name scope, table_name table, const void* data, ...@@ -1026,7 +1026,7 @@ int32_t store_i64i64i64( account_name scope, table_name table, const void* data,
* @param len - length of the data * @param len - length of the data
* @return 1 if the record was updated, 0 if no record with key was found * @return 1 if the record was updated, 0 if no record with key was found
*/ */
int32_t update_i64i64i64( account_name scope, table_name table, const void* data, uint32_t len ); int32_t update_i64i64i64( account_name scope, table_name table, account_name bta, const void* data, uint32_t len );
///@} dbi64i64i64 ///@} dbi64i64i64
} }
...@@ -83,16 +83,16 @@ struct table_impl<sizeof(uint128_t),sizeof(uint128_t)> { ...@@ -83,16 +83,16 @@ struct table_impl<sizeof(uint128_t),sizeof(uint128_t)> {
return lower_bound_secondary_i128i128( scope, code, table_n, data, len ); return lower_bound_secondary_i128i128( scope, code, table_n, data, len );
} }
static int32_t remove( uint64_t scope, uint64_t table_n, const void* data ) { static int32_t remove( uint64_t scope, uint64_t table_n, account_name bta, const void* data ) {
return remove_i128i128( scope, table_n, data ); return remove_i128i128( scope, table_n, bta, data );
} }
static int32_t store( account_name scope, table_name table_n, const void* data, uint32_t len ) { static int32_t store( account_name scope, table_name table_n, account_name bta, const void* data, uint32_t len ) {
return store_i128i128( scope, table_n, data, len ); return store_i128i128( scope, table_n, bta, data, len );
} }
static int32_t update( account_name scope, table_name table_n, const void* data, uint32_t len ) { static int32_t update( account_name scope, table_name table_n, account_name bta, const void* data, uint32_t len ) {
return update_i128i128( scope, table_n, data, len ); return update_i128i128( scope, table_n, bta, data, len );
} }
}; };
...@@ -175,7 +175,7 @@ struct table_impl<sizeof(uint128_t),sizeof(uint128_t)> { ...@@ -175,7 +175,7 @@ struct table_impl<sizeof(uint128_t),sizeof(uint128_t)> {
* @ingroup databaseCpp * @ingroup databaseCpp
* @{ * @{
*/ */
template<uint64_t scope, uint64_t code, uint64_t table_n, typename Record, typename PrimaryType, typename SecondaryType = void> template<uint64_t scope, uint64_t code, uint64_t table_n, uint64_t bta, typename Record, typename PrimaryType, typename SecondaryType = void>
struct table { struct table {
private: private:
typedef table_impl<sizeof( PrimaryType ), sizeof( SecondaryType )> impl; typedef table_impl<sizeof( PrimaryType ), sizeof( SecondaryType )> impl;
...@@ -387,8 +387,8 @@ struct table { ...@@ -387,8 +387,8 @@ struct table {
* *
* @return true if successful store. * @return true if successful store.
*/ */
static bool store( const Record& r, uint64_t s = scope ) { static bool store( const Record& r, uint64_t s = scope, uint64_t b = bta ) {
assert( impl::store( s, table_n, &r, sizeof(r) ), "error storing record" ); assert( impl::store( s, table_n, b, &r, sizeof(r) ), "error storing record" );
return true; return true;
} }
...@@ -400,8 +400,8 @@ struct table { ...@@ -400,8 +400,8 @@ struct table {
* *
* @return true if successful update. * @return true if successful update.
*/ */
static bool update( const Record& r, uint64_t s = scope ) { static bool update( const Record& r, uint64_t s = scope, uint64_t b = bta ) {
assert( impl::update( s, table_n, &r, sizeof(r) ), "error updating record" ); assert( impl::update( s, table_n, b, &r, sizeof(r) ), "error updating record" );
return true; return true;
} }
...@@ -413,8 +413,8 @@ struct table { ...@@ -413,8 +413,8 @@ struct table {
* *
* @return true if successful remove. * @return true if successful remove.
*/ */
static bool remove( const Record& r, uint64_t s = scope ) { static bool remove( const Record& r, uint64_t s = scope, uint64_t b = bta ) {
return impl::remove( s, table_n, &r ) != 0; return impl::remove( s, table_n, b, &r ) != 0;
} }
}; };
/// @} /// @}
...@@ -450,16 +450,16 @@ struct table_impl<sizeof(uint64_t),0> { ...@@ -450,16 +450,16 @@ struct table_impl<sizeof(uint64_t),0> {
return upper_bound_i64(scope, code, table_n, data, len); return upper_bound_i64(scope, code, table_n, data, len);
} }
static int32_t remove( uint64_t scope, uint64_t table_n, const void* data ) { static int32_t remove( uint64_t scope, uint64_t table_n, account_name bta, const void* data ) {
return remove_i64( scope, table_n, (uint64_t*)data); return remove_i64( scope, table_n, bta, (uint64_t*)data);
} }
static int32_t store( account_name scope, table_name table_n, const void* data, uint32_t len ) { static int32_t store( account_name scope, table_name table_n, account_name bta, const void* data, uint32_t len ) {
return store_i64( scope, table_n, data, len ); return store_i64( scope, table_n, bta, data, len );
} }
static int32_t update( account_name scope, table_name table_n, const void* data, uint32_t len ) { static int32_t update( account_name scope, table_name table_n, account_name bta, const void* data, uint32_t len ) {
return update_i64( scope, table_n, data, len ); return update_i64( scope, table_n, bta, data, len );
} }
}; };
...@@ -531,8 +531,8 @@ struct table_impl<sizeof(uint64_t),0> { ...@@ -531,8 +531,8 @@ struct table_impl<sizeof(uint64_t),0> {
* @ingroup databaseCpp * @ingroup databaseCpp
* @{ * @{
*/ */
template<uint64_t scope, uint64_t code, uint64_t table_n, typename Record, typename PrimaryType> template<uint64_t scope, uint64_t code, uint64_t table_n, uint64_t bta, typename Record, typename PrimaryType>
struct table<scope,code,table_n,Record,PrimaryType,void> { struct table<scope,code,table_n,bta,Record,PrimaryType,void> {
private: private:
typedef table_impl<sizeof( PrimaryType ),0> impl; typedef table_impl<sizeof( PrimaryType ),0> impl;
static_assert( sizeof(PrimaryType) <= sizeof(Record), "invalid template parameters" ); static_assert( sizeof(PrimaryType) <= sizeof(Record), "invalid template parameters" );
...@@ -667,8 +667,8 @@ struct table<scope,code,table_n,Record,PrimaryType,void> { ...@@ -667,8 +667,8 @@ struct table<scope,code,table_n,Record,PrimaryType,void> {
* @param s - scope; defaults to scope of the class. * @param s - scope; defaults to scope of the class.
* @return true if store succeeds. * @return true if store succeeds.
*/ */
static bool store( const Record& r, uint64_t s = scope ) { static bool store( const Record& r, uint64_t s = scope, uint64_t b = bta ) {
return impl::store( s, table_n, &r, sizeof(r) ) != 0; return impl::store( s, table_n, b, &r, sizeof(r) ) != 0;
} }
/** /**
...@@ -678,8 +678,8 @@ struct table<scope,code,table_n,Record,PrimaryType,void> { ...@@ -678,8 +678,8 @@ struct table<scope,code,table_n,Record,PrimaryType,void> {
* @param s - scope; defaults to scope of the class. * @param s - scope; defaults to scope of the class.
* @return true if update succeeds. * @return true if update succeeds.
*/ */
static bool update( const Record& r, uint64_t s = scope ) { static bool update( const Record& r, uint64_t s = scope, uint64_t b = bta ) {
return impl::update( s, table_n, &r, sizeof(r) ) != 0; return impl::update( s, table_n, b, &r, sizeof(r) ) != 0;
} }
/** /**
...@@ -689,20 +689,20 @@ struct table<scope,code,table_n,Record,PrimaryType,void> { ...@@ -689,20 +689,20 @@ struct table<scope,code,table_n,Record,PrimaryType,void> {
* @param s - scope; defaults to scope of the class. * @param s - scope; defaults to scope of the class.
* @return true if remove succeeds. * @return true if remove succeeds.
*/ */
static bool remove( const Record& r, uint64_t s = scope ) { static bool remove( const Record& r, uint64_t s = scope, uint64_t b = bta ) {
return impl::remove( s, table_n, &r ) != 0; return impl::remove( s, table_n, b, &r ) != 0;
} }
}; /// @} singleindextable }; /// @} singleindextable
template<> template<>
struct table_impl_obj<char*> { struct table_impl_obj<char*> {
static int32_t store( account_name scope, table_name table_n, char* key, uint32_t keylen, char* data, uint32_t datalen ) { static int32_t store( account_name scope, table_name table_n, account_name bta, char* key, uint32_t keylen, char* data, uint32_t datalen ) {
return store_str( scope, table_n, key, keylen, data, datalen ); return store_str( scope, table_n, bta, key, keylen, data, datalen );
} }
static int32_t update( account_name scope, table_name table_n, char* key, uint32_t keylen, char* data, uint32_t datalen ) { static int32_t update( account_name scope, table_name table_n, account_name bta, char* key, uint32_t keylen, char* data, uint32_t datalen ) {
return update_str( scope, table_n, key, keylen, data, datalen ); return update_str( scope, table_n, bta, key, keylen, data, datalen );
} }
static int32_t front( account_name scope, account_name code, table_name table_n, char* data, uint32_t len ) { static int32_t front( account_name scope, account_name code, table_name table_n, char* data, uint32_t len ) {
...@@ -733,8 +733,8 @@ struct table_impl_obj<char*> { ...@@ -733,8 +733,8 @@ struct table_impl_obj<char*> {
return upper_bound_str( scope, code, table_n, key, keylen, data, datalen ); return upper_bound_str( scope, code, table_n, key, keylen, data, datalen );
} }
static int32_t remove( account_name scope, table_name table_n, char* key, uint32_t keylen ) { static int32_t remove( account_name scope, table_name table_n, account_name bta, char* key, uint32_t keylen ) {
return remove_str( scope, table_n, key, keylen ); return remove_str( scope, table_n, bta, key, keylen );
} }
}; };
...@@ -751,7 +751,7 @@ struct table_impl_obj<char*> { ...@@ -751,7 +751,7 @@ struct table_impl_obj<char*> {
* @{ * @{
*/ */
template<account_name scope, account_name code, table_name table_n, typename PrimaryType> template<account_name scope, account_name code, table_name table_n, account_name bta, typename PrimaryType>
struct var_table { struct var_table {
private: private:
typedef table_impl_obj<PrimaryType> impl; typedef table_impl_obj<PrimaryType> impl;
...@@ -769,7 +769,7 @@ struct var_table { ...@@ -769,7 +769,7 @@ struct var_table {
* @return 1 if a new record was created, 0 if an existing record was updated * @return 1 if a new record was created, 0 if an existing record was updated
*/ */
int32_t store( primary key, uint32_t keylen, char* record, uint32_t len ) { int32_t store( primary key, uint32_t keylen, char* record, uint32_t len ) {
return impl::store( scope, table_n, key, keylen, record, len ); return impl::store( scope, table_n, bta, key, keylen, record, len );
} }
/** /**
...@@ -782,7 +782,7 @@ struct var_table { ...@@ -782,7 +782,7 @@ struct var_table {
* @return 1 if the record was updated, 0 if no record with key was found * @return 1 if the record was updated, 0 if no record with key was found
*/ */
int32_t update( primary key, uint32_t keylen, char* record, uint32_t len ) { int32_t update( primary key, uint32_t keylen, char* record, uint32_t len ) {
return impl::update( scope, table_n, key, keylen, record, len ); return impl::update( scope, table_n, bta, key, keylen, record, len );
} }
/** /**
...@@ -886,7 +886,7 @@ struct var_table { ...@@ -886,7 +886,7 @@ struct var_table {
* @return 1 if a record was removed, and 0 if no record with key was found * @return 1 if a record was removed, and 0 if no record with key was found
*/ */
int32_t remove( primary key, uint32_t keylen ) { int32_t remove( primary key, uint32_t keylen ) {
return impl::remove( scope, table_n, key, keylen ); return impl::remove( scope, table_n, bta, key, keylen );
} }
}; };
......
...@@ -74,8 +74,8 @@ namespace eosio { ...@@ -74,8 +74,8 @@ namespace eosio {
* Each user stores their balance in the singleton table under the * Each user stores their balance in the singleton table under the
* scope of their account name. * scope of their account name.
*/ */
typedef table64<code, accounts_table_name, account> accounts; typedef table64<code, accounts_table_name, code, account> accounts;
typedef table64<code, stats_table_name, currency_stats> stats; typedef table64<code, stats_table_name, code, currency_stats> stats;
static token_type get_balance( account_name owner ) { static token_type get_balance( account_name owner ) {
return accounts::get_or_create( token_type::symbol, owner ).balance; return accounts::get_or_create( token_type::symbol, owner ).balance;
......
...@@ -7,7 +7,7 @@ namespace eosio { ...@@ -7,7 +7,7 @@ namespace eosio {
* @tparam TableName - the name of the table with rows of type T * @tparam TableName - the name of the table with rows of type T
* @tparam T - a struct where the first 8 bytes are used as primary/unique key * @tparam T - a struct where the first 8 bytes are used as primary/unique key
*/ */
template<uint64_t DefaultScope, uint64_t TableName, typename T> template<uint64_t DefaultScope, uint64_t TableName, uint64_t BillToAccount, typename T>
class table64 class table64
{ {
public: public:
...@@ -44,7 +44,7 @@ namespace eosio { ...@@ -44,7 +44,7 @@ namespace eosio {
return result; return result;
} }
static void set( const T& value = T(), scope_name scope = DefaultScope ) { static void set( const T& value = T(), scope_name scope = DefaultScope, uint64_t bta = BillToAccount ) {
auto size = pack_size( value ); auto size = pack_size( value );
char buf[size]; char buf[size];
assert( size <= 1024, "singleton too big to store" ); assert( size <= 1024, "singleton too big to store" );
...@@ -52,7 +52,7 @@ namespace eosio { ...@@ -52,7 +52,7 @@ namespace eosio {
datastream<char*> ds( buf, size ); datastream<char*> ds( buf, size );
ds << value; ds << value;
store_i64( scope, TableName, buf, sizeof(buf) ); store_i64( scope, TableName, bta, buf, sizeof(buf) );
} }
}; };
......
...@@ -22,6 +22,6 @@ namespace proxy { ...@@ -22,6 +22,6 @@ namespace proxy {
uint32_t next_id = 0; uint32_t next_id = 0;
}; };
using configs = eosio::table<N(proxy),N(proxy),N(configs),config,uint64_t>; using configs = eosio::table<N(proxy),N(proxy),N(configs),N(proxy),config,uint64_t>;
} /// namespace proxy } /// namespace proxy
...@@ -21,6 +21,7 @@ namespace eosio { namespace chain { namespace contracts { ...@@ -21,6 +21,7 @@ namespace eosio { namespace chain { namespace contracts {
scope_name scope; scope_name scope;
account_name code; account_name code;
table_name table; table_name table;
account_name bta;
}; };
struct by_scope_code_table; struct by_scope_code_table;
...@@ -35,7 +36,8 @@ namespace eosio { namespace chain { namespace contracts { ...@@ -35,7 +36,8 @@ namespace eosio { namespace chain { namespace contracts {
composite_key< table_id_object, composite_key< table_id_object,
member<table_id_object, scope_name, &table_id_object::scope>, member<table_id_object, scope_name, &table_id_object::scope>,
member<table_id_object, account_name, &table_id_object::code>, member<table_id_object, account_name, &table_id_object::code>,
member<table_id_object, table_name, &table_id_object::table> member<table_id_object, table_name, &table_id_object::table>,
member<table_id_object, account_name, &table_id_object::bta>
> >
> >
> >
...@@ -214,4 +216,4 @@ FC_REFLECT(eosio::chain::contracts::table_id_object, (id)(scope)(code)(table) ) ...@@ -214,4 +216,4 @@ FC_REFLECT(eosio::chain::contracts::table_id_object, (id)(scope)(code)(table) )
FC_REFLECT(eosio::chain::contracts::key_value_object, (id)(t_id)(primary_key)(value) ) FC_REFLECT(eosio::chain::contracts::key_value_object, (id)(t_id)(primary_key)(value) )
FC_REFLECT(eosio::chain::contracts::keystr_value_object, (id)(t_id)(primary_key)(value) ) FC_REFLECT(eosio::chain::contracts::keystr_value_object, (id)(t_id)(primary_key)(value) )
FC_REFLECT(eosio::chain::contracts::key128x128_value_object, (id)(t_id)(primary_key)(secondary_key)(value) ) FC_REFLECT(eosio::chain::contracts::key128x128_value_object, (id)(t_id)(primary_key)(secondary_key)(value) )
FC_REFLECT(eosio::chain::contracts::key64x64x64_value_object, (id)(t_id)(primary_key)(secondary_key)(tertiary_key)(value) ) FC_REFLECT(eosio::chain::contracts::key64x64x64_value_object, (id)(t_id)(primary_key)(secondary_key)(tertiary_key)(value) )
\ No newline at end of file
...@@ -559,18 +559,18 @@ class db_api : public context_aware_api { ...@@ -559,18 +559,18 @@ class db_api : public context_aware_api {
public: public:
using context_aware_api::context_aware_api; using context_aware_api::context_aware_api;
int store(const scope_name& scope, const name& table, array_ptr<const char> data, size_t data_len) { int store(const scope_name& scope, const name& table, const scope_name& bta, array_ptr<const char> data, size_t data_len) {
auto res = call(&apply_context::store_record<ObjectType>, scope, table, data, data_len); auto res = call(&apply_context::store_record<ObjectType>, scope, table, data, data_len);
//ilog("STORE [${scope},${code},${table}] => ${res} :: ${HEX}", ("scope",scope)("code",context.receiver)("table",table)("res",res)("HEX", fc::to_hex(data, data_len))); //ilog("STORE [${scope},${code},${table}] => ${res} :: ${HEX}", ("scope",scope)("code",context.receiver)("table",table)("res",res)("HEX", fc::to_hex(data, data_len)));
return res; return res;
} }
int update(const scope_name& scope, const name& table, array_ptr<const char> data, size_t data_len) { int update(const scope_name& scope, const name& table, const scope_name& bta, array_ptr<const char> data, size_t data_len) {
return call(&apply_context::update_record<ObjectType>, scope, table, data, data_len); return call(&apply_context::update_record<ObjectType>, scope, table, data, data_len);
} }
int remove(const scope_name& scope, const name& table, const KeyArrayType &keys) { int remove(const scope_name& scope, const name& table, const scope_name& bta, const KeyArrayType &keys) {
const auto& t_id = context.find_or_create_table(scope, context.receiver, table); const auto& t_id = context.find_or_create_table(scope, context.receiver, table);
return context.remove_record<ObjectType>(t_id, keys); return context.remove_record<ObjectType>(t_id, keys);
} }
...@@ -777,9 +777,9 @@ REGISTER_INTRINSICS(memory_api, ...@@ -777,9 +777,9 @@ REGISTER_INTRINSICS(memory_api,
#define DB_METHOD_SEQ(SUFFIX) \ #define DB_METHOD_SEQ(SUFFIX) \
(store, int32_t(int64_t, int64_t, int, int), "store_"#SUFFIX )\ (store, int32_t(int64_t, int64_t, int64_t, int, int), "store_"#SUFFIX ) \
(update, int32_t(int64_t, int64_t, int, int), "update_"#SUFFIX )\ (update, int32_t(int64_t, int64_t, int64_t, int, int), "update_"#SUFFIX ) \
(remove, int32_t(int64_t, int64_t, int), "remove_"#SUFFIX ) (remove, int32_t(int64_t, int64_t, int64_t, int), "remove_"#SUFFIX )
#define DB_INDEX_METHOD_SEQ(SUFFIX)\ #define DB_INDEX_METHOD_SEQ(SUFFIX)\
(load, int32_t(int64_t, int64_t, int64_t, int, int), "load_"#SUFFIX )\ (load, int32_t(int64_t, int64_t, int64_t, int, int), "load_"#SUFFIX )\
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册