Fabcoin Core  0.16.2
P2P Digital Currency
ChainParams.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 <libdevcore/Common.h>
25 #include <libethcore/Common.h>
27 #include <libethcore/BlockHeader.h>
28 #include "Account.h"
29 
30 namespace dev
31 {
32 namespace eth
33 {
34 
35 class SealEngineFace;
36 
38 {
39  ChainParams();
40  ChainParams(ChainParams const& /*_org*/) = default;
41  ChainParams(std::string const& _s, h256 const& _stateRoot = h256());
42  ChainParams(bytes const& _genesisRLP, AccountMap const& _state) { populateFromGenesis(_genesisRLP, _state); }
43  ChainParams(std::string const& _json, bytes const& _genesisRLP, AccountMap const& _state): ChainParams(_json) { populateFromGenesis(_genesisRLP, _state); }
44 
46 
51  u256 gasLimit = 1 << 31;
55  mutable h256 stateRoot;
57 
58  unsigned sealFields = 0;
60 
61  h256 calculateStateRoot(bool _force = false) const;
62 
64  bytes genesisBlock() const;
66  ChainParams loadConfig(std::string const& _json, h256 const& _stateRoot = h256()) const;
67  ChainParams loadGenesisState(std::string const& _json, h256 const& _stateRoot = h256()) const;
68  ChainParams loadGenesis(std::string const& _json, h256 const& _stateRoot = h256()) const;
69 
70 private:
71  void populateFromGenesis(bytes const& _genesisRLP, AccountMap const& _state);
72 };
73 
74 }
75 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
h256 calculateStateRoot(bool _force=false) const
std::unordered_map< Address, Account > AccountMap
Definition: Account.h:239
bytes genesisBlock() const
Genesis block info.
ChainParams loadGenesisState(std::string const &_json, h256 const &_stateRoot=h256()) const
Definition: ChainParams.cpp:80
void populateFromGenesis(bytes const &_genesisRLP, AccountMap const &_state)
h160 Address
An Ethereum address: 20 bytes.
Definition: Common.h:62
ChainParams(bytes const &_genesisRLP, AccountMap const &_state)
Definition: ChainParams.h:42
ChainParams loadConfig(std::string const &_json, h256 const &_stateRoot=h256()) const
load config/genesis
Definition: ChainParams.cpp:54
ChainParams(std::string const &_json, bytes const &_genesisRLP, AccountMap const &_state)
Definition: ChainParams.h:43
ChainParams loadGenesis(std::string const &_json, h256 const &_stateRoot=h256()) const
Definition: ChainParams.cpp:88
h256 stateRoot
Only pre-populate if known equivalent to genesisState&#39;s root. If they&#39;re different Bad Things Will Ha...
Definition: ChainParams.h:55
std::vector< byte > bytes
Definition: Common.h:75
FixedHash< 32 > h256
Definition: FixedHash.h:340
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
AccountMap genesisState
Definition: ChainParams.h:56
h256 parentHash
Genesis params.
Definition: ChainParams.h:48
SealEngineFace * createSealEngine()