Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Commit a88d70e

Browse files
authored
Merge pull request #1042 from GolosChain/golos-v0.19.1
Golos v0.19.1
2 parents 3a1e2bb + f8da6e7 commit a88d70e

7 files changed

Lines changed: 84 additions & 81 deletions

File tree

libraries/api/discussion_helper.cpp

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ namespace golos { namespace api {
5757

5858
discussion get_discussion(const comment_object& c, uint32_t vote_limit, uint32_t offset) const;
5959

60+
void fill_discussion(discussion& d, const comment_object& comment, uint32_t vote_limit, uint32_t offset) const;
61+
6062
void fill_comment_api_object(const comment_object& o, comment_api_object& d) const;
6163

6264
private:
@@ -136,8 +138,28 @@ namespace golos { namespace api {
136138
// get_discussion
137139
discussion discussion_helper::impl::get_discussion(const comment_object& comment, uint32_t vote_limit, uint32_t offset) const {
138140
discussion d = create_discussion(comment);
141+
fill_discussion(d, comment, vote_limit, offset);
142+
return d;
143+
}
144+
145+
discussion discussion_helper::get_discussion(const comment_object& c, uint32_t vote_limit, uint32_t offset) const {
146+
return pimpl->get_discussion(c, vote_limit, offset);
147+
}
148+
149+
void discussion_helper::impl::fill_discussion(
150+
discussion& d, const comment_object& comment, uint32_t vote_limit, uint32_t offset
151+
) const {
139152
set_url(d);
140153

154+
fill_reputation_(database_, d.author, d.author_reputation);
155+
156+
if (d.body.size() > 1024 * 128) {
157+
d.body = "body pruned due to size";
158+
}
159+
if (d.parent_author.size() > 0 && d.body.size() > 1024 * 16) {
160+
d.body = "comment pruned due to size";
161+
}
162+
141163
d.active_votes_count = comment.total_votes;
142164

143165
comment_curation_info c{database_, comment, true};
@@ -149,12 +171,12 @@ namespace golos { namespace api {
149171
d.active_votes = select_active_votes(c, vote_limit, offset);
150172

151173
set_pending_payout(d);
152-
153-
return d;
154174
}
155175

156-
discussion discussion_helper::get_discussion(const comment_object& c, uint32_t vote_limit, uint32_t offset) const {
157-
return pimpl->get_discussion(c, vote_limit, offset);
176+
void discussion_helper::fill_discussion(
177+
discussion& d, const comment_object& comment, uint32_t vote_limit, uint32_t offset
178+
) const {
179+
pimpl->fill_discussion(d, comment, vote_limit, offset);
158180
}
159181
//
160182

@@ -293,22 +315,8 @@ namespace golos { namespace api {
293315

294316
d.total_pending_payout_value = db.to_sbd(asset(static_cast<uint64_t>(tpp), pot.symbol));
295317
}
296-
297-
fill_reputation_(db, d.author, d.author_reputation);
298-
299-
if (d.body.size() > 1024 * 128) {
300-
d.body = "body pruned due to size";
301-
}
302-
if (d.parent_author.size() > 0 && d.body.size() > 1024 * 16) {
303-
d.body = "comment pruned due to size";
304-
}
305-
306-
set_url(d);
307318
}
308319

309-
void discussion_helper::set_pending_payout(discussion& d) const {
310-
pimpl->set_pending_payout(d);
311-
}
312320
//
313321
// set_url
314322
void discussion_helper::impl::set_url(discussion& d) const {
@@ -321,9 +329,6 @@ namespace golos { namespace api {
321329
}
322330
}
323331

324-
void discussion_helper::set_url(discussion& d) const {
325-
pimpl->set_url(d);
326-
}
327332
//
328333
// create_discussion
329334
discussion discussion_helper::impl::create_discussion(const std::string& author) const {

libraries/api/include/golos/api/discussion_helper.hpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ namespace golos { namespace api {
2121
);
2222
~discussion_helper();
2323

24-
25-
void set_pending_payout(discussion& d) const;
26-
27-
void set_url(discussion& d) const;
28-
2924
std::vector<vote_state> select_active_votes(
3025
const std::string& author, const std::string& permlink, uint32_t limit, uint32_t offset
3126
) const;
@@ -38,6 +33,8 @@ namespace golos { namespace api {
3833

3934
comment_api_object create_comment_api_object(const comment_object& o) const;
4035

36+
void fill_discussion(discussion&, const comment_object&, uint32_t vote_limit, uint32_t offset) const;
37+
4138
void fill_comment_api_object(const comment_object& o, comment_api_object& d) const;
4239

4340

libraries/protocol/include/golos/protocol/config.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44
#pragma once
55

6-
#define STEEMIT_BLOCKCHAIN_VERSION (version(0, 19, 0))
6+
#define STEEMIT_BLOCKCHAIN_VERSION (version(0, 19, 1))
77
#define STEEMIT_BLOCKCHAIN_HARDFORK_VERSION (hardfork_version(STEEMIT_BLOCKCHAIN_VERSION))
88

99
#ifdef STEEMIT_BUILD_TESTNET

plugins/database_api/api.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ struct plugin::api_impl final {
9797
uint64_t get_account_count() const;
9898

9999
// Authority / validation
100-
std::string get_transaction_hex(const signed_transaction &trx) const;
101100
std::set<public_key_type> get_required_signatures(const signed_transaction &trx, const flat_set<public_key_type> &available_keys) const;
102101
std::set<public_key_type> get_potential_signatures(const signed_transaction &trx) const;
103102
bool verify_authority(const signed_transaction &trx) const;
@@ -572,17 +571,20 @@ DEFINE_API(plugin, get_account_bandwidth) {
572571
// //
573572
//////////////////////////////////////////////////////////////////////
574573

575-
DEFINE_API(plugin, get_transaction_hex) {
574+
DEFINE_API(plugin, get_transaction_digest) {
576575
PLUGIN_API_VALIDATE_ARGS(
577-
(signed_transaction, trx)
576+
(transaction, trx)
578577
);
579-
return my->database().with_weak_read_lock([&]() {
580-
return my->get_transaction_hex(trx);
581-
});
578+
static const auto chain_id = STEEMIT_CHAIN_ID;
579+
return trx.sig_digest(chain_id).str();
582580
}
583581

584-
std::string plugin::api_impl::get_transaction_hex(const signed_transaction &trx) const {
582+
DEFINE_API(plugin, get_transaction_hex) {
583+
PLUGIN_API_VALIDATE_ARGS(
584+
(transaction, trx)
585+
);
585586
return fc::to_hex(fc::raw::pack(trx));
587+
586588
}
587589

588590
DEFINE_API(plugin, get_required_signatures) {

plugins/database_api/include/golos/plugins/database_api/plugin.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ DEFINE_API_ARGS(get_vesting_delegations, msg_pack, vector<vesting_deleg
120120
DEFINE_API_ARGS(get_expiring_vesting_delegations, msg_pack, vector<vesting_delegation_expiration_api_object>)
121121

122122
DEFINE_API_ARGS(get_conversion_requests, msg_pack, std::vector<convert_request_api_object>)
123+
DEFINE_API_ARGS(get_transaction_digest, msg_pack, std::string)
123124
DEFINE_API_ARGS(get_transaction_hex, msg_pack, std::string)
124125
DEFINE_API_ARGS(get_required_signatures, msg_pack, std::set<public_key_type>)
125126
DEFINE_API_ARGS(get_potential_signatures, msg_pack, std::set<public_key_type>)
@@ -284,6 +285,9 @@ class plugin final : public appbase::plugin<plugin> {
284285
// Authority / Validation //
285286
////////////////////////////
286287

288+
/// @brief Get a hexdump of the serialized binary form of a transaction digest
289+
(get_transaction_digest)
290+
287291
/// @brief Get a hexdump of the serialized binary form of a transaction
288292
(get_transaction_hex)
289293

plugins/social_network/social_network.cpp

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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

plugins/tags/plugin.cpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ namespace golos { namespace plugins { namespace tags {
5151
return database_;
5252
}
5353

54-
std::vector<vote_state> select_active_votes(const std::string& author, const std::string& permlink, uint32_t limit, uint32_t offset) const;
55-
5654
bool filter_tags(const tags::tag_type type, std::set<std::string>& select_tags) const;
5755

5856
bool filter_authors(discussion_query& query) const;
@@ -84,10 +82,6 @@ namespace golos { namespace plugins { namespace tags {
8482

8583
std::vector<std::pair<std::string, uint32_t>> get_tags_used_by_author(const std::string& author) const;
8684

87-
void set_pending_payout(discussion& d) const;
88-
89-
void set_url(discussion& d) const;
90-
9185
std::vector<discussion> get_replies_by_last_update(
9286
account_name_type start_parent_author, std::string start_permlink,
9387
uint32_t limit, uint32_t vote_limit
@@ -111,12 +105,6 @@ namespace golos { namespace plugins { namespace tags {
111105
std::unique_ptr<discussion_helper> helper;
112106
};
113107

114-
std::vector<vote_state> tags_plugin::impl::select_active_votes(
115-
const std::string& author, const std::string& permlink, uint32_t limit, uint32_t offset
116-
) const {
117-
return helper->select_active_votes(author, permlink, limit, offset);
118-
}
119-
120108
discussion tags_plugin::impl::get_discussion(const comment_object& c, uint32_t vote_limit, uint32_t votes_offset) const {
121109
return helper->get_discussion(c, vote_limit, votes_offset);
122110
}
@@ -139,9 +127,8 @@ namespace golos { namespace plugins { namespace tags {
139127
}
140128

141129
void tags_plugin::impl::fill_discussion(discussion& d, const discussion_query& query) const {
142-
set_url(d);
143-
set_pending_payout(d);
144-
d.active_votes = select_active_votes(d.author, d.permlink, query.vote_limit, query.vote_offset);
130+
helper->fill_discussion(d, database_.get_comment(d.author, d.permlink), query.vote_limit, query.vote_offset);
131+
145132
d.body_length = static_cast<uint32_t>(d.body.size());
146133
if (query.truncate_body) {
147134
if (d.body.size() > query.truncate_body) {
@@ -231,21 +218,13 @@ namespace golos { namespace plugins { namespace tags {
231218

232219
tags_plugin::~tags_plugin() = default;
233220

234-
void tags_plugin::impl::set_url(discussion& d) const {
235-
helper->set_url( d );
236-
}
237-
238221
boost::multiprecision::uint256_t to256(const fc::uint128_t& t) {
239222
boost::multiprecision::uint256_t result(t.high_bits());
240223
result <<= 65;
241224
result += t.low_bits();
242225
return result;
243226
}
244227

245-
void tags_plugin::impl::set_pending_payout(discussion& d) const {
246-
helper->set_pending_payout(d);
247-
}
248-
249228
bool tags_plugin::impl::filter_tags(const tags::tag_type type, std::set<std::string>& select_tags) const {
250229
if (select_tags.empty()) {
251230
return true;

0 commit comments

Comments
 (0)