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

Commit 2e0f193

Browse files
committed
Merge branch 'golos-v0.16.2'
2 parents 16971d9 + 74d0fec commit 2e0f193

22 files changed

Lines changed: 522 additions & 139 deletions

File tree

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ if(LOW_MEMORY_NODE)
7070
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DIS_LOW_MEM")
7171
endif()
7272

73+
option(CHAINBASE_CHECK_LOCKING "Check locks in chainbase (ON or OFF)" TRUE)
74+
message(STATUS "CHAINBASE_CHECK_LOCKING: ${CHAINBASE_CHECK_LOCKING}")
75+
if(CHAINBASE_CHECK_LOCKING)
76+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCHAINBASE_CHECK_LOCKING")
77+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCHAINBASE_CHECK_LOCKING")
78+
endif()
79+
7380
option(CLEAR_VOTES "Build source to clear old votes from memory" ON)
7481
if(CLEAR_VOTES)
7582
message(STATUS " CONFIGURING TO CLEAR OLD VOTES FROM MEMORY")

libraries/app/application.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ namespace steemit {
232232
bool read_only = _options->count("read-only");
233233
register_builtin_apis();
234234

235+
if (_options->count("check-locks")) {
236+
_chain_db->set_require_locking(true);
237+
}
238+
235239
if (_options->count("shared-file-dir")) {
236240
_shared_dir = fc::path(_options->at("shared-file-dir").as<string>());
237241
} else {
@@ -543,16 +547,16 @@ namespace steemit {
543547
num <= _chain_db->head_block_num() &&
544548
result.size() < limit;
545549
++num) {
546-
if (num > 0) {
547-
result.push_back(_chain_db->get_block_id_for_num(num));
548-
}
550+
if (num > 0) {
551+
result.push_back(_chain_db->get_block_id_for_num(num));
552+
}
549553
}
550554

551555
if (!result.empty() &&
552556
block_header::num_from_id(result.back()) <
553557
_chain_db->head_block_num()) {
554-
remaining_item_count = _chain_db->head_block_num() -
555-
block_header::num_from_id(result.back());
558+
remaining_item_count = _chain_db->head_block_num() -
559+
block_header::num_from_id(result.back());
556560
}
557561

558562
return result;
@@ -690,9 +694,9 @@ namespace steemit {
690694

691695
if (last_non_fork_block ==
692696
block_id_type()) { // if the fork goes all the way back to genesis (does graphene's fork db allow this?)
693-
non_fork_high_block_num = 0;
697+
non_fork_high_block_num = 0;
694698
} else {
695-
non_fork_high_block_num = block_header::num_from_id(last_non_fork_block);
699+
non_fork_high_block_num = block_header::num_from_id(last_non_fork_block);
696700
}
697701

698702
high_block_num = non_fork_high_block_num +
@@ -904,7 +908,8 @@ namespace steemit {
904908
("public-api", bpo::value<vector<string>>()->composing()->default_value(default_apis, str_default_apis), "Set an API to be publicly available, may be specified multiple times")
905909
("enable-plugin", bpo::value<vector<string>>()->composing()->default_value(default_plugins, str_default_plugins), "Plugin(s) to enable, may be specified multiple times")
906910
("max-block-age", bpo::value<int32_t>()->default_value(200), "Maximum age of head block when broadcasting tx via API")
907-
("flush", bpo::value<uint32_t>()->default_value(100000), "Flush shared memory file to disk this many blocks");
911+
("flush", bpo::value<uint32_t>()->default_value(100000), "Flush shared memory file to disk this many blocks")
912+
("check-locks", bpo::value<bool>()->default_value(false), "Check correctness of chainbase locking");
908913
command_line_options.add(configuration_file_options);
909914
command_line_options.add_options()
910915
("replay-blockchain", "Rebuild object graph by replaying all blocks")

libraries/app/database_api.cpp

Lines changed: 135 additions & 50 deletions
Large diffs are not rendered by default.

libraries/app/include/steemit/app/database_api.hpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include <fc/api.hpp>
1616
#include <fc/optional.hpp>
1717
#include <fc/variant_object.hpp>
18-
1918
#include <fc/network/ip.hpp>
2019

2120
#include <boost/container/flat_set.hpp>
@@ -75,6 +74,7 @@ namespace steemit {
7574
/**
7675
* Defines the arguments to a query as a struct so it can be easily extended
7776
*/
77+
7878
struct discussion_query {
7979
void validate() const {
8080
FC_ASSERT(filter_tags.find(tag) == filter_tags.end());
@@ -84,6 +84,9 @@ namespace steemit {
8484
string tag;
8585
uint32_t limit = 0;
8686
set<string> filter_tags;
87+
set<string> select_authors; ///< list of authors to include, posts not by this author are filtered
88+
set<string> select_tags; ///< list of tags to include, posts without these tags are filtered
89+
uint32_t truncate_body = 0; ///< the number of bytes of the post body to return, 0 for all
8790
optional<string> start_author;
8891
optional<string> start_permlink;
8992
optional<string> parent_author;
@@ -356,6 +359,9 @@ namespace steemit {
356359
vector<discussion> get_content_replies(string parent, string parent_permlink) const;
357360

358361
///@{ tags API
362+
/** This API will return the top 1000 tags used by an author sorted by most frequently used */
363+
vector<pair<string, uint32_t>> get_tags_used_by_author(const string &author) const;
364+
359365
vector<discussion> get_discussions_by_trending(const discussion_query &query) const;
360366

361367
vector<discussion> get_discussions_by_trending30(const discussion_query &query) const;
@@ -440,7 +446,7 @@ namespace steemit {
440446

441447
void set_url(discussion &d) const;
442448

443-
discussion get_discussion(comment_id_type) const;
449+
discussion get_discussion(comment_id_type, uint32_t truncate_body = 0) const;
444450

445451
static bool filter_default(const comment_api_obj &c) {
446452
return false;
@@ -455,14 +461,14 @@ namespace steemit {
455461
}
456462

457463
template<typename Index, typename StartItr>
458-
vector<discussion> get_discussions(const discussion_query &q,
464+
vector<discussion> get_discussions(const discussion_query &query,
459465
const string &tag,
460466
comment_id_type parent,
461-
const Index &idx, StartItr itr,
467+
const Index &tidx, StartItr tidx_itr,
468+
uint32_t truncate_body = 0,
462469
const std::function<bool(const comment_api_obj &)> &filter = &database_api::filter_default,
463470
const std::function<bool(const comment_api_obj &)> &exit = &database_api::exit_default,
464-
const std::function<bool(const tags::tag_object &)> &tag_exit = &database_api::tag_exit_default
465-
) const;
471+
const std::function<bool(const tags::tag_object &)> &tag_exit = &database_api::tag_exit_default) const;
466472

467473
comment_id_type get_parent(const discussion_query &q) const;
468474

@@ -480,7 +486,7 @@ FC_REFLECT(steemit::app::scheduled_hardfork, (hf_version)(live_time));
480486
FC_REFLECT(steemit::app::liquidity_balance, (account)(weight));
481487
FC_REFLECT(steemit::app::withdraw_route, (from_account)(to_account)(percent)(auto_vest));
482488

483-
FC_REFLECT(steemit::app::discussion_query, (tag)(filter_tags)(start_author)(start_permlink)(parent_author)(parent_permlink)(limit));
489+
FC_REFLECT(steemit::app::discussion_query, (tag)(filter_tags)(select_tags)(select_authors)(truncate_body)(start_author)(start_permlink)(parent_author)(parent_permlink)(limit));
484490

485491
FC_REFLECT_ENUM(steemit::app::withdraw_route_type, (incoming)(outgoing)(all));
486492

@@ -493,6 +499,7 @@ FC_API(steemit::app::database_api,
493499

494500
// tags
495501
(get_trending_tags)
502+
(get_tags_used_by_author)
496503
(get_discussions_by_trending)
497504
(get_discussions_by_trending30)
498505
(get_discussions_by_created)

libraries/app/include/steemit/app/state.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ namespace steemit {
8282
vector<string> replies; ///< author/slug mapping
8383
share_type author_reputation = 0;
8484
asset promoted = asset(0, SBD_SYMBOL);
85-
optional<string> first_reblogged_by;
85+
uint32_t body_length = 0;
86+
vector<account_name_type> reblogged_by;
87+
optional<account_name_type> first_reblogged_by;
8688
optional<time_point_sec> first_reblogged_on;
8789
};
8890

@@ -105,6 +107,8 @@ namespace steemit {
105107
map<uint64_t, applied_operation> vote_history;
106108
map<uint64_t, applied_operation> other_history;
107109
set<string> witness_votes;
110+
vector<pair<string, uint32_t>> tags_usage;
111+
vector<pair<account_name_type, uint32_t>> guest_bloggers;
108112

109113
optional<map<uint32_t, extended_limit_order>> open_orders;
110114
optional<vector<string>> comments; /// permlinks for this user
@@ -193,7 +197,7 @@ namespace steemit {
193197
FC_REFLECT_DERIVED(steemit::app::extended_account,
194198
(steemit::app::account_api_obj),
195199
(vesting_balance)(reputation)
196-
(transfer_history)(market_history)(post_history)(vote_history)(other_history)(witness_votes)(open_orders)(comments)(feed)(blog)(recent_replies)(blog_category)(recommended))
200+
(transfer_history)(market_history)(post_history)(vote_history)(other_history)(witness_votes)(tags_usage)(guest_bloggers)(open_orders)(comments)(feed)(blog)(recent_replies)(blog_category)(recommended))
197201

198202

199203
FC_REFLECT(steemit::app::vote_state, (voter)(weight)(rshares)(percent)(reputation)(time));
@@ -202,7 +206,7 @@ FC_REFLECT(steemit::app::account_vote, (authorperm)(weight)(rshares)(percent)(ti
202206
FC_REFLECT(steemit::app::discussion_index, (category)(trending)(trending30)(updated)(created)(responses)(active)(votes)(maturing)(best)(hot)(promoted)(cashout))
203207
FC_REFLECT(steemit::app::category_index, (active)(recent)(best))
204208
FC_REFLECT(steemit::app::tag_index, (trending))
205-
FC_REFLECT_DERIVED(steemit::app::discussion, (steemit::app::comment_api_obj), (url)(root_title)(pending_payout_value)(total_pending_payout_value)(active_votes)(replies)(author_reputation)(promoted)(first_reblogged_by)(first_reblogged_on))
209+
FC_REFLECT_DERIVED(steemit::app::discussion, (steemit::app::comment_api_obj), (url)(root_title)(pending_payout_value)(total_pending_payout_value)(active_votes)(replies)(author_reputation)(promoted)(body_length)(reblogged_by)(first_reblogged_by)(first_reblogged_on))
206210

207211
FC_REFLECT(steemit::app::state, (current_route)(props)(category_idx)(tag_idx)(categories)(tags)(content)(accounts)(pow_queue)(witnesses)(discussion_idx)(witness_schedule)(feed_price)(error)(market_data))
208212

libraries/chain/database.cpp

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -600,15 +600,14 @@ namespace steemit {
600600

601601
bool result;
602602
detail::with_skip_flags(*this, skip, [&]() {
603-
detail::without_pending_transactions(*this, std::move(_pending_tx),
604-
[&]() {
605-
try {
606-
with_write_lock([&]() {
607-
result = _push_block(new_block);
608-
});
609-
}
610-
FC_CAPTURE_AND_RETHROW((new_block))
611-
});
603+
with_write_lock([&]() {
604+
detail::without_pending_transactions(*this, std::move(_pending_tx), [&]() {
605+
try {
606+
result = _push_block(new_block);
607+
}
608+
FC_CAPTURE_AND_RETHROW((new_block))
609+
});
610+
});
612611
});
613612

614613
//fc::time_point end_time = fc::time_point::now();
@@ -2315,7 +2314,8 @@ namespace steemit {
23152314
auto pay = std::max(percent, STEEMIT_MIN_PRODUCER_REWARD);
23162315

23172316
/// pay witness in vesting shares
2318-
if (props.head_block_number >= STEEMIT_START_MINER_VOTING_BLOCK ||
2317+
if (props.head_block_number >=
2318+
STEEMIT_START_MINER_VOTING_BLOCK ||
23192319
(witness_account.vesting_shares.amount.value == 0)) {
23202320
// const auto& witness_obj = get_witness( props.current_witness );
23212321
create_vesting(witness_account, pay);
@@ -2330,7 +2330,8 @@ namespace steemit {
23302330
auto pay = std::max(percent, STEEMIT_MIN_PRODUCER_REWARD_PRE_HF_16);
23312331

23322332
/// pay witness in vesting shares
2333-
if (props.head_block_number >= STEEMIT_START_MINER_VOTING_BLOCK ||
2333+
if (props.head_block_number >=
2334+
STEEMIT_START_MINER_VOTING_BLOCK ||
23342335
(witness_account.vesting_shares.amount.value == 0)) {
23352336
// const auto& witness_obj = get_witness( props.current_witness );
23362337
create_vesting(witness_account, pay);
@@ -2371,8 +2372,9 @@ namespace steemit {
23712372

23722373
void database::pay_liquidity_reward() {
23732374
#ifdef STEEMIT_BUILD_TESTNET
2374-
if( !liquidity_rewards_enabled )
2375-
return;
2375+
if (!liquidity_rewards_enabled) {
2376+
return;
2377+
}
23762378
#endif
23772379

23782380
if ((head_block_num() % STEEMIT_LIQUIDITY_REWARD_BLOCKS) == 0) {
@@ -2922,9 +2924,11 @@ namespace steemit {
29222924

29232925

29242926
void database::validate_transaction(const signed_transaction &trx) {
2925-
auto session = start_undo_session(true);
2926-
_apply_transaction(trx);
2927-
session.undo();
2927+
database::with_write_lock([&]() {
2928+
auto session = start_undo_session(true);
2929+
_apply_transaction(trx);
2930+
session.undo();
2931+
});
29282932
}
29292933

29302934
void database::notify_changed_objects() {
@@ -3016,12 +3020,12 @@ namespace steemit {
30163020
x += now % span;
30173021
}
30183022
_next_flush_block = x;
3019-
ilog("Next flush scheduled at block ${b}", ("b", x));
3023+
// ilog("Next flush scheduled at block ${b}", ("b", x));
30203024
}
30213025

30223026
if (_next_flush_block == block_num) {
30233027
_next_flush_block = 0;
3024-
ilog("Flushing database shared memory at block ${b}", ("b", block_num));
3028+
// ilog("Flushing database shared memory at block ${b}", ("b", block_num));
30253029
chainbase::database::flush();
30263030
}
30273031
}
@@ -3233,8 +3237,9 @@ namespace steemit {
32333237
fho.current_median_history = copy[copy.size() / 2];
32343238

32353239
#ifdef STEEMIT_BUILD_TESTNET
3236-
if( skip_price_feed_limit_check )
3237-
return;
3240+
if (skip_price_feed_limit_check) {
3241+
return;
3242+
}
32383243
#endif
32393244
if (has_hardfork(STEEMIT_HARDFORK_0_14__230)) {
32403245
const auto &gpo = get_dynamic_global_properties();
@@ -4137,17 +4142,17 @@ namespace steemit {
41374142
case STEEMIT_HARDFORK_0_1:
41384143
perform_vesting_share_split(10000);
41394144
#ifdef STEEMIT_BUILD_TESTNET
4140-
{
4141-
custom_operation test_op;
4142-
string op_msg = "Testnet: Hardfork applied";
4143-
test_op.data = vector< char >( op_msg.begin(), op_msg.end() );
4144-
test_op.required_auths.insert( STEEMIT_INIT_MINER_NAME );
4145-
operation op = test_op; // we need the operation object to live to the end of this scope
4146-
operation_notification note( op );
4147-
notify_pre_apply_operation( note );
4148-
notify_post_apply_operation( note );
4149-
}
4150-
break;
4145+
{
4146+
custom_operation test_op;
4147+
string op_msg = "Testnet: Hardfork applied";
4148+
test_op.data = vector<char>(op_msg.begin(), op_msg.end());
4149+
test_op.required_auths.insert(STEEMIT_INIT_MINER_NAME);
4150+
operation op = test_op; // we need the operation object to live to the end of this scope
4151+
operation_notification note(op);
4152+
notify_pre_apply_operation(note);
4153+
notify_post_apply_operation(note);
4154+
}
4155+
break;
41514156
#endif
41524157
break;
41534158
case STEEMIT_HARDFORK_0_2:
@@ -4470,10 +4475,9 @@ namespace steemit {
44704475
if (itr->parent_author != STEEMIT_ROOT_POST_PARENT) {
44714476
// Low memory nodes only need immediate child count, full nodes track total children
44724477
#ifdef IS_LOW_MEM
4473-
modify( get_comment( itr->parent_author, itr->parent_permlink ), [&]( comment_object& c )
4474-
{
4475-
c.children++;
4476-
});
4478+
modify(get_comment(itr->parent_author, itr->parent_permlink), [&](comment_object &c) {
4479+
c.children++;
4480+
});
44774481
#else
44784482
const comment_object *parent = &get_comment(itr->parent_author, itr->parent_permlink);
44794483
while (parent) {
@@ -4547,6 +4551,5 @@ namespace steemit {
45474551
}
45484552
}
45494553
}
4550-
45514554
}
45524555
} //steemit::chain

libraries/chain/include/steemit/chain/account_object.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ namespace steemit {
2121
class account_object
2222
: public object<account_object_type, account_object> {
2323
public:
24+
account_object() = delete;
25+
2426
template<typename Constructor, typename Allocator>
2527
account_object(Constructor &&c, allocator<Allocator> a)
2628
:json_metadata(a) {
@@ -117,6 +119,8 @@ namespace steemit {
117119
class account_authority_object
118120
: public object<account_authority_object_type, account_authority_object> {
119121
public:
122+
account_authority_object() = delete;
123+
120124
template<typename Constructor, typename Allocator>
121125
account_authority_object(Constructor &&c, allocator<Allocator> a)
122126
: owner(a), active(a), posting(a) {
@@ -157,6 +161,8 @@ namespace steemit {
157161
class owner_authority_history_object
158162
: public object<owner_authority_history_object_type, owner_authority_history_object> {
159163
public:
164+
owner_authority_history_object() = delete;
165+
160166
template<typename Constructor, typename Allocator>
161167
owner_authority_history_object(Constructor &&c, allocator<Allocator> a)
162168
:previous_owner_authority(shared_authority::allocator_type(a.get_segment_manager())) {
@@ -173,6 +179,8 @@ namespace steemit {
173179
class account_recovery_request_object
174180
: public object<account_recovery_request_object_type, account_recovery_request_object> {
175181
public:
182+
account_recovery_request_object() = delete;
183+
176184
template<typename Constructor, typename Allocator>
177185
account_recovery_request_object(Constructor &&c, allocator<Allocator> a)
178186
:new_owner_authority(shared_authority::allocator_type(a.get_segment_manager())) {

libraries/chain/include/steemit/chain/comment_object.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ namespace steemit {
3737
class category_object
3838
: public object<category_object_type, category_object> {
3939
public:
40+
category_object() = delete;
41+
4042
template<typename Constructor, typename Allocator>
4143
category_object(Constructor &&c, allocator <Allocator> a)
4244
:name(a) {
@@ -100,6 +102,8 @@ namespace steemit {
100102
class comment_object
101103
: public object<comment_object_type, comment_object> {
102104
public:
105+
comment_object() = delete;
106+
103107
template<typename Constructor, typename Allocator>
104108
comment_object(Constructor &&c, allocator <Allocator> a)
105109
:category(a), parent_permlink(a), permlink(a), title(a),

0 commit comments

Comments
 (0)