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

Commit

Permalink
Merge pull request #717 from GolosChain/golos-v0.18.0
Browse files Browse the repository at this point in the history
Golos v0.18.0
  • Loading branch information
afalaleev committed Jun 6, 2018
2 parents 909e781 + 9e97d43 commit cbd8613
Show file tree
Hide file tree
Showing 54 changed files with 3,638 additions and 535 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@ env:
- DOCKERFILE=share/golosd/docker/Dockerfile-test DOCKERNAME="-test"
- DOCKERFILE=share/golosd/docker/Dockerfile-testnet DOCKERNAME="-testnet"
- DOCKERFILE=share/golosd/docker/Dockerfile-lowmem DOCKERNAME="-lowmem"
- DOCKERFILE=share/golosd/docker/Dockerfile-mongo DOCKERNAME="-mongo"

matrix:
fast_finish: true

script:
- if [ "$TRAVIS_BRANCH" == "master" ]; then
export DOCKERNAME="latest""$DOCKERNAME";
export EXPORTNAME="latest""$DOCKERNAME";
export EXPORTNAME="$DOCKERNAME";
elif [ -n "$TRAVIS_TAG" ]; then
export DOCKERNAME="$TRAVIS_TAG""$DOCKERNAME";
export EXPORTNAME="$TRAVIS_TAG""$DOCKERNAME";
export EXPORTNAME="$DOCKERNAME";
else
export DOCKERNAME=develop"$DOCKERNAME";
fi
Expand Down
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ if(CHAINBASE_CHECK_LOCKING)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DCHAINBASE_CHECK_LOCKING")
endif()

option(ENABLE_MONGO_PLUGIN "Build with mongodb plugin" FALSE)
if(ENABLE_MONGO_PLUGIN)
set(MONGO_LIB golos::mongo_db)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMONGODB_PLUGIN_BUILT")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMONGODB_PLUGIN_BUILT")
endif()

if(WIN32)
set(BOOST_ROOT $ENV{BOOST_ROOT})
set(Boost_USE_MULTITHREADED ON)
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ RUN \
-DBUILD_SHARED_LIBRARIES=FALSE \
-DLOW_MEMORY_NODE=FALSE \
-DCHAINBASE_CHECK_LOCKING=FALSE \
-DENABLE_MONGO_PLUGIN=FALSE \
.. \
&& \
make -j$(nproc) && \
Expand Down
34 changes: 10 additions & 24 deletions libraries/api/account_api_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,38 +49,24 @@ account_api_object::account_api_object(const account_object& a, const golos::cha
json_metadata = golos::chain::to_string(meta.json_metadata);
#endif

auto old_forum = db.find<account_bandwidth_object, by_account_bandwidth_type>(
std::make_tuple(name, bandwidth_type::old_forum));
if (old_forum != nullptr) {
average_bandwidth = old_forum->average_bandwidth;
lifetime_bandwidth = old_forum->lifetime_bandwidth;
last_bandwidth_update = old_forum->last_bandwidth_update;
}

auto old_market = db.find<account_bandwidth_object, by_account_bandwidth_type>(
std::make_tuple(name, bandwidth_type::old_market));
if (old_market != nullptr) {
average_market_bandwidth = old_market->average_bandwidth;
last_market_bandwidth_update = old_market->last_bandwidth_update;
}

auto post = db.find<account_bandwidth_object, by_account_bandwidth_type>(
std::make_tuple(name, bandwidth_type::post));
auto post = db.find<account_bandwidth_object, by_account_bandwidth_type>(std::make_tuple(name, bandwidth_type::post));
if (post != nullptr) {
last_root_post = post->last_bandwidth_update;
post_bandwidth = post->average_bandwidth;
last_root_post = post->last_bandwidth_update;
}

auto forum = db.find<account_bandwidth_object, by_account_bandwidth_type>(
std::make_tuple(name, bandwidth_type::forum));
auto forum = db.find<account_bandwidth_object, by_account_bandwidth_type>(std::make_tuple(name, bandwidth_type::forum));
if (forum != nullptr) {
new_average_bandwidth = forum->average_bandwidth;
average_bandwidth = forum->average_bandwidth;
lifetime_bandwidth = forum->lifetime_bandwidth;
last_bandwidth_update = forum->last_bandwidth_update;
}

auto market = db.find<account_bandwidth_object, by_account_bandwidth_type>(
std::make_tuple(name, bandwidth_type::market));
auto market = db.find<account_bandwidth_object, by_account_bandwidth_type>(std::make_tuple(name, bandwidth_type::market));
if (market != nullptr) {
new_average_market_bandwidth = market->average_bandwidth;
average_market_bandwidth = market->average_bandwidth;
lifetime_market_bandwidth = market->lifetime_bandwidth;
last_market_bandwidth_update = market->last_bandwidth_update;
}
}

