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

Commit cbd8613

Browse files
authored
Merge pull request #717 from GolosChain/golos-v0.18.0
Golos v0.18.0
2 parents 909e781 + 9e97d43 commit cbd8613

54 files changed

Lines changed: 3638 additions & 535 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,18 @@ env:
1414
- DOCKERFILE=share/golosd/docker/Dockerfile-test DOCKERNAME="-test"
1515
- DOCKERFILE=share/golosd/docker/Dockerfile-testnet DOCKERNAME="-testnet"
1616
- DOCKERFILE=share/golosd/docker/Dockerfile-lowmem DOCKERNAME="-lowmem"
17+
- DOCKERFILE=share/golosd/docker/Dockerfile-mongo DOCKERNAME="-mongo"
1718

1819
matrix:
1920
fast_finish: true
2021

2122
script:
2223
- if [ "$TRAVIS_BRANCH" == "master" ]; then
2324
export DOCKERNAME="latest""$DOCKERNAME";
24-
export EXPORTNAME="latest""$DOCKERNAME";
25+
export EXPORTNAME="$DOCKERNAME";
2526
elif [ -n "$TRAVIS_TAG" ]; then
2627
export DOCKERNAME="$TRAVIS_TAG""$DOCKERNAME";
27-
export EXPORTNAME="$TRAVIS_TAG""$DOCKERNAME";
28+
export EXPORTNAME="$DOCKERNAME";
2829
else
2930
export DOCKERNAME=develop"$DOCKERNAME";
3031
fi

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,14 @@ if(CHAINBASE_CHECK_LOCKING)
9090
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCHAINBASE_CHECK_LOCKING")
9191
endif()
9292

93+
option(ENABLE_MONGO_PLUGIN "Build with mongodb plugin" FALSE)
94+
if(ENABLE_MONGO_PLUGIN)
95+
set(MONGO_LIB golos::mongo_db)
96+
97+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMONGODB_PLUGIN_BUILT")
98+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMONGODB_PLUGIN_BUILT")
99+
endif()
100+
93101
if(WIN32)
94102
set(BOOST_ROOT $ENV{BOOST_ROOT})
95103
set(Boost_USE_MULTITHREADED ON)

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ RUN \
4343
-DBUILD_SHARED_LIBRARIES=FALSE \
4444
-DLOW_MEMORY_NODE=FALSE \
4545
-DCHAINBASE_CHECK_LOCKING=FALSE \
46+
-DENABLE_MONGO_PLUGIN=FALSE \
4647
.. \
4748
&& \
4849
make -j$(nproc) && \

libraries/api/account_api_object.cpp

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,24 @@ account_api_object::account_api_object(const account_object& a, const golos::cha
4949
json_metadata = golos::chain::to_string(meta.json_metadata);
5050
#endif
5151

52-
auto old_forum = db.find<account_bandwidth_object, by_account_bandwidth_type>(
53-
std::make_tuple(name, bandwidth_type::old_forum));
54-
if (old_forum != nullptr) {
55-
average_bandwidth = old_forum->average_bandwidth;
56-
lifetime_bandwidth = old_forum->lifetime_bandwidth;
57-
last_bandwidth_update = old_forum->last_bandwidth_update;
58-
}
59-
60-
auto old_market = db.find<account_bandwidth_object, by_account_bandwidth_type>(
61-
std::make_tuple(name, bandwidth_type::old_market));
62-
if (old_market != nullptr) {
63-
average_market_bandwidth = old_market->average_bandwidth;
64-
last_market_bandwidth_update = old_market->last_bandwidth_update;
65-
}
66-
67-
auto post = db.find<account_bandwidth_object, by_account_bandwidth_type>(
68-
std::make_tuple(name, bandwidth_type::post));
52+
auto post = db.find<account_bandwidth_object, by_account_bandwidth_type>(std::make_tuple(name, bandwidth_type::post));
6953
if (post != nullptr) {
70-
last_root_post = post->last_bandwidth_update;
7154
post_bandwidth = post->average_bandwidth;
55+
last_root_post = post->last_bandwidth_update;
7256
}
7357

74-
auto forum = db.find<account_bandwidth_object, by_account_bandwidth_type>(
75-
std::make_tuple(name, bandwidth_type::forum));
58+
auto forum = db.find<account_bandwidth_object, by_account_bandwidth_type>(std::make_tuple(name, bandwidth_type::forum));
7659
if (forum != nullptr) {
77-
new_average_bandwidth = forum->average_bandwidth;
60+
average_bandwidth = forum->average_bandwidth;
61+
lifetime_bandwidth = forum->lifetime_bandwidth;
62+
last_bandwidth_update = forum->last_bandwidth_update;
7863
}
7964

80-
auto market = db.find<account_bandwidth_object, by_account_bandwidth_type>(
81-
std::make_tuple(name, bandwidth_type::market));
65+
auto market = db.find<account_bandwidth_object, by_account_bandwidth_type>(std::make_tuple(name, bandwidth_type::market));
8266
if (market != nullptr) {
83-
new_average_market_bandwidth = market->average_bandwidth;
67+
average_market_bandwidth = market->average_bandwidth;
68+
lifetime_market_bandwidth = market->lifetime_bandwidth;
69+
last_market_bandwidth_update = market->last_bandwidth_update;
8470
}
8571
}
8672

