BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
fee_schedule.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
25 
26 namespace graphene { namespace protocol {
27 
28  fee_schedule fee_schedule::get_default_impl()
29  {
30  fee_schedule result;
31  const auto count = fee_parameters::count();
32  result.parameters.reserve(count);
33  for( size_t i = 0; i < count; ++i )
34  {
36  x.set_which(i);
37  result.parameters.insert(x);
38  }
39  return result;
40  }
41 
43  {
44  static const auto result = get_default_impl();
45  return result;
46  }
47 
49  {
50  using result_type = void;
51 
52  template<typename ParamType>
53  result_type operator()( ParamType& op )const
54  {
55  memset( (char*)&op, 0, sizeof(op) );
56  }
57  };
58 
60  {
61  *this = get_default();
62  for( fee_parameters& i : parameters )
63  i.visit( zero_fee_visitor() );
64  this->scale = 0;
65  }
66 
67 } } // graphene::protocol
graphene::protocol::fee_schedule
contains all of the parameters necessary to calculate the fee for any operation
Definition: fee_schedule.hpp:173
fee_schedule.hpp
graphene::protocol::zero_fee_visitor::result_type
void result_type
Definition: fee_schedule.cpp:50
graphene::protocol::fee_schedule::parameters
fee_parameters::flat_set_type parameters
Definition: fee_schedule.hpp:220
graphene::protocol::fee_schedule::scale
uint32_t scale
fee * scale / GRAPHENE_100_PERCENT
Definition: fee_schedule.hpp:221
graphene::protocol::zero_fee_visitor::operator()
result_type operator()(ParamType &op) const
Definition: fee_schedule.cpp:53
graphene::protocol::fee_schedule::zero_all_fees
void zero_all_fees()
Definition: fee_schedule.cpp:59
graphene::protocol::fee_parameters
transform_to_fee_parameters< operation >::type fee_parameters
Definition: fee_schedule.hpp:35
graphene::protocol::fee_schedule::get_default
static const fee_schedule & get_default()
Definition: fee_schedule.cpp:42
graphene::protocol::zero_fee_visitor
Definition: fee_schedule.cpp:48
graphene
Definition: api.cpp:48