diff --git a/libraries/chain/account_object.cpp b/libraries/chain/account_object.cpp
index 15a41443..8b8f656e 100644
--- a/libraries/chain/account_object.cpp
+++ b/libraries/chain/account_object.cpp
@@ -142,7 +142,12 @@ set
account_member_index::get_address_members(const account_object& a)c
return result;
}
-void account_member_index::object_inserted(const object& obj)
+void account_member_index::object_loaded(const object& obj)
+{
+ object_created(obj);
+}
+
+void account_member_index::object_created(const object& obj)
{
assert( dynamic_cast(&obj) ); // for debug only
const account_object& a = static_cast(obj);
@@ -256,7 +261,10 @@ void account_member_index::object_modified(const object& after)
}
-void account_referrer_index::object_inserted( const object& obj )
+void account_referrer_index::object_loaded( const object& obj )
+{
+}
+void account_referrer_index::object_created( const object& obj )
{
}
void account_referrer_index::object_removed( const object& obj )
@@ -272,7 +280,12 @@ void account_referrer_index::object_modified( const object& after )
const uint8_t balances_by_account_index::bits = 20;
const uint64_t balances_by_account_index::mask = (1ULL << balances_by_account_index::bits) - 1;
-void balances_by_account_index::object_inserted( const object& obj )
+void balances_by_account_index::object_loaded( const object& obj )
+{
+ object_created(obj);
+}
+
+void balances_by_account_index::object_created( const object& obj )
{
const auto& abo = dynamic_cast< const account_balance_object& >( obj );
while( balances.size() < (abo.owner.instance.value >> bits) + 1 )
diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp
index c547af22..3f7cb984 100644
--- a/libraries/chain/include/graphene/chain/account_object.hpp
+++ b/libraries/chain/include/graphene/chain/account_object.hpp
@@ -323,7 +323,8 @@ namespace graphene { namespace chain {
};
public:
- virtual void object_inserted( const object& obj ) override;
+ virtual void object_loaded( const object& obj ) override;
+ virtual void object_created( const object& obj ) override;
virtual void object_removed( const object& obj ) override;
virtual void about_to_modify( const object& before ) override;
virtual void object_modified( const object& after ) override;
@@ -354,7 +355,8 @@ namespace graphene { namespace chain {
class account_referrer_index : public secondary_index
{
public:
- virtual void object_inserted( const object& obj ) override;
+ virtual void object_loaded( const object& obj ) override;
+ virtual void object_created( const object& obj ) override;
virtual void object_removed( const object& obj ) override;
virtual void about_to_modify( const object& before ) override;
virtual void object_modified( const object& after ) override;
@@ -395,7 +397,8 @@ namespace graphene { namespace chain {
class balances_by_account_index : public secondary_index
{
public:
- virtual void object_inserted( const object& obj ) override;
+ virtual void object_loaded( const object& obj ) override;
+ virtual void object_created( const object& obj ) override;
virtual void object_removed( const object& obj ) override;
virtual void about_to_modify( const object& before ) override;
virtual void object_modified( const object& after ) override;
diff --git a/libraries/chain/include/graphene/chain/offer_object.hpp b/libraries/chain/include/graphene/chain/offer_object.hpp
index cb6440c8..917a4f0f 100644
--- a/libraries/chain/include/graphene/chain/offer_object.hpp
+++ b/libraries/chain/include/graphene/chain/offer_object.hpp
@@ -60,7 +60,8 @@ namespace graphene
class offer_item_index : public secondary_index
{
public:
- virtual void object_inserted(const object &obj) override;
+ virtual void object_loaded(const object &obj) override;
+ virtual void object_created(const object &obj) override;
virtual void object_removed(const object &obj) override;
virtual void about_to_modify(const object &before) override{};
virtual void object_modified(const object &after) override;
diff --git a/libraries/chain/include/graphene/chain/proposal_object.hpp b/libraries/chain/include/graphene/chain/proposal_object.hpp
index 3b83b748..8809aea0 100644
--- a/libraries/chain/include/graphene/chain/proposal_object.hpp
+++ b/libraries/chain/include/graphene/chain/proposal_object.hpp
@@ -62,7 +62,7 @@ class proposal_object : public abstract_object
};
/**
- * @brief tracks all of the proposal objects that requrie approval of
+ * @brief tracks all of the proposal objects that require approval of
* an individual account.
*
* @ingroup object
@@ -75,7 +75,8 @@ class proposal_object : public abstract_object
class required_approval_index : public secondary_index
{
public:
- virtual void object_inserted( const object& obj ) override;
+ virtual void object_loaded( const object& obj ) override;
+ virtual void object_created( const object& obj ) override;
virtual void object_removed( const object& obj ) override;
virtual void about_to_modify( const object& before ) override{};
virtual void object_modified( const object& after ) override{};
diff --git a/libraries/chain/include/graphene/chain/tournament_object.hpp b/libraries/chain/include/graphene/chain/tournament_object.hpp
index 9f2e5860..51964f60 100644
--- a/libraries/chain/include/graphene/chain/tournament_object.hpp
+++ b/libraries/chain/include/graphene/chain/tournament_object.hpp
@@ -224,7 +224,8 @@ namespace graphene { namespace chain {
class tournament_players_index : public secondary_index
{
public:
- virtual void object_inserted( const object& obj ) override;
+ virtual void object_loaded( const object& obj ) override;
+ virtual void object_created( const object& obj ) override;
virtual void object_removed( const object& obj ) override;
virtual void about_to_modify( const object& before ) override;
virtual void object_modified( const object& after ) override;
diff --git a/libraries/chain/offer_object.cpp b/libraries/chain/offer_object.cpp
index 35ac47d2..795648f3 100644
--- a/libraries/chain/offer_object.cpp
+++ b/libraries/chain/offer_object.cpp
@@ -6,7 +6,12 @@ namespace graphene
namespace chain
{
- void offer_item_index::object_inserted(const object &obj)
+ void offer_item_index::object_loaded(const object &obj)
+ {
+ object_created(obj);
+ }
+
+ void offer_item_index::object_created(const object &obj)
{
assert(dynamic_cast(&obj));
const offer_object &oo = static_cast(obj);
@@ -47,4 +52,4 @@ namespace graphene
}
} // namespace chain
-} // namespace graphene
\ No newline at end of file
+} // namespace graphene
diff --git a/libraries/chain/proposal_object.cpp b/libraries/chain/proposal_object.cpp
index 662c700a..2841daa9 100644
--- a/libraries/chain/proposal_object.cpp
+++ b/libraries/chain/proposal_object.cpp
@@ -52,7 +52,12 @@ bool proposal_object::is_authorized_to_execute( database& db ) const
return true;
}
-void required_approval_index::object_inserted( const object& obj )
+void required_approval_index::object_loaded( const object& obj )
+{
+ object_created(obj);
+}
+
+void required_approval_index::object_created( const object& obj )
{
assert( dynamic_cast(&obj) );
const proposal_object& p = static_cast(obj);
diff --git a/libraries/chain/tournament_object.cpp b/libraries/chain/tournament_object.cpp
index 715ef1d3..9465e048 100644
--- a/libraries/chain/tournament_object.cpp
+++ b/libraries/chain/tournament_object.cpp
@@ -653,7 +653,12 @@ namespace graphene { namespace chain {
return vector();
}
- void tournament_players_index::object_inserted(const object& obj)
+ void tournament_players_index::object_loaded(const object& obj)
+ {
+ object_created(obj);
+ }
+
+ void tournament_players_index::object_created(const object& obj)
{
assert( dynamic_cast(&obj) ); // for debug only
const tournament_details_object& details = static_cast(obj);
diff --git a/libraries/db/include/graphene/db/index.hpp b/libraries/db/include/graphene/db/index.hpp
index c02aeb69..2aa7cb9a 100644
--- a/libraries/db/include/graphene/db/index.hpp
+++ b/libraries/db/include/graphene/db/index.hpp
@@ -135,13 +135,23 @@ namespace graphene { namespace db {
virtual void object_default( object& obj )const = 0;
};
+ /** @class secondary_index
+ * @brief A secondary index is intended to observe a primary index.
+ * A secondary index is not automatically persisted when the node shuts own.
+ */
class secondary_index
{
public:
virtual ~secondary_index(){};
- virtual void object_inserted( const object& obj ){};
+ // Called when an object from a previous node session is loaded from persistence
+ virtual void object_loaded( const object& obj ){};
+ // Called when an object from the current node session is created
+ virtual void object_created( const object& obj ){};
+ // Called when an object is removed
virtual void object_removed( const object& obj ){};
+ // Called when an object is about to be modified
virtual void about_to_modify( const object& before ){};
+ // Called when an object is modified
virtual void object_modified( const object& after ){};
};
@@ -226,7 +236,12 @@ namespace graphene { namespace db {
virtual ~direct_index(){}
- virtual void object_inserted( const object& obj )
+ virtual void object_loaded( const object& obj )
+ {
+ object_created(obj);
+ }
+
+ virtual void object_created( const object& obj )
{
uint64_t instance = obj.id.instance();
if( instance == next )
@@ -386,7 +401,7 @@ namespace graphene { namespace db {
{
const auto& result = DerivedIndex::insert( fc::raw::unpack( data ) );
for( const auto& item : _sindex )
- item->object_inserted( result );
+ item->object_loaded( result );
return result;
}
@@ -395,7 +410,7 @@ namespace graphene { namespace db {
{
const auto& result = DerivedIndex::create( constructor );
for( const auto& item : _sindex )
- item->object_inserted( result );
+ item->object_created( result );
on_add( result );
return result;
}
diff --git a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp
index 84315013..9f042a13 100644
--- a/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp
+++ b/libraries/plugins/account_history/include/graphene/account_history/account_history_plugin.hpp
@@ -84,7 +84,8 @@ class account_history_plugin : public graphene::app::plugin
class affiliate_reward_index : public secondary_index
{
public:
- virtual void object_inserted( const object& obj ) override;
+ virtual void object_loaded( const object& obj ) override;
+ virtual void object_created( const object& obj ) override;
virtual void object_removed( const object& obj ) override;
virtual void about_to_modify( const object& before ) override{};
virtual void object_modified( const object& after ) override{};
diff --git a/libraries/plugins/bookie/bookie_plugin.cpp b/libraries/plugins/bookie/bookie_plugin.cpp
index a8c06a0d..a75624d3 100644
--- a/libraries/plugins/bookie/bookie_plugin.cpp
+++ b/libraries/plugins/bookie/bookie_plugin.cpp
@@ -66,7 +66,8 @@ class persistent_bet_object_helper : public secondary_index
using watched_index = primary_index;
- virtual void object_inserted(const object& obj) override;
+ //virtual void object_loaded(const object& obj) override;
+ virtual void object_created(const object& obj) override;
//virtual void object_removed( const object& obj ) override;
//virtual void about_to_modify( const object& before ) override;
virtual void object_modified(const object& after) override;
@@ -75,7 +76,7 @@ class persistent_bet_object_helper : public secondary_index
bookie_plugin* _bookie_plugin;
};
-void persistent_bet_object_helper::object_inserted(const object& obj)
+void persistent_bet_object_helper::object_created(const object& obj)
{
const bet_object& bet_obj = *boost::polymorphic_downcast(&obj);
_bookie_plugin->database().create([&](persistent_bet_object& saved_bet_obj) {
@@ -103,7 +104,8 @@ class persistent_betting_market_object_helper : public secondary_index
using watched_index = primary_index;
- virtual void object_inserted(const object& obj) override;
+ //virtual void object_loaded(const object& obj) override;
+ virtual void object_created(const object& obj) override;
//virtual void object_removed( const object& obj ) override;
//virtual void about_to_modify( const object& before ) override;
virtual void object_modified(const object& after) override;
@@ -112,7 +114,7 @@ class persistent_betting_market_object_helper : public secondary_index
bookie_plugin* _bookie_plugin;
};
-void persistent_betting_market_object_helper::object_inserted(const object& obj)
+void persistent_betting_market_object_helper::object_created(const object& obj)
{
const betting_market_object& betting_market_obj = *boost::polymorphic_downcast(&obj);
_bookie_plugin->database().create([&](persistent_betting_market_object& saved_betting_market_obj) {
@@ -140,7 +142,8 @@ class persistent_betting_market_group_object_helper : public secondary_index
using watched_index = primary_index;
- virtual void object_inserted(const object& obj) override;
+ //virtual void object_loaded(const object& obj) override;
+ virtual void object_created(const object& obj) override;
//virtual void object_removed( const object& obj ) override;
//virtual void about_to_modify( const object& before ) override;
virtual void object_modified(const object& after) override;
@@ -149,7 +152,7 @@ class persistent_betting_market_group_object_helper : public secondary_index
bookie_plugin* _bookie_plugin;
};
-void persistent_betting_market_group_object_helper::object_inserted(const object& obj)
+void persistent_betting_market_group_object_helper::object_created(const object& obj)
{
const betting_market_group_object& betting_market_group_obj = *boost::polymorphic_downcast(&obj);
_bookie_plugin->database().create([&](persistent_betting_market_group_object& saved_betting_market_group_obj) {
@@ -177,7 +180,8 @@ class persistent_event_object_helper : public secondary_index
using watched_index = primary_index;
- virtual void object_inserted(const object& obj) override;
+ //virtual void object_loaded(const object& obj) override;
+ virtual void object_created(const object& obj) override;
//virtual void object_removed( const object& obj ) override;
//virtual void about_to_modify( const object& before ) override;
virtual void object_modified(const object& after) override;
@@ -186,7 +190,7 @@ class persistent_event_object_helper : public secondary_index
bookie_plugin* _bookie_plugin;
};
-void persistent_event_object_helper::object_inserted(const object& obj)
+void persistent_event_object_helper::object_created(const object& obj)
{
const event_object& event_obj = *boost::polymorphic_downcast(&obj);
_bookie_plugin->database().create([&](persistent_event_object& saved_event_obj) {
diff --git a/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp b/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp
index c9e20b8e..bd91ef17 100644
--- a/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp
+++ b/libraries/plugins/bookie/include/graphene/bookie/bookie_objects.hpp
@@ -68,7 +68,8 @@ class events_by_competitor_index : public secondary_index
public:
virtual ~events_by_competitor_index() {}
- virtual void object_inserted( const object& obj ) override;
+ virtual void object_loaded( const object& obj ) override;
+ virtual void object_created( const object& obj ) override;
virtual void object_removed( const object& obj ) override;
virtual void about_to_modify( const object& before ) override;
virtual void object_modified( const object& after ) override;
@@ -77,7 +78,12 @@ class events_by_competitor_index : public secondary_index
map > competitor_to_events;
};
-void events_by_competitor_index::object_inserted( const object& obj )
+void events_by_competitor_index::object_loaded( const object& obj )
+{
+ object_created(obj);
+}
+
+void events_by_competitor_index::object_created( const object& obj )
{
const persistent_event_object& event_obj = *boost::polymorphic_downcast(&obj);
for (const competitor_id_type& competitor_id : event_obj.competitors)
@@ -97,7 +103,7 @@ void events_by_competitor_index::about_to_modify( const object& before )
}
void events_by_competitor_index::object_modified( const object& after )
{
- object_inserted(after);
+ object_created(after);
}
#endif
diff --git a/libraries/plugins/grouped_orders/grouped_orders_plugin.cpp b/libraries/plugins/grouped_orders/grouped_orders_plugin.cpp
index ef1ae04c..99a77b5a 100644
--- a/libraries/plugins/grouped_orders/grouped_orders_plugin.cpp
+++ b/libraries/plugins/grouped_orders/grouped_orders_plugin.cpp
@@ -55,7 +55,8 @@ class limit_order_group_index : public secondary_index
public:
limit_order_group_index( const flat_set& groups ) : _tracked_groups( groups ) {};
- virtual void object_inserted( const object& obj ) override;
+ virtual void object_loaded( const object& obj ) override;
+ virtual void object_created( const object& obj ) override;
virtual void object_removed( const object& obj ) override;
virtual void about_to_modify( const object& before ) override;
virtual void object_modified( const object& after ) override;
@@ -76,7 +77,12 @@ class limit_order_group_index : public secondary_index
map< limit_order_group_key, limit_order_group_data > _og_data;
};
-void limit_order_group_index::object_inserted( const object& objct )
+void limit_order_group_index::object_loaded( const object& objct )
+{
+ object_created(objct);
+}
+
+void limit_order_group_index::object_created( const object& objct )
{ try {
const limit_order_object& o = static_cast( objct );
@@ -201,7 +207,7 @@ void limit_order_group_index::about_to_modify( const object& objct )
void limit_order_group_index::object_modified( const object& objct )
{ try {
- object_inserted( objct );
+ object_created( objct );
} FC_CAPTURE_AND_RETHROW( (objct) ); }
void limit_order_group_index::remove_order( const limit_order_object& o, bool remove_empty )