Ref #1506/#1737: Macro-fy ID type definitions
Define macros to fully de-boilerplate ID type definitions. Externalities: - Rename transaction_object -> transaction_history_object - Rename impl_asset_dynamic_data_type -> impl_asset_dynamic_data_object_type - Rename impl_asset_bitasset_data_type -> impl_asset_bitasset_data_object_type The first is to avoid a naming collision on transaction_id_type, and the other two are to maintain consistency with the naming of the other types.
This commit is contained in:
parent
6074749813
commit
c94e46f451
11 changed files with 135 additions and 244 deletions
|
|
@ -32,7 +32,7 @@
|
||||||
#include <graphene/protocol/fee_schedule.hpp>
|
#include <graphene/protocol/fee_schedule.hpp>
|
||||||
#include <graphene/chain/confidential_object.hpp>
|
#include <graphene/chain/confidential_object.hpp>
|
||||||
#include <graphene/chain/market_object.hpp>
|
#include <graphene/chain/market_object.hpp>
|
||||||
#include <graphene/chain/transaction_object.hpp>
|
#include <graphene/chain/transaction_history_object.hpp>
|
||||||
#include <graphene/chain/withdraw_permission_object.hpp>
|
#include <graphene/chain/withdraw_permission_object.hpp>
|
||||||
#include <graphene/chain/worker_object.hpp>
|
#include <graphene/chain/worker_object.hpp>
|
||||||
#include <graphene/chain/tournament_object.hpp>
|
#include <graphene/chain/tournament_object.hpp>
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,7 @@ add_library( graphene_chain
|
||||||
fba_object.cpp
|
fba_object.cpp
|
||||||
proposal_object.cpp
|
proposal_object.cpp
|
||||||
vesting_balance_object.cpp
|
vesting_balance_object.cpp
|
||||||
|
transaction_history_object.cpp
|
||||||
small_objects.cpp
|
small_objects.cpp
|
||||||
|
|
||||||
block_database.cpp
|
block_database.cpp
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
#include <graphene/chain/operation_history_object.hpp>
|
#include <graphene/chain/operation_history_object.hpp>
|
||||||
|
|
||||||
#include <graphene/chain/proposal_object.hpp>
|
#include <graphene/chain/proposal_object.hpp>
|
||||||
#include <graphene/chain/transaction_object.hpp>
|
#include <graphene/chain/transaction_history_object.hpp>
|
||||||
#include <graphene/chain/witness_object.hpp>
|
#include <graphene/chain/witness_object.hpp>
|
||||||
#include <graphene/chain/exceptions.hpp>
|
#include <graphene/chain/exceptions.hpp>
|
||||||
#include <graphene/chain/evaluator.hpp>
|
#include <graphene/chain/evaluator.hpp>
|
||||||
|
|
@ -816,8 +816,8 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
|
||||||
//Insert transaction into unique transactions database.
|
//Insert transaction into unique transactions database.
|
||||||
if( !(skip & skip_transaction_dupe_check) )
|
if( !(skip & skip_transaction_dupe_check) )
|
||||||
{
|
{
|
||||||
create<transaction_object>([&trx_id,&trx](transaction_object& transaction) {
|
create<transaction_history_object>([&trx](transaction_history_object& transaction) {
|
||||||
transaction.trx_id = trx_id;
|
transaction.trx_id = trx.id();
|
||||||
transaction.trx = trx;
|
transaction.trx = trx;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
#include <graphene/chain/operation_history_object.hpp>
|
#include <graphene/chain/operation_history_object.hpp>
|
||||||
#include <graphene/chain/proposal_object.hpp>
|
#include <graphene/chain/proposal_object.hpp>
|
||||||
#include <graphene/chain/special_authority_object.hpp>
|
#include <graphene/chain/special_authority_object.hpp>
|
||||||
#include <graphene/chain/transaction_object.hpp>
|
#include <graphene/chain/transaction_history_object.hpp>
|
||||||
#include <graphene/chain/vesting_balance_object.hpp>
|
#include <graphene/chain/vesting_balance_object.hpp>
|
||||||
#include <graphene/chain/withdraw_permission_object.hpp>
|
#include <graphene/chain/withdraw_permission_object.hpp>
|
||||||
#include <graphene/chain/witness_object.hpp>
|
#include <graphene/chain/witness_object.hpp>
|
||||||
|
|
@ -132,8 +132,8 @@ const uint8_t operation_history_object::type_id;
|
||||||
const uint8_t proposal_object::space_id;
|
const uint8_t proposal_object::space_id;
|
||||||
const uint8_t proposal_object::type_id;
|
const uint8_t proposal_object::type_id;
|
||||||
|
|
||||||
const uint8_t transaction_object::space_id;
|
const uint8_t transaction_history_object::space_id;
|
||||||
const uint8_t transaction_object::type_id;
|
const uint8_t transaction_history_object::type_id;
|
||||||
|
|
||||||
const uint8_t vesting_balance_object::space_id;
|
const uint8_t vesting_balance_object::space_id;
|
||||||
const uint8_t vesting_balance_object::type_id;
|
const uint8_t vesting_balance_object::type_id;
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
#include <graphene/chain/proposal_object.hpp>
|
#include <graphene/chain/proposal_object.hpp>
|
||||||
#include <graphene/chain/operation_history_object.hpp>
|
#include <graphene/chain/operation_history_object.hpp>
|
||||||
#include <graphene/chain/vesting_balance_object.hpp>
|
#include <graphene/chain/vesting_balance_object.hpp>
|
||||||
#include <graphene/chain/transaction_object.hpp>
|
#include <graphene/chain/transaction_history_object.hpp>
|
||||||
#include <graphene/chain/impacted.hpp>
|
#include <graphene/chain/impacted.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -366,7 +366,6 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
|
||||||
{
|
{
|
||||||
case null_object_type:
|
case null_object_type:
|
||||||
case base_object_type:
|
case base_object_type:
|
||||||
case OBJECT_TYPE_COUNT:
|
|
||||||
return;
|
return;
|
||||||
case account_object_type:{
|
case account_object_type:{
|
||||||
accounts.insert( obj->id );
|
accounts.insert( obj->id );
|
||||||
|
|
@ -445,9 +444,9 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
|
||||||
break;
|
break;
|
||||||
case impl_reserved0_object_type:
|
case impl_reserved0_object_type:
|
||||||
break;
|
break;
|
||||||
case impl_asset_dynamic_data_type:
|
case impl_asset_dynamic_data_object_type:
|
||||||
break;
|
break;
|
||||||
case impl_asset_bitasset_data_type:
|
case impl_asset_bitasset_data_object_type:
|
||||||
break;
|
break;
|
||||||
case impl_account_balance_object_type:{
|
case impl_account_balance_object_type:{
|
||||||
const auto& aobj = dynamic_cast<const account_balance_object*>(obj);
|
const auto& aobj = dynamic_cast<const account_balance_object*>(obj);
|
||||||
|
|
@ -459,9 +458,9 @@ void get_relevant_accounts( const object* obj, flat_set<account_id_type>& accoun
|
||||||
assert( aobj != nullptr );
|
assert( aobj != nullptr );
|
||||||
accounts.insert( aobj->owner );
|
accounts.insert( aobj->owner );
|
||||||
break;
|
break;
|
||||||
} case impl_transaction_object_type:{
|
} case impl_transaction_history_object_type:{
|
||||||
const auto& aobj = dynamic_cast<const transaction_object*>(obj);
|
const auto& aobj = dynamic_cast<const transaction_history_object*>(obj);
|
||||||
assert( aobj != nullptr );
|
FC_ASSERT( aobj != nullptr );
|
||||||
transaction_get_impacted_accounts( aobj->trx, accounts );
|
transaction_get_impacted_accounts( aobj->trx, accounts );
|
||||||
break;
|
break;
|
||||||
} case impl_blinded_balance_object_type:{
|
} case impl_blinded_balance_object_type:{
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
#include <graphene/chain/hardfork.hpp>
|
#include <graphene/chain/hardfork.hpp>
|
||||||
#include <graphene/chain/market_object.hpp>
|
#include <graphene/chain/market_object.hpp>
|
||||||
#include <graphene/chain/proposal_object.hpp>
|
#include <graphene/chain/proposal_object.hpp>
|
||||||
#include <graphene/chain/transaction_object.hpp>
|
#include <graphene/chain/transaction_history_object.hpp>
|
||||||
#include <graphene/chain/withdraw_permission_object.hpp>
|
#include <graphene/chain/withdraw_permission_object.hpp>
|
||||||
#include <graphene/chain/witness_object.hpp>
|
#include <graphene/chain/witness_object.hpp>
|
||||||
#include <graphene/chain/tournament_object.hpp>
|
#include <graphene/chain/tournament_object.hpp>
|
||||||
|
|
@ -153,7 +153,8 @@ void database::clear_expired_transactions()
|
||||||
{ try {
|
{ try {
|
||||||
//Look for expired transactions in the deduplication list, and remove them.
|
//Look for expired transactions in the deduplication list, and remove them.
|
||||||
//Transactions must have expired by at least two forking windows in order to be removed.
|
//Transactions must have expired by at least two forking windows in order to be removed.
|
||||||
auto& transaction_idx = static_cast<transaction_index&>(get_mutable_index(implementation_ids, impl_transaction_object_type));
|
auto& transaction_idx = static_cast<transaction_index&>(get_mutable_index(implementation_ids,
|
||||||
|
impl_transaction_history_object_type));
|
||||||
const auto& dedupe_index = transaction_idx.indices().get<by_expiration>();
|
const auto& dedupe_index = transaction_idx.indices().get<by_expiration>();
|
||||||
while( (!dedupe_index.empty()) && (head_block_time() > dedupe_index.begin()->trx.expiration) )
|
while( (!dedupe_index.empty()) && (head_block_time() > dedupe_index.begin()->trx.expiration) )
|
||||||
transaction_idx.remove(*dedupe_index.begin());
|
transaction_idx.remove(*dedupe_index.begin());
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ namespace graphene { namespace chain {
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uint8_t space_id = implementation_ids;
|
static const uint8_t space_id = implementation_ids;
|
||||||
static const uint8_t type_id = impl_asset_dynamic_data_type;
|
static const uint8_t type_id = impl_asset_dynamic_data_object_type;
|
||||||
|
|
||||||
/// The number of shares currently in existence
|
/// The number of shares currently in existence
|
||||||
share_type current_supply;
|
share_type current_supply;
|
||||||
|
|
@ -193,7 +193,7 @@ namespace graphene { namespace chain {
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uint8_t space_id = implementation_ids;
|
static const uint8_t space_id = implementation_ids;
|
||||||
static const uint8_t type_id = impl_asset_bitasset_data_type;
|
static const uint8_t type_id = impl_asset_bitasset_data_object_type;
|
||||||
|
|
||||||
/// The asset this object belong to
|
/// The asset this object belong to
|
||||||
asset_id_type asset_id;
|
asset_id_type asset_id;
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,14 @@ namespace graphene { namespace chain {
|
||||||
using namespace boost::multi_index;
|
using namespace boost::multi_index;
|
||||||
/**
|
/**
|
||||||
* The purpose of this object is to enable the detection of duplicate transactions. When a transaction is included
|
* The purpose of this object is to enable the detection of duplicate transactions. When a transaction is included
|
||||||
* in a block a transaction_object is added. At the end of block processing all transaction_objects that have
|
* in a block a transaction_history_object is added. At the end of block processing all transaction_history_objects that
|
||||||
* expired can be removed from the index.
|
* have expired can be removed from the index.
|
||||||
*/
|
*/
|
||||||
class transaction_object : public abstract_object<transaction_object>
|
class transaction_history_object : public abstract_object<transaction_history_object>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static const uint8_t space_id = implementation_ids;
|
static const uint8_t space_id = implementation_ids;
|
||||||
static const uint8_t type_id = impl_transaction_object_type;
|
static const uint8_t type_id = impl_transaction_history_object_type;
|
||||||
|
|
||||||
signed_transaction trx;
|
signed_transaction trx;
|
||||||
transaction_id_type trx_id;
|
transaction_id_type trx_id;
|
||||||
|
|
@ -57,19 +57,21 @@ namespace graphene { namespace chain {
|
||||||
struct by_expiration;
|
struct by_expiration;
|
||||||
struct by_trx_id;
|
struct by_trx_id;
|
||||||
typedef multi_index_container<
|
typedef multi_index_container<
|
||||||
transaction_object,
|
transaction_history_object,
|
||||||
indexed_by<
|
indexed_by<
|
||||||
ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
|
ordered_unique< tag<by_id>, member< object, object_id_type, &object::id > >,
|
||||||
hashed_unique< tag<by_trx_id>, BOOST_MULTI_INDEX_MEMBER(transaction_object, transaction_id_type, trx_id), std::hash<transaction_id_type> >,
|
hashed_unique< tag<by_trx_id>, BOOST_MULTI_INDEX_MEMBER(transaction_history_object, transaction_id_type, trx_id),
|
||||||
ordered_non_unique< tag<by_expiration>, const_mem_fun<transaction_object, time_point_sec, &transaction_object::get_expiration > >
|
std::hash<transaction_id_type> >,
|
||||||
|
ordered_non_unique< tag<by_expiration>, const_mem_fun< transaction_history_object, time_point_sec,
|
||||||
|
&transaction_history_object::get_expiration > >
|
||||||
>
|
>
|
||||||
> transaction_multi_index_type;
|
> transaction_multi_index_type;
|
||||||
|
|
||||||
typedef generic_index<transaction_object, transaction_multi_index_type> transaction_index;
|
typedef generic_index<transaction_history_object, transaction_multi_index_type> transaction_index;
|
||||||
} }
|
} }
|
||||||
|
|
||||||
MAP_OBJECT_ID_TO_TYPE(graphene::chain::transaction_object)
|
MAP_OBJECT_ID_TO_TYPE(graphene::chain::transaction_history_object)
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::transaction_object, (graphene::db::object), (trx)(trx_id) )
|
FC_REFLECT_DERIVED( graphene::chain::transaction_history_object, (graphene::db::object), (trx)(trx_id) )
|
||||||
|
|
||||||
GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transaction_object )
|
GRAPHENE_EXTERNAL_SERIALIZATION( extern, graphene::chain::transaction_history_object )
|
||||||
|
|
@ -25,82 +25,31 @@
|
||||||
|
|
||||||
#include <graphene/protocol/types.hpp>
|
#include <graphene/protocol/types.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain { using namespace protocol; } }
|
||||||
|
|
||||||
using namespace graphene::protocol;
|
GRAPHENE_DEFINE_IDS(chain, implementation_ids, impl_,
|
||||||
|
(global_property)
|
||||||
enum impl_object_type {
|
(dynamic_global_property)
|
||||||
impl_global_property_object_type,
|
(reserved0)
|
||||||
impl_dynamic_global_property_object_type,
|
(asset_dynamic_data)
|
||||||
impl_reserved0_object_type, // formerly index_meta_object_type, TODO: delete me
|
(asset_bitasset_data)
|
||||||
impl_asset_dynamic_data_type,
|
(account_balance)
|
||||||
impl_asset_bitasset_data_type,
|
(account_statistics)
|
||||||
impl_account_balance_object_type,
|
(transaction_history)
|
||||||
impl_account_statistics_object_type,
|
(block_summary)
|
||||||
impl_transaction_object_type,
|
(account_transaction_history)
|
||||||
impl_block_summary_object_type,
|
(blinded_balance)
|
||||||
impl_account_transaction_history_object_type,
|
(chain_property)
|
||||||
impl_blinded_balance_object_type,
|
(witness_schedule)
|
||||||
impl_chain_property_object_type,
|
(budget_record)
|
||||||
impl_witness_schedule_object_type,
|
(special_authority)
|
||||||
impl_budget_record_object_type,
|
(buyback)
|
||||||
impl_special_authority_object_type,
|
(fba_accumulator)
|
||||||
impl_buyback_object_type,
|
(asset_dividend_data)
|
||||||
impl_fba_accumulator_object_type,
|
(pending_dividend_payout_balance_for_holder_object)
|
||||||
impl_collateral_bid_object_type
|
(distributed_dividend_balance_data)
|
||||||
};
|
(betting_market_position_object)
|
||||||
|
(global_betting_statistics_object)
|
||||||
using global_property_id_type = object_id<implementation_ids, impl_global_property_object_type>;
|
(lottery_balance_object)
|
||||||
using dynamic_global_property_id_type = object_id<implementation_ids, impl_dynamic_global_property_object_type>;
|
(sweeps_vesting_balance_object)
|
||||||
using asset_dynamic_data_id_type = object_id<implementation_ids, impl_asset_dynamic_data_type>;
|
(offer_history_object))
|
||||||
using asset_bitasset_data_id_type = object_id<implementation_ids, impl_asset_bitasset_data_type>;
|
|
||||||
using account_balance_id_type = object_id<implementation_ids, impl_account_balance_object_type>;
|
|
||||||
using account_statistics_id_type = object_id<implementation_ids, impl_account_statistics_object_type>;
|
|
||||||
using transaction_obj_id_type = object_id<implementation_ids, impl_transaction_object_type>;
|
|
||||||
using block_summary_id_type = object_id<implementation_ids, impl_block_summary_object_type>;
|
|
||||||
using account_transaction_history_id_type = object_id<implementation_ids, impl_account_transaction_history_object_type>;
|
|
||||||
using chain_property_id_type = object_id<implementation_ids, impl_chain_property_object_type>;
|
|
||||||
using witness_schedule_id_type = object_id<implementation_ids, impl_witness_schedule_object_type>;
|
|
||||||
using budget_record_id_type = object_id<implementation_ids, impl_budget_record_object_type>;
|
|
||||||
using blinded_balance_id_type = object_id<implementation_ids, impl_blinded_balance_object_type>;
|
|
||||||
using special_authority_id_type = object_id<implementation_ids, impl_special_authority_object_type>;
|
|
||||||
using buyback_id_type = object_id<implementation_ids, impl_buyback_object_type>;
|
|
||||||
using fba_accumulator_id_type = object_id<implementation_ids, impl_fba_accumulator_object_type>;
|
|
||||||
using collateral_bid_id_type = object_id<implementation_ids, impl_collateral_bid_object_type>;
|
|
||||||
|
|
||||||
} }
|
|
||||||
|
|
||||||
FC_REFLECT_ENUM(graphene::chain::impl_object_type,
|
|
||||||
(impl_global_property_object_type)
|
|
||||||
(impl_dynamic_global_property_object_type)
|
|
||||||
(impl_reserved0_object_type)
|
|
||||||
(impl_asset_dynamic_data_type)
|
|
||||||
(impl_asset_bitasset_data_type)
|
|
||||||
(impl_account_balance_object_type)
|
|
||||||
(impl_account_statistics_object_type)
|
|
||||||
(impl_transaction_object_type)
|
|
||||||
(impl_block_summary_object_type)
|
|
||||||
(impl_account_transaction_history_object_type)
|
|
||||||
(impl_blinded_balance_object_type)
|
|
||||||
(impl_chain_property_object_type)
|
|
||||||
(impl_witness_schedule_object_type)
|
|
||||||
(impl_budget_record_object_type)
|
|
||||||
(impl_special_authority_object_type)
|
|
||||||
(impl_buyback_object_type)
|
|
||||||
(impl_fba_accumulator_object_type)
|
|
||||||
(impl_collateral_bid_object_type))
|
|
||||||
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::global_property_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::dynamic_global_property_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::asset_dynamic_data_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::asset_bitasset_data_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::account_balance_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::account_statistics_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::transaction_obj_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::block_summary_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::account_transaction_history_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::budget_record_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::special_authority_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::buyback_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::fba_accumulator_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::chain::collateral_bid_id_type)
|
|
||||||
|
|
|
||||||
|
|
@ -21,19 +21,19 @@
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#include <graphene/chain/transaction_object.hpp>
|
#include <graphene/chain/transaction_history_object.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace chain {
|
namespace graphene { namespace chain {
|
||||||
|
|
||||||
const object* transaction_index::create(const std::function<void (object*)>& constructor, object_id_type)
|
const object* transaction_index::create(const std::function<void (object*)>& constructor, object_id_type)
|
||||||
{
|
{
|
||||||
transaction_object obj;
|
transaction_history_object obj;
|
||||||
|
|
||||||
obj.id = get_next_available_id();
|
obj.id = get_next_available_id();
|
||||||
constructor(&obj);
|
constructor(&obj);
|
||||||
|
|
||||||
auto result = _index.insert(std::move(obj));
|
auto result = _index.insert(std::move(obj));
|
||||||
FC_ASSERT(result.second, "Could not create transaction_object! Most likely a uniqueness constraint is violated.");
|
FC_ASSERT(result.second, "Could not create transaction_history_object! Most likely a uniqueness constraint is violated.");
|
||||||
return &*result.first;
|
return &*result.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -43,28 +43,28 @@ void transaction_index::modify(const object* obj,
|
||||||
assert(obj != nullptr);
|
assert(obj != nullptr);
|
||||||
FC_ASSERT(obj->id < _index.size());
|
FC_ASSERT(obj->id < _index.size());
|
||||||
|
|
||||||
const transaction_object* t = dynamic_cast<const transaction_object*>(obj);
|
const transaction_history_object* t = dynamic_cast<const transaction_history_object*>(obj);
|
||||||
assert(t != nullptr);
|
assert(t != nullptr);
|
||||||
|
|
||||||
auto itr = _index.find(obj->id.instance());
|
auto itr = _index.find(obj->id.instance());
|
||||||
assert(itr != _index.end());
|
assert(itr != _index.end());
|
||||||
_index.modify(itr, [&m](transaction_object& o) { m(&o); });
|
_index.modify(itr, [&m](transaction_history_object& o) { m(&o); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void transaction_index::add(unique_ptr<object> o)
|
void transaction_index::add(unique_ptr<object> o)
|
||||||
{
|
{
|
||||||
assert(o);
|
assert(o);
|
||||||
object_id_type id = o->id;
|
object_id_type id = o->id;
|
||||||
assert(id.space() == transaction_object::space_id);
|
assert(id.space() == transaction_history_object::space_id);
|
||||||
assert(id.type() == transaction_object::type_id);
|
assert(id.type() == transaction_history_object::type_id);
|
||||||
assert(id.instance() == size());
|
assert(id.instance() == size());
|
||||||
|
|
||||||
auto trx = dynamic_cast<transaction_object*>(o.get());
|
auto trx = dynamic_cast<transaction_history_object*>(o.get());
|
||||||
assert(trx != nullptr);
|
assert(trx != nullptr);
|
||||||
o.release();
|
o.release();
|
||||||
|
|
||||||
auto result = _index.insert(std::move(*trx));
|
auto result = _index.insert(std::move(*trx));
|
||||||
FC_ASSERT(result.second, "Could not insert transaction_object! Most likely a uniqueness constraint is violated.");
|
FC_ASSERT(result.second, "Could not insert transaction_history_object! Most likely a uniqueness constraint is violated.");
|
||||||
}
|
}
|
||||||
|
|
||||||
void transaction_index::remove(object_id_type id)
|
void transaction_index::remove(object_id_type id)
|
||||||
|
|
@ -74,16 +74,16 @@ void transaction_index::remove(object_id_type id)
|
||||||
if( itr == index.end() )
|
if( itr == index.end() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
assert(id.space() == transaction_object::space_id);
|
assert(id.space() == transaction_history_object::space_id);
|
||||||
assert(id.type() == transaction_object::type_id);
|
assert(id.type() == transaction_history_object::type_id);
|
||||||
|
|
||||||
index.erase(itr);
|
index.erase(itr);
|
||||||
}
|
}
|
||||||
|
|
||||||
const object*transaction_index::get(object_id_type id) const
|
const object*transaction_index::get(object_id_type id) const
|
||||||
{
|
{
|
||||||
if( id.type() != transaction_object::type_id ||
|
if( id.type() != transaction_history_object::type_id ||
|
||||||
id.space() != transaction_object::space_id )
|
id.space() != transaction_history_object::space_id )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto itr = _index.find(id.instance());
|
auto itr = _index.find(id.instance());
|
||||||
|
|
@ -22,6 +22,14 @@
|
||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <boost/preprocessor/seq/for_each.hpp>
|
||||||
|
#include <boost/preprocessor/seq/transform.hpp>
|
||||||
|
#include <boost/preprocessor/seq/elem.hpp>
|
||||||
|
#include <boost/preprocessor/seq/enum.hpp>
|
||||||
|
#include <boost/preprocessor/tuple/elem.hpp>
|
||||||
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
|
||||||
#include <fc/container/flat_fwd.hpp>
|
#include <fc/container/flat_fwd.hpp>
|
||||||
#include <fc/io/varint.hpp>
|
#include <fc/io/varint.hpp>
|
||||||
#include <fc/io/enum_type.hpp>
|
#include <fc/io/enum_type.hpp>
|
||||||
|
|
@ -51,6 +59,28 @@
|
||||||
|
|
||||||
#include <boost/rational.hpp>
|
#include <boost/rational.hpp>
|
||||||
|
|
||||||
|
#define GRAPHENE_NAME_TO_OBJECT_TYPE(x, prefix, name) BOOST_PP_CAT(prefix, BOOST_PP_CAT(name, _object_type))
|
||||||
|
#define GRAPHENE_NAME_TO_ID_TYPE(x, y, name) BOOST_PP_CAT(name, _id_type)
|
||||||
|
#define GRAPHENE_DECLARE_ID(x, space_prefix_seq, name) \
|
||||||
|
using BOOST_PP_CAT(name, _id_type) = object_id<BOOST_PP_TUPLE_ELEM(2, 0, space_prefix_seq), \
|
||||||
|
GRAPHENE_NAME_TO_OBJECT_TYPE(x, BOOST_PP_TUPLE_ELEM(2, 1, space_prefix_seq), name)>;
|
||||||
|
#define GRAPHENE_REFLECT_ID(x, id_namespace, name) FC_REFLECT_TYPENAME(graphene::id_namespace::name)
|
||||||
|
|
||||||
|
#define GRAPHENE_DEFINE_IDS(id_namespace, object_space, object_type_prefix, names_seq) \
|
||||||
|
namespace graphene { namespace id_namespace { \
|
||||||
|
\
|
||||||
|
enum BOOST_PP_CAT(object_type_prefix, object_type) { \
|
||||||
|
BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TRANSFORM(GRAPHENE_NAME_TO_OBJECT_TYPE, object_type_prefix, names_seq)) \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(GRAPHENE_DECLARE_ID, (object_space, object_type_prefix), names_seq) \
|
||||||
|
\
|
||||||
|
} } \
|
||||||
|
\
|
||||||
|
FC_REFLECT_ENUM(graphene::id_namespace::BOOST_PP_CAT(object_type_prefix, object_type), \
|
||||||
|
BOOST_PP_SEQ_TRANSFORM(GRAPHENE_NAME_TO_OBJECT_TYPE, object_type_prefix, names_seq)) \
|
||||||
|
BOOST_PP_SEQ_FOR_EACH(GRAPHENE_REFLECT_ID, id_namespace, BOOST_PP_SEQ_TRANSFORM(GRAPHENE_NAME_TO_ID_TYPE, , names_seq))
|
||||||
|
|
||||||
namespace graphene { namespace protocol {
|
namespace graphene { namespace protocol {
|
||||||
using namespace graphene::db;
|
using namespace graphene::db;
|
||||||
|
|
||||||
|
|
@ -124,65 +154,6 @@ enum reserved_spaces {
|
||||||
|
|
||||||
inline bool is_relative(object_id_type o) { return o.space() == 0; }
|
inline bool is_relative(object_id_type o) { return o.space() == 0; }
|
||||||
|
|
||||||
/**
|
|
||||||
* List all object types from all namespaces here so they can
|
|
||||||
* be easily reflected and displayed in debug output. If a 3rd party
|
|
||||||
* wants to extend the core code then they will have to change the
|
|
||||||
* packed_object::type field from enum_type to uint16 to avoid
|
|
||||||
* warnings when converting packed_objects to/from json.
|
|
||||||
*/
|
|
||||||
enum object_type {
|
|
||||||
null_object_type,
|
|
||||||
base_object_type,
|
|
||||||
account_object_type,
|
|
||||||
asset_object_type,
|
|
||||||
force_settlement_object_type,
|
|
||||||
committee_member_object_type,
|
|
||||||
witness_object_type,
|
|
||||||
limit_order_object_type,
|
|
||||||
call_order_object_type,
|
|
||||||
custom_object_type,
|
|
||||||
proposal_object_type,
|
|
||||||
operation_history_object_type,
|
|
||||||
withdraw_permission_object_type,
|
|
||||||
vesting_balance_object_type,
|
|
||||||
worker_object_type,
|
|
||||||
balance_object_type,
|
|
||||||
tournament_object_type,
|
|
||||||
tournament_details_object_type,
|
|
||||||
match_object_type,
|
|
||||||
game_object_type,
|
|
||||||
sport_object_type,
|
|
||||||
event_group_object_type,
|
|
||||||
event_object_type,
|
|
||||||
betting_market_rules_object_type,
|
|
||||||
betting_market_group_object_type,
|
|
||||||
betting_market_object_type,
|
|
||||||
bet_object_type,
|
|
||||||
custom_permission_object_type,
|
|
||||||
custom_account_authority_object_type,
|
|
||||||
offer_object_type,
|
|
||||||
nft_metadata_type,
|
|
||||||
nft_object_type,
|
|
||||||
OBJECT_TYPE_COUNT ///< Sentry value which contains the number of different object types
|
|
||||||
};
|
|
||||||
|
|
||||||
using account_id_type = object_id<protocol_ids, account_object_type>;
|
|
||||||
using asset_id_type = object_id<protocol_ids, asset_object_type>;
|
|
||||||
using force_settlement_id_type = object_id<protocol_ids, force_settlement_object_type>;
|
|
||||||
using committee_member_id_type = object_id<protocol_ids, committee_member_object_type>;
|
|
||||||
using witness_id_type = object_id<protocol_ids, witness_object_type>;
|
|
||||||
using limit_order_id_type = object_id<protocol_ids, limit_order_object_type>;
|
|
||||||
using call_order_id_type = object_id<protocol_ids, call_order_object_type>;
|
|
||||||
using custom_id_type = object_id<protocol_ids, custom_object_type>;
|
|
||||||
using proposal_id_type = object_id<protocol_ids, proposal_object_type>;
|
|
||||||
using operation_history_id_type = object_id<protocol_ids, operation_history_object_type>;
|
|
||||||
using withdraw_permission_id_type = object_id<protocol_ids, withdraw_permission_object_type>;
|
|
||||||
using vesting_balance_id_type = object_id<protocol_ids, vesting_balance_object_type>;
|
|
||||||
using worker_id_type = object_id<protocol_ids, worker_object_type>;
|
|
||||||
using balance_id_type = object_id<protocol_ids, balance_object_type>;
|
|
||||||
using htlc_id_type = object_id<protocol_ids, htlc_object_type>;
|
|
||||||
|
|
||||||
using block_id_type = fc::ripemd160;
|
using block_id_type = fc::ripemd160;
|
||||||
using checksum_type = fc::ripemd160;
|
using checksum_type = fc::ripemd160;
|
||||||
using transaction_id_type = fc::ripemd160;
|
using transaction_id_type = fc::ripemd160;
|
||||||
|
|
@ -237,71 +208,39 @@ void from_variant( const fc::variant& var, std::shared_ptr<const graphene::proto
|
||||||
uint32_t max_depth = 2 );
|
uint32_t max_depth = 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
FC_REFLECT_ENUM(graphene::protocol::object_type,
|
GRAPHENE_DEFINE_IDS(protocol, protocol_ids, /*protocol objects are not prefixed*/,
|
||||||
(null_object_type)
|
(null)
|
||||||
(base_object_type)
|
(base)
|
||||||
(account_object_type)
|
(account)
|
||||||
(force_settlement_object_type)
|
(force_settlement)
|
||||||
(asset_object_type)
|
(asset)
|
||||||
(committee_member_object_type)
|
(committee_member)
|
||||||
(witness_object_type)
|
(witness)
|
||||||
(limit_order_object_type)
|
(limit_order)
|
||||||
(call_order_object_type)
|
(call_order)
|
||||||
(custom_object_type)
|
(custom)
|
||||||
(proposal_object_type)
|
(proposal)
|
||||||
(operation_history_object_type)
|
(operation_history)
|
||||||
(withdraw_permission_object_type)
|
(withdraw_permission)
|
||||||
(vesting_balance_object_type)
|
(vesting_balance)
|
||||||
(worker_object_type)
|
(worker)
|
||||||
(balance_object_type)
|
(balance)
|
||||||
(tournament_object_type)
|
(tournament_object_type)
|
||||||
(tournament_details_object_type)
|
(tournament_details_object_type)
|
||||||
(match_object_type)
|
(match_object_type)
|
||||||
(game_object_type)
|
(game_object_type)
|
||||||
(sport_object_type)
|
(sport_object_type)
|
||||||
(event_group_object_type)
|
(event_group_object_type)
|
||||||
(event_object_type)
|
(event_object_type)
|
||||||
(betting_market_rules_object_type)
|
(betting_market_rules_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)
|
||||||
(custom_permission_object_type)
|
(custom_permission_object_type)
|
||||||
(custom_account_authority_object_type)
|
(custom_account_authority_object_type)
|
||||||
(offer_object_type)
|
(offer_object_type)
|
||||||
(nft_metadata_type)
|
(nft_metadata_type)
|
||||||
(nft_object_type)
|
(nft_object_type))
|
||||||
(OBJECT_TYPE_COUNT))
|
|
||||||
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::account_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::asset_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::force_settlement_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::committee_member_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::witness_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::limit_order_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::call_order_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::custom_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::proposal_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::operation_history_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::withdraw_permission_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::vesting_balance_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::worker_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::balance_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::tournament_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::tournament_details_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::match_id_type))
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::game_id_type))
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::sport_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::event_group_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::event_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::betting_market_rules_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::betting_market_group_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::betting_market_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::bet_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::custom_permission_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::custom_account_authority_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::offer_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::nft_metadata_id_type)
|
|
||||||
FC_REFLECT_TYPENAME(graphene::protocol::nft_id_type)
|
|
||||||
|
|
||||||
FC_REFLECT(graphene::protocol::public_key_type, (key_data))
|
FC_REFLECT(graphene::protocol::public_key_type, (key_data))
|
||||||
FC_REFLECT(graphene::protocol::public_key_type::binary_key, (data)(check))
|
FC_REFLECT(graphene::protocol::public_key_type::binary_key, (data)(check))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue