Switch dividend payout virtual op from using a flat_set to vector
to allow payouts in multiple assets in the same operation
This commit is contained in:
parent
ed9cdd96ec
commit
123fc3915f
2 changed files with 5 additions and 7 deletions
|
|
@ -1088,7 +1088,6 @@ void process_dividend_assets(database& db)
|
||||||
{
|
{
|
||||||
dlog("Dividend payout time has arrived for asset ${holder_asset}",
|
dlog("Dividend payout time has arrived for asset ${holder_asset}",
|
||||||
("holder_asset", dividend_holder_asset_obj.symbol));
|
("holder_asset", dividend_holder_asset_obj.symbol));
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
// dump balances before the payouts for debugging
|
// dump balances before the payouts for debugging
|
||||||
const auto& balance_idx = db.get_index_type<account_balance_index>().indices().get<by_account_asset>();
|
const auto& balance_idx = db.get_index_type<account_balance_index>().indices().get<by_account_asset>();
|
||||||
|
|
@ -1108,7 +1107,7 @@ void process_dividend_assets(database& db)
|
||||||
// the pending_payouts_range is all payouts for this dividend asset, sorted by the holder's account
|
// the pending_payouts_range is all payouts for this dividend asset, sorted by the holder's account
|
||||||
// we iterate in this order so we can build up a list of payouts for each account to put in the
|
// we iterate in this order so we can build up a list of payouts for each account to put in the
|
||||||
// virtual op
|
// virtual op
|
||||||
flat_set<asset> payouts_for_this_holder;
|
vector<asset> payouts_for_this_holder;
|
||||||
fc::optional<account_id_type> last_holder_account_id;
|
fc::optional<account_id_type> last_holder_account_id;
|
||||||
|
|
||||||
// cache the assets the distribution account is approved to send, we will be asking
|
// cache the assets the distribution account is approved to send, we will be asking
|
||||||
|
|
@ -1124,7 +1123,6 @@ void process_dividend_assets(database& db)
|
||||||
return is_approved;
|
return is_approved;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto pending_balance_object_iter = pending_payouts_range.first; pending_balance_object_iter != pending_payouts_range.second; )
|
|
||||||
{
|
{
|
||||||
const pending_dividend_payout_balance_for_holder_object& pending_balance_object = *pending_balance_object_iter;
|
const pending_dividend_payout_balance_for_holder_object& pending_balance_object = *pending_balance_object_iter;
|
||||||
|
|
||||||
|
|
@ -1151,8 +1149,8 @@ void process_dividend_assets(database& db)
|
||||||
db.adjust_balance(pending_balance_object.owner,
|
db.adjust_balance(pending_balance_object.owner,
|
||||||
asset(pending_balance_object.pending_balance,
|
asset(pending_balance_object.pending_balance,
|
||||||
pending_balance_object.dividend_payout_asset_type));
|
pending_balance_object.dividend_payout_asset_type));
|
||||||
payouts_for_this_holder.insert(asset(pending_balance_object.pending_balance,
|
payouts_for_this_holder.push_back(asset(pending_balance_object.pending_balance,
|
||||||
pending_balance_object.dividend_payout_asset_type));
|
pending_balance_object.dividend_payout_asset_type));
|
||||||
last_holder_account_id = pending_balance_object.owner;
|
last_holder_account_id = pending_balance_object.owner;
|
||||||
amounts_paid_out_by_asset[pending_balance_object.dividend_payout_asset_type] += pending_balance_object.pending_balance;
|
amounts_paid_out_by_asset[pending_balance_object.dividend_payout_asset_type] += pending_balance_object.pending_balance;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -291,7 +291,7 @@ namespace graphene { namespace chain {
|
||||||
asset_dividend_distribution_operation() {}
|
asset_dividend_distribution_operation() {}
|
||||||
asset_dividend_distribution_operation(const asset_id_type& dividend_asset_id,
|
asset_dividend_distribution_operation(const asset_id_type& dividend_asset_id,
|
||||||
const account_id_type& account_id,
|
const account_id_type& account_id,
|
||||||
const flat_set<asset>& amounts) :
|
const vector<asset>& amounts) :
|
||||||
dividend_asset_id(dividend_asset_id),
|
dividend_asset_id(dividend_asset_id),
|
||||||
account_id(account_id),
|
account_id(account_id),
|
||||||
amounts(amounts)
|
amounts(amounts)
|
||||||
|
|
@ -323,7 +323,7 @@ namespace graphene { namespace chain {
|
||||||
account_id_type account_id;
|
account_id_type account_id;
|
||||||
|
|
||||||
/// The amounts received
|
/// The amounts received
|
||||||
flat_set<asset> amounts;
|
vector<asset> amounts;
|
||||||
|
|
||||||
extensions_type extensions;
|
extensions_type extensions;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue