@@ -230,32 +230,30 @@ namespace golos { namespace plugins { namespace social_network {
230230 }
231231
232232 void operator ()(const delete_comment_operation& o) const {
233- const auto & comment = impl.db .get_comment (o.author , o.permlink );
234- const auto content = impl.find_comment_content (comment.id );
235-
236- if (content == nullptr ) {
233+ const auto * comment = impl.db .find_comment (o.author , o.permlink );
234+ if (comment == nullptr ) {
237235 return ;
238236 }
239237
240- impl.db . remove (*content );
238+ const auto content = impl.find_comment_content (comment-> id );
241239
242- if (impl.db .template has_index <comment_last_update_index>()) {
243- if (comment.net_rshares > 0 ) {
244- return ;
245- }
240+ if (content != nullptr ) {
241+ impl.db .remove (*content);
242+ }
246243
247- impl.activate_parent_comments (comment);
244+ if (impl.db .template has_index <comment_last_update_index>()) {
245+ impl.activate_parent_comments (*comment);
248246
249247 auto & idx = impl.db .template get_index <comment_last_update_index>().indices ().template get <by_comment>();
250- auto itr = idx.find (comment. id );
248+ auto itr = idx.find (comment-> id );
251249 if (idx.end () != itr) {
252250 impl.db .remove (*itr);
253251 }
254252 }
255253
256254 if (impl.db .template has_index <comment_reward_index>()) {
257255 auto & idx = impl.db .template get_index <comment_reward_index>().indices ().template get <by_comment>();
258- auto itr = idx.find (comment. id );
256+ auto itr = idx.find (comment-> id );
259257 if (idx.end () != itr) {
260258 impl.db .remove (*itr);
261259 }
@@ -287,10 +285,14 @@ namespace golos { namespace plugins { namespace social_network {
287285 } // / ignore all other ops
288286
289287 void operator ()(const golos::protocol::comment_operation& o) const {
290- const auto & comment = db.get_comment (o.author , o.permlink );
288+ const auto * comment = db.find_comment (o.author , o.permlink );
289+ if (nullptr == comment) {
290+ return ;
291+ }
292+
291293 const auto & dp = depth_parameters;
292294 if (!dp.miss_content ()) {
293- const auto comment_content = impl.find_comment_content (comment. id );
295+ const auto comment_content = impl.find_comment_content (comment-> id );
294296 if ( comment_content != nullptr ) {
295297 // Edit case
296298 db.modify (*comment_content, [&]( comment_content_object& con ) {
@@ -331,7 +333,7 @@ namespace golos { namespace plugins { namespace social_network {
331333 } else {
332334 // Creation case
333335 db.create <comment_content_object>([&](comment_content_object& con) {
334- con.comment = comment. id ;
336+ con.comment = comment-> id ;
335337 if (!dp.has_comment_title_depth || dp.comment_title_depth > 0 ) {
336338 from_string (con.title , o.title );
337339 }
@@ -351,8 +353,8 @@ namespace golos { namespace plugins { namespace social_network {
351353
352354 if (db.has_index <comment_last_update_index>()) {
353355 auto now = db.head_block_time ();
354- if (!impl.set_comment_update (comment, now, true )) { // If create case
355- impl.activate_parent_comments (comment);
356+ if (!impl.set_comment_update (* comment, now, true )) { // If create case
357+ impl.activate_parent_comments (* comment);
356358 }
357359 }
358360 }
@@ -472,10 +474,14 @@ namespace golos { namespace plugins { namespace social_network {
472474 auto & content = *itr;
473475 ++itr;
474476
475- auto & comment = db.get_comment (content.comment );
477+ auto * comment = db.find <comment_object, by_id>(content.comment );
478+ if (nullptr == comment) {
479+ db.remove (content);
480+ continue ;
481+ }
476482
477483 auto delta = head_block_num - content.block_number ;
478- if (comment. mode == archived && dp.should_delete_part_of_content_object (delta)) {
484+ if (comment-> mode == archived && dp.should_delete_part_of_content_object (delta)) {
479485 if (dp.should_delete_whole_content_object (delta)) {
480486 db.remove (content);
481487 continue ;
@@ -509,10 +515,14 @@ namespace golos { namespace plugins { namespace social_network {
509515 auto & clu = *itr;
510516 ++itr;
511517
512- auto & comment = db.get_comment (clu.comment );
518+ auto * comment = db.find <comment_object, by_id>(clu.comment );
519+ if (nullptr == comment) {
520+ db.remove (clu);
521+ continue ;
522+ }
513523
514524 auto delta = head_block_num - clu.block_number ;
515- if (comment. mode == archived && depth_parameters.should_delete_last_update_object (delta)) {
525+ if (comment-> mode == archived && depth_parameters.should_delete_last_update_object (delta)) {
516526 db.remove (clu);
517527 } else {
518528 break ;
@@ -720,9 +730,12 @@ namespace golos { namespace plugins { namespace social_network {
720730 continue ;
721731 }
722732
723- const auto & vo = db.get (itr->comment );
733+ const auto * vo = db.find (itr->comment );
734+ if (nullptr == vo) {
735+ continue ;
736+ }
724737 account_vote avote;
725- avote.authorperm = vo. author + " /" + to_string (vo. permlink );
738+ avote.authorperm = vo-> author + " /" + to_string (vo-> permlink );
726739 // avote.weight = itr->weight; // TODO:
727740 avote.rshares = itr->rshares ;
728741 avote.percent = itr->vote_percent ;
@@ -806,7 +819,10 @@ namespace golos { namespace plugins { namespace social_network {
806819 result.reserve (limit);
807820
808821 while (itr != clu_idx.end () && result.size () < limit && itr->parent_author == *parent_author) {
809- result.emplace_back (get_discussion (db.get_comment (itr->comment ), vote_limit, vote_offset));
822+ auto * comment = db.find <comment_object, by_id>(itr->comment );
823+ if (nullptr != comment) {
824+ result.emplace_back (get_discussion (*comment, vote_limit, vote_offset));
825+ }
810826 ++itr;
811827 }
812828
0 commit comments