Fabcoin Core  0.16.2
P2P Digital Currency
BasicGasPricer.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
22 #pragma once
23 
24 #include <array>
25 #include "GasPricer.h"
26 
27 namespace dev
28 {
29 namespace eth
30 {
31 
33 {
34 public:
35  explicit BasicGasPricer(u256 _weiPerRef, u256 _refsPerBlock): m_weiPerRef(_weiPerRef), m_refsPerBlock(_refsPerBlock) {}
36 
37  void setRefPrice(u256 _weiPerRef) { if ((bigint)m_refsPerBlock * _weiPerRef > std::numeric_limits<u256>::max() ) BOOST_THROW_EXCEPTION(Overflow() << errinfo_comment("ether price * block fees is larger than 2**256-1, choose a smaller number.") ); else m_weiPerRef = _weiPerRef; }
38  void setRefBlockFees(u256 _refsPerBlock) { if ((bigint)m_weiPerRef * _refsPerBlock > std::numeric_limits<u256>::max() ) BOOST_THROW_EXCEPTION(Overflow() << errinfo_comment("ether price * block fees is larger than 2**256-1, choose a smaller number.") ); else m_refsPerBlock = _refsPerBlock; }
39 
40  u256 ask(Block const&) const override { return m_weiPerRef * m_refsPerBlock / m_gasPerBlock; }
41  u256 bid(TransactionPriority _p = TransactionPriority::Medium) const override { return m_octiles[(int)_p] > 0 ? m_octiles[(int)_p] : (m_weiPerRef * m_refsPerBlock / m_gasPerBlock); }
42 
43  void update(BlockChain const& _bc) override;
44 
45 private:
48  u256 m_gasPerBlock = DefaultBlockGasLimit;
49  std::array<u256, 9> m_octiles;
50 };
51 
52 }
53 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
Implements the blockchain database.
Definition: BlockChain.h:105
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>> bigint
Definition: Common.h:121
u256 ask(Block const &) const override
TransactionPriority
Definition: GasPricer.h:34
Active model of a block within the block chain.
Definition: Block.h:73
void update(BlockChain const &_bc) override
ExecStats::duration max
Definition: ExecStats.cpp:36
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
u256 bid(TransactionPriority _p=TransactionPriority::Medium) const override
boost::error_info< struct tag_comment, std::string > errinfo_comment
Definition: Assertions.h:78
std::array< u256, 9 > m_octiles
void setRefPrice(u256 _weiPerRef)
BasicGasPricer(u256 _weiPerRef, u256 _refsPerBlock)
void setRefBlockFees(u256 _refsPerBlock)