libraries/api/discussion_helper.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ namespace golos { namespace api {
9191
std::function<void(const golos::chain::database&, discussion&)> fill_promoted_;
9292
};
9393

94-
// get_discussion
94+
// get_discussion
9595
discussion discussion_helper::impl::get_discussion(const comment_object& c, uint32_t vote_limit) const {
9696
discussion d = create_discussion(c);
9797
set_url(d);
@@ -100,9 +100,9 @@ namespace golos { namespace api {
100100
return d;
101101
}
102102

103-
discussion discussion_helper::get_discussion(const comment_object& c, uint32_t vote_limit) const {
103+
discussion discussion_helper::get_discussion(const comment_object& c, uint32_t vote_limit) const {
104104
return pimpl->get_discussion(c, vote_limit);
105-
}
105+
}
106106
//
107107

108108
// select_active_votes
@@ -202,7 +202,7 @@ namespace golos { namespace api {
202202
void discussion_helper::set_url(discussion& d) const {
203203
pimpl->set_url(d);
204204
}
205-
//
205+
//
206206
// create_discussion
207207
discussion discussion_helper::impl::create_discussion(const comment_object& o) const {
208208
return discussion(o, database_);
@@ -218,7 +218,7 @@ namespace golos { namespace api {
218218
std::function<void(const golos::chain::database&, discussion&)> fill_promoted
219219
) {
220220
pimpl = std::make_unique<impl>(db, fill_reputation, fill_promoted);
221-
}
221+
}
222222

223223
discussion_helper::~discussion_helper() = default;
224224

libraries/api/include/golos/api/account_api_object.hpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,18 @@ struct account_api_object {
8181

8282
uint16_t witnesses_voted_for;
8383

84-
share_type average_bandwidth = 0;
85-
share_type lifetime_bandwidth = 0;
84+
share_type average_bandwidth;
85+
share_type average_market_bandwidth;
86+
share_type lifetime_bandwidth;
87+
share_type lifetime_market_bandwidth;
8688
time_point_sec last_bandwidth_update;
87-
88-
share_type average_market_bandwidth = 0;
8989
time_point_sec last_market_bandwidth_update;
9090
time_point_sec last_post;
9191
time_point_sec last_root_post;
9292
share_type post_bandwidth = STEEMIT_100_PERCENT;
9393

94-
share_type new_average_bandwidth;
95-
share_type new_average_market_bandwidth;
9694
set<string> witness_votes;
97-
95+
9896
fc::optional<share_type> reputation;
9997
};
10098

@@ -110,9 +108,10 @@ FC_REFLECT((golos::api::account_api_object),
110108
(savings_sbd_seconds)(savings_sbd_seconds_last_update)(savings_sbd_last_interest_payment)
111109
(savings_withdraw_requests)(vesting_shares)(delegated_vesting_shares)(received_vesting_shares)
112110
(vesting_withdraw_rate)(next_vesting_withdrawal)(withdrawn)(to_withdraw)(withdraw_routes)
113-
(curation_rewards)(posting_rewards)(proxied_vsf_votes)(witnesses_voted_for)(average_bandwidth)
114-
(lifetime_bandwidth)(last_bandwidth_update)(average_market_bandwidth)(last_market_bandwidth_update)
115-
(last_post)(last_root_post)(post_bandwidth)(new_average_bandwidth)(new_average_market_bandwidth)
111+
(curation_rewards)(posting_rewards)(proxied_vsf_votes)(witnesses_voted_for)
112+
(average_bandwidth)(average_market_bandwidth)(lifetime_bandwidth)(lifetime_market_bandwidth)
113+
(last_bandwidth_update)(last_market_bandwidth_update)
114+
(last_post)(last_root_post)(post_bandwidth)
116115
(witness_votes)(reputation))
117116

118117
#endif //GOLOS_ACCOUNT_API_OBJ_HPP

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ namespace golos { namespace api {
1818
golos::chain::database& db,
1919
std::function<void(const golos::chain::database&, const account_name_type&, fc::optional<share_type>&)> fill_reputation,
2020
std::function<void(const golos::chain::database&, discussion&)> fill_promoted);
21-
~discussion_helper() ;
21+
~discussion_helper();
2222

2323

2424
void set_pending_payout(discussion& d) const;
25-
25+
2626
void set_url(discussion& d) const;
2727

2828
void select_active_votes(
2929
std::vector<vote_state>& result, uint32_t& total_count,
3030
const std::string& author, const std::string& permlink, uint32_t limit
31-
) const ;
31+
) const;
3232

3333
discussion create_discussion(const comment_object& o) const;
3434

libraries/chain/chain_properties_evaluators.cpp

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,56 @@
55
namespace golos { namespace chain {
66

77
void witness_update_evaluator::do_apply(const witness_update_operation& o) {
8-
db().get_account(o.owner); // verify owner exists
8+
_db.get_account(o.owner); // verify owner exists
99

10-
if (db().has_hardfork(STEEMIT_HARDFORK_0_1)) {
10+
if (_db.has_hardfork(STEEMIT_HARDFORK_0_1)) {
1111
FC_ASSERT(o.url.size() <= STEEMIT_MAX_WITNESS_URL_LENGTH, "URL is too long");
1212
} else if (o.url.size() > STEEMIT_MAX_WITNESS_URL_LENGTH) {
1313
// after HF, above check can be moved to validate() if reindex doesn't show this warning
14-
wlog("URL is too long in block ${b}", ("b", db().head_block_num() + 1));
14+
wlog("URL is too long in block ${b}", ("b", _db.head_block_num() + 1));
1515
}
1616

17-
if (db().has_hardfork(STEEMIT_HARDFORK_0_14__410)) {
17+
if (_db.has_hardfork(STEEMIT_HARDFORK_0_14__410)) {
1818
FC_ASSERT(o.props.account_creation_fee.symbol == STEEM_SYMBOL);
1919
} else if (o.props.account_creation_fee.symbol != STEEM_SYMBOL) {
2020
// after HF, above check can be moved to validate() if reindex doesn't show this warning
21-
wlog("Wrong fee symbol in block ${b}", ("b",
22-
db().head_block_num() + 1));
21+
wlog("Wrong fee symbol in block ${b}", ("b", _db.head_block_num() + 1));
2322
}
2423

25-
const auto &idx = db().get_index<witness_index>().indices().get<by_name>();
24+
const bool has_hf18 = _db.has_hardfork(STEEMIT_HARDFORK_0_18__673);
25+
26+
// TODO: remove this after HF 18
27+
if (has_hf18) {
28+
if (o.props.account_creation_fee.amount.value != STEEMIT_MIN_ACCOUNT_CREATION_FEE) {
29+
wlog("The chain_properties_update_operation should be used to update account_creation_fee");
30+
}
31+
if (o.props.sbd_interest_rate != STEEMIT_DEFAULT_SBD_INTEREST_RATE) {
32+
wlog("The chain_properties_update_operation should be used to update sbd_interest_rate");
33+
}
34+
if (o.props.maximum_block_size != STEEMIT_MIN_BLOCK_SIZE_LIMIT * 2) {
35+
wlog("The chain_properties_update_operation should be used to update maximum_block_size");
36+
}
37+
}
38+
39+
const auto &idx = _db.get_index<witness_index>().indices().get<by_name>();
2640
auto itr = idx.find(o.owner);
2741
if (itr != idx.end()) {
28-
db().modify(*itr, [&](witness_object& w) {
42+
_db.modify(*itr, [&](witness_object& w) {
2943
from_string(w.url, o.url);
3044
w.signing_key = o.block_signing_key;
31-
w.props = o.props;
45+
if (!has_hf18) {
46+
w.props = o.props;
47+
}
3248
});
3349
} else {
34-
db().create<witness_object>([&](witness_object& w) {
50+
_db.create<witness_object>([&](witness_object& w) {
3551
w.owner = o.owner;
3652
from_string(w.url, o.url);
3753
w.signing_key = o.block_signing_key;
38-
w.created = db().head_block_time();
39-
w.props = o.props;
54+
w.created = _db.head_block_time();
55+
if (!has_hf18) {
56+
w.props = o.props;
57+
}
4058
});
4159
}
4260
}
@@ -54,20 +72,21 @@ namespace golos { namespace chain {
5472

5573
void chain_properties_update_evaluator::do_apply(const chain_properties_update_operation& o) {
5674
ASSERT_REQ_HF(STEEMIT_HARDFORK_0_18__673, "Chain properties"); // remove after hf
57-
db().get_account(o.owner); // verify owner exists
75+
_db.get_account(o.owner); // verify owner exists
5876

59-
const auto &idx = db().get_index<witness_index>().indices().get<by_name>();
77+
const auto &idx = _db.get_index<witness_index>().indices().get<by_name>();
6078
auto itr = idx.find(o.owner);
6179
if (itr != idx.end()) {
62-
db().modify(*itr, [&](witness_object& w) {
80+
_db.modify(*itr, [&](witness_object& w) {
6381
w.props = o.props.visit(chain_properties_convert());
6482
});
6583
} else {
66-
db().create<witness_object>([&](witness_object& w) {
84+
_db.create<witness_object>([&](witness_object& w) {
6785
w.owner = o.owner;
68-
w.created = db().head_block_time();
86+
w.created = _db.head_block_time();
6987
w.props = o.props.visit(chain_properties_convert());
7088
});
7189
}
7290
}
91+
7392
} } // golos::chain

0 commit comments

Comments
 (0)