Expand Down
10 changes: 5 additions & 5 deletions libraries/api/discussion_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ namespace golos { namespace api {
std::function<void(const golos::chain::database&, discussion&)> fill_promoted_;
};

// get_discussion
// get_discussion
discussion discussion_helper::impl::get_discussion(const comment_object& c, uint32_t vote_limit) const {
discussion d = create_discussion(c);
set_url(d);
Expand All @@ -100,9 +100,9 @@ namespace golos { namespace api {
return d;
}

discussion discussion_helper::get_discussion(const comment_object& c, uint32_t vote_limit) const {
discussion discussion_helper::get_discussion(const comment_object& c, uint32_t vote_limit) const {
return pimpl->get_discussion(c, vote_limit);
}
}
//

// select_active_votes
Expand Down Expand Up @@ -202,7 +202,7 @@ namespace golos { namespace api {
void discussion_helper::set_url(discussion& d) const {
pimpl->set_url(d);
}
//
//
// create_discussion
discussion discussion_helper::impl::create_discussion(const comment_object& o) const {
return discussion(o, database_);
Expand All @@ -218,7 +218,7 @@ namespace golos { namespace api {
std::function<void(const golos::chain::database&, discussion&)> fill_promoted
) {
pimpl = std::make_unique<impl>(db, fill_reputation, fill_promoted);
}
}

discussion_helper::~discussion_helper() = default;

Expand Down
19 changes: 9 additions & 10 deletions libraries/api/include/golos/api/account_api_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,18 @@ struct account_api_object {

uint16_t witnesses_voted_for;

share_type average_bandwidth = 0;
share_type lifetime_bandwidth = 0;
share_type average_bandwidth;
share_type average_market_bandwidth;
share_type lifetime_bandwidth;
share_type lifetime_market_bandwidth;
time_point_sec last_bandwidth_update;

share_type average_market_bandwidth = 0;
time_point_sec last_market_bandwidth_update;
time_point_sec last_post;
time_point_sec last_root_post;
share_type post_bandwidth = STEEMIT_100_PERCENT;

share_type new_average_bandwidth;
share_type new_average_market_bandwidth;
set<string> witness_votes;

fc::optional<share_type> reputation;
};

Expand All @@ -110,9 +108,10 @@ FC_REFLECT((golos::api::account_api_object),
(savings_sbd_seconds)(savings_sbd_seconds_last_update)(savings_sbd_last_interest_payment)
(savings_withdraw_requests)(vesting_shares)(delegated_vesting_shares)(received_vesting_shares)
(vesting_withdraw_rate)(next_vesting_withdrawal)(withdrawn)(to_withdraw)(withdraw_routes)
(curation_rewards)(posting_rewards)(proxied_vsf_votes)(witnesses_voted_for)(average_bandwidth)
(lifetime_bandwidth)(last_bandwidth_update)(average_market_bandwidth)(last_market_bandwidth_update)
(last_post)(last_root_post)(post_bandwidth)(new_average_bandwidth)(new_average_market_bandwidth)
(curation_rewards)(posting_rewards)(proxied_vsf_votes)(witnesses_voted_for)
(average_bandwidth)(average_market_bandwidth)(lifetime_bandwidth)(lifetime_market_bandwidth)
(last_bandwidth_update)(last_market_bandwidth_update)
(last_post)(last_root_post)(post_bandwidth)
(witness_votes)(reputation))

#endif //GOLOS_ACCOUNT_API_OBJ_HPP
6 changes: 3 additions & 3 deletions libraries/api/include/golos/api/discussion_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ namespace golos { namespace api {
golos::chain::database& db,
std::function<void(const golos::chain::database&, const account_name_type&, fc::optional<share_type>&)> fill_reputation,
std::function<void(const golos::chain::database&, discussion&)> fill_promoted);
~discussion_helper() ;
~discussion_helper();


void set_pending_payout(discussion& d) const;

void set_url(discussion& d) const;

void select_active_votes(
std::vector<vote_state>& result, uint32_t& total_count,
const std::string& author, const std::string& permlink, uint32_t limit
) const ;
) const;

discussion create_discussion(const comment_object& o) const;

Expand Down
53 changes: 36 additions & 17 deletions libraries/chain/chain_properties_evaluators.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,56 @@
namespace golos { namespace chain {

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

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

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

const auto &idx = db().get_index<witness_index>().indices().get<by_name>();
const bool has_hf18 = _db.has_hardfork(STEEMIT_HARDFORK_0_18__673);

// TODO: remove this after HF 18
if (has_hf18) {
if (o.props.account_creation_fee.amount.value != STEEMIT_MIN_ACCOUNT_CREATION_FEE) {
wlog("The chain_properties_update_operation should be used to update account_creation_fee");
}
if (o.props.sbd_interest_rate != STEEMIT_DEFAULT_SBD_INTEREST_RATE) {
wlog("The chain_properties_update_operation should be used to update sbd_interest_rate");
}
if (o.props.maximum_block_size != STEEMIT_MIN_BLOCK_SIZE_LIMIT * 2) {
wlog("The chain_properties_update_operation should be used to update maximum_block_size");
}
}

const auto &idx = _db.get_index<witness_index>().indices().get<by_name>();
auto itr = idx.find(o.owner);
if (itr != idx.end()) {
db().modify(*itr, [&](witness_object& w) {
_db.modify(*itr, [&](witness_object& w) {
from_string(w.url, o.url);
w.signing_key = o.block_signing_key;
w.props = o.props;
if (!has_hf18) {
w.props = o.props;
}
});
} else {
db().create<witness_object>([&](witness_object& w) {
_db.create<witness_object>([&](witness_object& w) {
w.owner = o.owner;
from_string(w.url, o.url);
w.signing_key = o.block_signing_key;
w.created = db().head_block_time();
w.props = o.props;
w.created = _db.head_block_time();
if (!has_hf18) {
w.props = o.props;
}
});
}
}
Expand All @@ -54,20 +72,21 @@ namespace golos { namespace chain {

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

const auto &idx = db().get_index<witness_index>().indices().get<by_name>();
const auto &idx = _db.get_index<witness_index>().indices().get<by_name>();
auto itr = idx.find(o.owner);
if (itr != idx.end()) {
db().modify(*itr, [&](witness_object& w) {
_db.modify(*itr, [&](witness_object& w) {
w.props = o.props.visit(chain_properties_convert());
});
} else {
db().create<witness_object>([&](witness_object& w) {
_db.create<witness_object>([&](witness_object& w) {
w.owner = o.owner;
w.created = db().head_block_time();
w.created = _db.head_block_time();
w.props = o.props.visit(chain_properties_convert());
});
}
}

} } // golos::chain
Loading

0 comments on commit cbd8613

Please sign in to comment.