Skip to content

Commit

Permalink
BSIP 40: Merge/Review Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielhourt committed Aug 20, 2019
1 parent 63b1241 commit 4b2b59c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions libraries/chain/custom_authority_evaluator.cpp
Expand Up @@ -56,15 +56,15 @@ void_result custom_authority_create_evaluator::do_evaluate(const custom_authorit
FC_ASSERT(std::distance(range.first, range.second) < config->max_custom_authorities_per_account,
"Cannot create custom authority for account: account already has maximum number");

predicate = get_restriction_predicate(op.restrictions, op.operation_type);
get_restriction_predicate(op.restrictions, op.operation_type);
return void_result();
} FC_CAPTURE_AND_RETHROW((op)) }

object_id_type custom_authority_create_evaluator::do_apply(const custom_authority_create_operation& op)
{ try {
database& d = db();

return d.create<custom_authority_object>([&op, p=std::move(predicate)] (custom_authority_object& obj) mutable {
return d.create<custom_authority_object>([&op] (custom_authority_object& obj) mutable {
obj.account = op.account;
obj.enabled = op.enabled;
obj.valid_from = op.valid_from;
Expand Down
Expand Up @@ -33,7 +33,6 @@ class custom_authority_object;
class custom_authority_create_evaluator : public evaluator<custom_authority_create_evaluator> {
public:
using operation_type = custom_authority_create_operation;
restriction_predicate_function predicate;

void_result do_evaluate(const operation_type& op);
object_id_type do_apply(const operation_type& op);
Expand Down
Expand Up @@ -497,7 +497,7 @@ object_restriction_predicate<Object> create_field_predicate(restriction&& r, sho
auto p = create_predicate_function<Field>(static_cast<restriction_function>(f), std::move(a));
return [p=std::move(p)](const Object& o) { return p(FieldReflection::get(o)); };
};
return typelist::runtime::dispatch(member_list(), r.member_index, predicator);
return typelist::runtime::dispatch(member_list(), r.member_index.value, predicator);
}
template<typename Object>
object_restriction_predicate<Object> create_field_predicate(restriction&&, long) {
Expand Down
2 changes: 2 additions & 0 deletions libraries/protocol/custom_authority.cpp
Expand Up @@ -25,6 +25,8 @@
#include <graphene/protocol/operations.hpp>
#include <graphene/protocol/restriction_predicate.hpp>

#include <fc/io/raw.hpp>

namespace graphene { namespace protocol {

share_type custom_authority_create_operation::calculate_fee(const fee_parameters_type& k)const {
Expand Down
14 changes: 8 additions & 6 deletions tests/common/database_fixture.cpp
Expand Up @@ -41,6 +41,7 @@
#include <graphene/chain/worker_object.hpp>
#include <graphene/chain/htlc_object.hpp>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/hardfork_visitor.hpp>

#include <graphene/utilities/tempdir.hpp>

Expand Down Expand Up @@ -1383,14 +1384,15 @@ void database_fixture::set_htlc_committee_parameters()
std::shared_ptr<fee_schedule_type> new_fee_schedule = std::make_shared<fee_schedule_type>();
new_fee_schedule->scale = GRAPHENE_100_PERCENT;
// replace the old with the new
flat_map<uint64_t, graphene::chain::fee_parameters> params_map = get_htlc_fee_parameters();
flat_map<uint64_t, graphene::chain::fee_parameters> htlc_fees = get_htlc_fee_parameters();
for(auto param : existing_fee_schedule.parameters)
{
auto itr = params_map.find(param.which());
if (itr == params_map.end())
new_fee_schedule->parameters.insert(param);
else
{
auto itr = htlc_fees.find(param.which());
if (itr == htlc_fees.end()) {
// Only define fees for operations which are already forked in!
if (hardfork_visitor(db.head_block_time()).visit(param.which()))
new_fee_schedule->parameters.insert(param);
} else {
new_fee_schedule->parameters.insert( (*itr).second);
}
}
Expand Down

0 comments on commit 4b2b59c

Please sign in to comment.