rename object, add update operation skeleton
This commit is contained in:
parent
52e9c2a5a6
commit
ba77a33711
14 changed files with 75 additions and 27 deletions
|
|
@ -432,10 +432,10 @@ namespace graphene { namespace app {
|
||||||
} case balance_object_type:{
|
} case balance_object_type:{
|
||||||
/** these are free from any accounts */
|
/** these are free from any accounts */
|
||||||
break;
|
break;
|
||||||
} case son_member_object_type:{
|
} case son_object_type:{
|
||||||
const auto& son_object = dynamic_cast<const son_member_object*>(obj);
|
const auto& aobj = dynamic_cast<const son_object*>(obj);
|
||||||
assert( son_object != nullptr );
|
assert( aobj != nullptr );
|
||||||
accounts.insert( son_object->son_member_account );
|
accounts.insert( aobj->son_member_account );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case sport_object_type:
|
case sport_object_type:
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,7 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
|
||||||
map<string, committee_member_id_type> lookup_committee_member_accounts(const string& lower_bound_name, uint32_t limit)const;
|
map<string, committee_member_id_type> lookup_committee_member_accounts(const string& lower_bound_name, uint32_t limit)const;
|
||||||
|
|
||||||
// SON members
|
// SON members
|
||||||
fc::optional<son_member_object> get_son_member_by_account(account_id_type account)const;
|
fc::optional<son_object> get_son_member_by_account(account_id_type account)const;
|
||||||
|
|
||||||
// Votes
|
// Votes
|
||||||
vector<variant> lookup_vote_ids( const vector<vote_id_type>& votes )const;
|
vector<variant> lookup_vote_ids( const vector<vote_id_type>& votes )const;
|
||||||
|
|
@ -1586,12 +1586,12 @@ map<string, committee_member_id_type> database_api_impl::lookup_committee_member
|
||||||
// //
|
// //
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
fc::optional<son_member_object> database_api::get_son_member_by_account(account_id_type account)const
|
fc::optional<son_object> database_api::get_son_member_by_account(account_id_type account)const
|
||||||
{
|
{
|
||||||
return my->get_son_member_by_account( account );
|
return my->get_son_member_by_account( account );
|
||||||
}
|
}
|
||||||
|
|
||||||
fc::optional<son_member_object> database_api_impl::get_son_member_by_account(account_id_type account) const
|
fc::optional<son_object> database_api_impl::get_son_member_by_account(account_id_type account) const
|
||||||
{
|
{
|
||||||
const auto& idx = _db.get_index_type<son_member_index>().indices().get<by_account>();
|
const auto& idx = _db.get_index_type<son_member_index>().indices().get<by_account>();
|
||||||
auto itr = idx.find(account);
|
auto itr = idx.find(account);
|
||||||
|
|
|
||||||
|
|
@ -283,6 +283,9 @@ struct get_impacted_account_visitor
|
||||||
}
|
}
|
||||||
void operator()( const affiliate_referral_payout_operation& op ) { }
|
void operator()( const affiliate_referral_payout_operation& op ) { }
|
||||||
void operator()( const son_create_operation& op ){
|
void operator()( const son_create_operation& op ){
|
||||||
|
_impacted.insert( op.owner_account );
|
||||||
|
}
|
||||||
|
void operator()( const son_update_operation& op ){
|
||||||
_impacted.insert( op.owner_account );
|
_impacted.insert( op.owner_account );
|
||||||
}
|
}
|
||||||
void operator()( const son_delete_operation& op ){
|
void operator()( const son_delete_operation& op ){
|
||||||
|
|
|
||||||
|
|
@ -556,7 +556,7 @@ class database_api
|
||||||
* @param account The ID of the account whose son_member should be retrieved
|
* @param account The ID of the account whose son_member should be retrieved
|
||||||
* @return The son_member object, or null if the account does not have a son_member
|
* @return The son_member object, or null if the account does not have a son_member
|
||||||
*/
|
*/
|
||||||
fc::optional<son_member_object> get_son_member_by_account(account_id_type account)const;
|
fc::optional<son_object> get_son_member_by_account(account_id_type account)const;
|
||||||
|
|
||||||
|
|
||||||
/// WORKERS
|
/// WORKERS
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,9 @@ struct get_impacted_account_visitor
|
||||||
void operator()( const son_create_operation& op ) {
|
void operator()( const son_create_operation& op ) {
|
||||||
_impacted.insert( op.owner_account );
|
_impacted.insert( op.owner_account );
|
||||||
}
|
}
|
||||||
|
void operator()( const son_update_operation& op ) {
|
||||||
|
_impacted.insert( op.owner_account );
|
||||||
|
}
|
||||||
void operator()( const son_delete_operation& op ) {
|
void operator()( const son_delete_operation& op ) {
|
||||||
_impacted.insert( op.owner_account );
|
_impacted.insert( op.owner_account );
|
||||||
}
|
}
|
||||||
|
|
@ -363,10 +366,10 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
|
||||||
} case balance_object_type:{
|
} case balance_object_type:{
|
||||||
/** these are free from any accounts */
|
/** these are free from any accounts */
|
||||||
break;
|
break;
|
||||||
} case son_member_object_type:{
|
} case son_object_type:{
|
||||||
const auto& son_object = dynamic_cast<const son_member_object*>(obj);
|
const auto& aobj = dynamic_cast<const son_object*>(obj);
|
||||||
assert( son_object != nullptr );
|
assert( aobj != nullptr );
|
||||||
accounts.insert( son_object->son_member_account );
|
accounts.insert( aobj->son_member_account );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ namespace graphene { namespace chain {
|
||||||
flat_set<witness_id_type> active_witnesses; // updated once per maintenance interval
|
flat_set<witness_id_type> active_witnesses; // updated once per maintenance interval
|
||||||
// n.b. witness scheduling is done by witness_schedule object
|
// n.b. witness scheduling is done by witness_schedule object
|
||||||
|
|
||||||
flat_set<son_member_id_type> active_son_members; // updated once per maintenance interval
|
flat_set<son_id_type> active_son_members; // updated once per maintenance interval
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ namespace graphene { namespace chain {
|
||||||
affiliate_payout_operation, // VIRTUAL
|
affiliate_payout_operation, // VIRTUAL
|
||||||
affiliate_referral_payout_operation, // VIRTUAL
|
affiliate_referral_payout_operation, // VIRTUAL
|
||||||
son_create_operation,
|
son_create_operation,
|
||||||
|
son_update_operation,
|
||||||
son_delete_operation
|
son_delete_operation
|
||||||
> operation;
|
> operation;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,19 @@ namespace graphene { namespace chain {
|
||||||
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
|
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct son_update_operation : public base_operation
|
||||||
|
{
|
||||||
|
struct fee_parameters_type { uint64_t fee = 0; };
|
||||||
|
|
||||||
|
asset fee;
|
||||||
|
son_id_type son_id;
|
||||||
|
account_id_type owner_account;
|
||||||
|
std::string new_url;
|
||||||
|
|
||||||
|
account_id_type fee_payer()const { return owner_account; }
|
||||||
|
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
|
||||||
|
};
|
||||||
|
|
||||||
struct son_delete_operation : public base_operation
|
struct son_delete_operation : public base_operation
|
||||||
{
|
{
|
||||||
struct fee_parameters_type { uint64_t fee = 0; };
|
struct fee_parameters_type { uint64_t fee = 0; };
|
||||||
|
|
@ -31,5 +44,8 @@ namespace graphene { namespace chain {
|
||||||
FC_REFLECT( graphene::chain::son_create_operation::fee_parameters_type, (fee) )
|
FC_REFLECT( graphene::chain::son_create_operation::fee_parameters_type, (fee) )
|
||||||
FC_REFLECT( graphene::chain::son_create_operation, (fee)(owner_account)(url) )
|
FC_REFLECT( graphene::chain::son_create_operation, (fee)(owner_account)(url) )
|
||||||
|
|
||||||
|
FC_REFLECT( graphene::chain::son_update_operation::fee_parameters_type, (fee) )
|
||||||
|
FC_REFLECT( graphene::chain::son_update_operation, (fee)(son_id)(owner_account)(new_url) )
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::son_delete_operation::fee_parameters_type, (fee) )
|
FC_REFLECT( graphene::chain::son_delete_operation::fee_parameters_type, (fee) )
|
||||||
FC_REFLECT( graphene::chain::son_delete_operation, (fee)(owner_account) )
|
FC_REFLECT( graphene::chain::son_delete_operation, (fee)(owner_account) )
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ namespace graphene { namespace chain {
|
||||||
betting_market_group_object_type,
|
betting_market_group_object_type,
|
||||||
betting_market_object_type,
|
betting_market_object_type,
|
||||||
bet_object_type,
|
bet_object_type,
|
||||||
son_member_object_type,
|
son_object_type,
|
||||||
OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types
|
OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -203,7 +203,7 @@ namespace graphene { namespace chain {
|
||||||
class betting_market_group_object;
|
class betting_market_group_object;
|
||||||
class betting_market_object;
|
class betting_market_object;
|
||||||
class bet_object;
|
class bet_object;
|
||||||
class son_member_object;
|
class son_object;
|
||||||
|
|
||||||
typedef object_id< protocol_ids, account_object_type, account_object> account_id_type;
|
typedef object_id< protocol_ids, account_object_type, account_object> account_id_type;
|
||||||
typedef object_id< protocol_ids, asset_object_type, asset_object> asset_id_type;
|
typedef object_id< protocol_ids, asset_object_type, asset_object> asset_id_type;
|
||||||
|
|
@ -230,7 +230,7 @@ namespace graphene { namespace chain {
|
||||||
typedef object_id< protocol_ids, betting_market_group_object_type, betting_market_group_object> betting_market_group_id_type;
|
typedef object_id< protocol_ids, betting_market_group_object_type, betting_market_group_object> betting_market_group_id_type;
|
||||||
typedef object_id< protocol_ids, betting_market_object_type, betting_market_object> betting_market_id_type;
|
typedef object_id< protocol_ids, betting_market_object_type, betting_market_object> betting_market_id_type;
|
||||||
typedef object_id< protocol_ids, bet_object_type, bet_object> bet_id_type;
|
typedef object_id< protocol_ids, bet_object_type, bet_object> bet_id_type;
|
||||||
typedef object_id< protocol_ids, son_member_object_type, son_member_object> son_member_id_type;
|
typedef object_id< protocol_ids, son_object_type, son_object> son_id_type;
|
||||||
|
|
||||||
// implementation types
|
// implementation types
|
||||||
class global_property_object;
|
class global_property_object;
|
||||||
|
|
@ -405,7 +405,7 @@ FC_REFLECT_ENUM( graphene::chain::object_type,
|
||||||
(betting_market_group_object_type)
|
(betting_market_group_object_type)
|
||||||
(betting_market_object_type)
|
(betting_market_object_type)
|
||||||
(bet_object_type)
|
(bet_object_type)
|
||||||
(son_member_object_type)
|
(son_object_type)
|
||||||
(OBJECT_TYPE_COUNT)
|
(OBJECT_TYPE_COUNT)
|
||||||
)
|
)
|
||||||
FC_REFLECT_ENUM( graphene::chain::impl_object_type,
|
FC_REFLECT_ENUM( graphene::chain::impl_object_type,
|
||||||
|
|
@ -473,6 +473,8 @@ FC_REFLECT_TYPENAME( graphene::chain::fba_accumulator_id_type )
|
||||||
FC_REFLECT_TYPENAME( graphene::chain::betting_market_position_id_type )
|
FC_REFLECT_TYPENAME( graphene::chain::betting_market_position_id_type )
|
||||||
FC_REFLECT_TYPENAME( graphene::chain::global_betting_statistics_id_type )
|
FC_REFLECT_TYPENAME( graphene::chain::global_betting_statistics_id_type )
|
||||||
FC_REFLECT_TYPENAME( graphene::chain::tournament_details_id_type )
|
FC_REFLECT_TYPENAME( graphene::chain::tournament_details_id_type )
|
||||||
|
FC_REFLECT_TYPENAME( graphene::chain::son_id_type )
|
||||||
|
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::void_t, )
|
FC_REFLECT( graphene::chain::void_t, )
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,15 @@ public:
|
||||||
object_id_type do_apply(const son_create_operation& o);
|
object_id_type do_apply(const son_create_operation& o);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class update_son_evaluator : public evaluator<update_son_evaluator>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef son_update_operation operation_type;
|
||||||
|
|
||||||
|
void_result do_evaluate(const son_update_operation& o);
|
||||||
|
object_id_type do_apply(const son_update_operation& o);
|
||||||
|
};
|
||||||
|
|
||||||
class delete_son_evaluator : public evaluator<delete_son_evaluator>
|
class delete_son_evaluator : public evaluator<delete_son_evaluator>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,15 @@ namespace graphene { namespace chain {
|
||||||
using namespace graphene::db;
|
using namespace graphene::db;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @class son_member_object
|
* @class son_object
|
||||||
* @brief tracks information about a son_member account.
|
* @brief tracks information about a son_member account.
|
||||||
* @ingroup object
|
* @ingroup object
|
||||||
*/
|
*/
|
||||||
class son_member_object : public abstract_object<son_member_object>
|
class son_object : public abstract_object<son_object>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uint8_t space_id = protocol_ids;
|
static const uint8_t space_id = protocol_ids;
|
||||||
static const uint8_t type_id = son_member_object_type;
|
static const uint8_t type_id = son_object_type;
|
||||||
|
|
||||||
account_id_type son_member_account;
|
account_id_type son_member_account;
|
||||||
vote_id_type vote_id;
|
vote_id_type vote_id;
|
||||||
|
|
@ -26,21 +26,21 @@ namespace graphene { namespace chain {
|
||||||
struct by_account;
|
struct by_account;
|
||||||
struct by_vote_id;
|
struct by_vote_id;
|
||||||
using son_member_multi_index_type = multi_index_container<
|
using son_member_multi_index_type = multi_index_container<
|
||||||
son_member_object,
|
son_object,
|
||||||
indexed_by<
|
indexed_by<
|
||||||
ordered_unique< tag<by_id>,
|
ordered_unique< tag<by_id>,
|
||||||
member<object, object_id_type, &object::id>
|
member<object, object_id_type, &object::id>
|
||||||
>,
|
>,
|
||||||
ordered_unique< tag<by_account>,
|
ordered_unique< tag<by_account>,
|
||||||
member<son_member_object, account_id_type, &son_member_object::son_member_account>
|
member<son_object, account_id_type, &son_object::son_member_account>
|
||||||
>,
|
>,
|
||||||
ordered_unique< tag<by_vote_id>,
|
ordered_unique< tag<by_vote_id>,
|
||||||
member<son_member_object, vote_id_type, &son_member_object::vote_id>
|
member<son_object, vote_id_type, &son_object::vote_id>
|
||||||
>
|
>
|
||||||
>
|
>
|
||||||
>;
|
>;
|
||||||
using son_member_index = generic_index<son_member_object, son_member_multi_index_type>;
|
using son_member_index = generic_index<son_object, son_member_multi_index_type>;
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::son_member_object, (graphene::db::object),
|
FC_REFLECT_DERIVED( graphene::chain::son_object, (graphene::db::object),
|
||||||
(son_member_account)(vote_id)(total_votes)(url) )
|
(son_member_account)(vote_id)(total_votes)(url) )
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ object_id_type create_son_evaluator::do_apply(const son_create_operation& op)
|
||||||
vote_id = get_next_vote_id(p, vote_id_type::son);
|
vote_id = get_next_vote_id(p, vote_id_type::son);
|
||||||
});
|
});
|
||||||
|
|
||||||
const auto& new_son_object = db().create<son_member_object>( [&]( son_member_object& obj ){
|
const auto& new_son_object = db().create<son_object>( [&]( son_object& obj ){
|
||||||
obj.son_member_account = op.owner_account;
|
obj.son_member_account = op.owner_account;
|
||||||
obj.vote_id = vote_id;
|
obj.vote_id = vote_id;
|
||||||
obj.url = op.url;
|
obj.url = op.url;
|
||||||
|
|
@ -26,6 +26,19 @@ object_id_type create_son_evaluator::do_apply(const son_create_operation& op)
|
||||||
return new_son_object.id;
|
return new_son_object.id;
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
|
void_result update_son_evaluator::do_evaluate(const son_update_operation& op)
|
||||||
|
{ try{
|
||||||
|
|
||||||
|
return void_result();
|
||||||
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
|
object_id_type update_son_evaluator::do_apply(const son_update_operation& op)
|
||||||
|
{ try {
|
||||||
|
|
||||||
|
|
||||||
|
return son_id_type(0);
|
||||||
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
void_result delete_son_evaluator::do_evaluate(const son_delete_operation& op)
|
void_result delete_son_evaluator::do_evaluate(const son_delete_operation& op)
|
||||||
{ try {
|
{ try {
|
||||||
database& d = db();
|
database& d = db();
|
||||||
|
|
|
||||||
|
|
@ -2031,7 +2031,7 @@ public:
|
||||||
{ try {
|
{ try {
|
||||||
account_object voting_account_object = get_account(voting_account);
|
account_object voting_account_object = get_account(voting_account);
|
||||||
account_id_type son_member_owner_account_id = get_account_id(son_member);
|
account_id_type son_member_owner_account_id = get_account_id(son_member);
|
||||||
fc::optional<son_member_object> son_member_obj = _remote_db->get_son_member_by_account(son_member_owner_account_id);
|
fc::optional<son_object> son_member_obj = _remote_db->get_son_member_by_account(son_member_owner_account_id);
|
||||||
if (!son_member_obj)
|
if (!son_member_obj)
|
||||||
FC_THROW("Account ${son_member} is not registered as a son_member", ("son_member", son_member));
|
FC_THROW("Account ${son_member} is not registered as a son_member", ("son_member", son_member));
|
||||||
if (approve)
|
if (approve)
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
#include <graphene/chain/tournament_object.hpp>
|
#include <graphene/chain/tournament_object.hpp>
|
||||||
#include <graphene/chain/match_object.hpp>
|
#include <graphene/chain/match_object.hpp>
|
||||||
#include <graphene/chain/game_object.hpp>
|
#include <graphene/chain/game_object.hpp>
|
||||||
|
#include <graphene/chain/son_object.hpp>
|
||||||
|
|
||||||
#include <fc/smart_ref_impl.hpp>
|
#include <fc/smart_ref_impl.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue