Fix #362 by replacing non-deterministic hashed indexes with ordered indexes Remove HARDFORK check for witness ordering because this #362 will require a test net reset to effeciently implment. Changed the order in wich process_fees iterates accounts to be "by_name" rather than "by_id" so that we retain the ability to switch back to hashed indexes in the future. This change was overly pestimistic and assumes all indexes may be traversed as part of consensus. We want to reserve the ability to change some of the indices back to hashed indicies in the future after a through audit reveals that they are never iterated over in order.
52 lines
1.6 KiB
C++
52 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <graphene/chain/vesting_balance_object.hpp>
|
|
|
|
namespace graphene { namespace chain {
|
|
|
|
class balance_object : public abstract_object<balance_object>
|
|
{
|
|
public:
|
|
static const uint8_t space_id = protocol_ids;
|
|
static const uint8_t type_id = balance_object_type;
|
|
|
|
bool is_vesting_balance()const
|
|
{ return vesting_policy.valid(); }
|
|
asset available(fc::time_point_sec now)const
|
|
{
|
|
return is_vesting_balance()? vesting_policy->get_allowed_withdraw({balance, now, {}})
|
|
: balance;
|
|
}
|
|
|
|
address owner;
|
|
asset balance;
|
|
optional<linear_vesting_policy> vesting_policy;
|
|
time_point_sec last_claim_date;
|
|
asset_id_type asset_type()const { return balance.asset_id; }
|
|
};
|
|
|
|
struct by_owner;
|
|
|
|
/**
|
|
* @ingroup object_index
|
|
*/
|
|
using balance_multi_index_type = multi_index_container<
|
|
balance_object,
|
|
indexed_by<
|
|
ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
|
|
ordered_non_unique< tag<by_owner>, composite_key<
|
|
balance_object,
|
|
member<balance_object, address, &balance_object::owner>,
|
|
const_mem_fun<balance_object, asset_id_type, &balance_object::asset_type>
|
|
> >
|
|
>
|
|
>;
|
|
|
|
/**
|
|
* @ingroup object_index
|
|
*/
|
|
using balance_index = generic_index<balance_object, balance_multi_index_type>;
|
|
} }
|
|
|
|
FC_REFLECT_DERIVED( graphene::chain::balance_object, (graphene::db::object),
|
|
(owner)(balance)(vesting_policy)(last_claim_date) )
|