Fabcoin Core  0.16.2
P2P Digital Currency
ChainOperationParams.cpp
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 #include "ChainOperationParams.h"
23 #include <libdevcore/Log.h>
24 #include <libdevcore/CommonData.h>
25 using namespace std;
26 using namespace dev;
27 using namespace eth;
28 
29 PrecompiledContract::PrecompiledContract(
30  unsigned _base,
31  unsigned _word,
32  PrecompiledExecutor const& _exec,
33  u256 const& _startingBlock
34 ):
35  PrecompiledContract([=](unsigned size) -> bigint
36  {
37  bigint s = size;
38  bigint b = _base;
39  bigint w = _word;
40  return b + (s + 31) / 32 * w;
41  }, _exec, _startingBlock)
42 {}
43 
45 {
46  otherParams = std::unordered_map<std::string, std::string>{
47  {"minGasLimit", "0x1388"},
48  {"maxGasLimit", "0x7fffffffffffffff"},
49  {"gasLimitBoundDivisor", "0x0400"},
50  {"minimumDifficulty", "0x020000"},
51  {"difficultyBoundDivisor", "0x0800"},
52  {"durationLimit", "0x0d"},
53  {"registrar", "5e70c0bbcd5636e0f9f9316e9f8633feb64d4050"},
54  {"networkID", "0x0"}
55  };
56  blockReward = u256("0x4563918244F40000");
57 }
58 
59 u256 ChainOperationParams::u256Param(string const& _name) const
60 {
61  std::string at("");
62 
63  auto it = otherParams.find(_name);
64  if (it != otherParams.end())
65  at = it->second;
66 
67  return u256(fromBigEndian<u256>(fromHex(at)));
68 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
boost::multiprecision::number< boost::multiprecision::cpp_int_backend<>> bigint
Definition: Common.h:121
std::hash for asio::adress
Definition: Common.h:323
std::function< std::pair< bool, bytes >(bytesConstRef _in)> PrecompiledExecutor
Definition: Precompiled.h:34
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
Definition: CommonData.cpp:99
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
#define b(i, j)
u256 u256Param(std::string const &_name) const
Convenience method to get an otherParam as a u256 int.
uint8_t const size_t const size
Definition: sha3.h:20