Browse Source

Genesis info.

cl-refactor
Gav Wood 10 years ago
parent
commit
4ffa45b83f
  1. 3
      libethereum/BlockChain.cpp
  2. 25
      libethereum/CanonBlockChain.cpp
  3. 37
      libethereum/GenesisInfo.cpp
  4. 32
      libethereum/GenesisInfo.h

3
libethereum/BlockChain.cpp

@ -22,6 +22,7 @@
#include "BlockChain.h"
#include <boost/filesystem.hpp>
#include <test/JsonSpiritHeaders.h>
#include <libdevcore/Common.h>
#include <libdevcore/RLP.h>
#include <libdevcrypto/FileSystem.h>
@ -29,11 +30,13 @@
#include <libethcore/ProofOfWork.h>
#include <libethcore/BlockInfo.h>
#include <liblll/Compiler.h>
#include "GenesisInfo.h"
#include "State.h"
#include "Defaults.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
namespace js = json_spirit;
#define ETH_CATCH 1

25
libethereum/CanonBlockChain.cpp

@ -21,6 +21,7 @@
#include "CanonBlockChain.h"
#include <test/JsonSpiritHeaders.h>
#include <boost/filesystem.hpp>
#include <libdevcore/Common.h>
#include <libdevcore/RLP.h>
@ -29,11 +30,13 @@
#include <libethcore/ProofOfWork.h>
#include <libethcore/BlockInfo.h>
#include <liblll/Compiler.h>
#include "GenesisInfo.h"
#include "State.h"
#include "Defaults.h"
using namespace std;
using namespace dev;
using namespace dev::eth;
namespace js = json_spirit;
#define ETH_CATCH 1
@ -42,18 +45,16 @@ std::map<Address, Account> const& dev::eth::genesisState()
static std::map<Address, Account> s_ret;
if (s_ret.empty())
{
// Initialise.
for (auto i: vector<string>({
"dbdbdb2cbd23b783741e8d7fcf51e459b497e4a6",
"e6716f9544a56c530d868e4bfbacb172315bdead",
"b9c015918bdaba24b4ff057a92a3873d6eb201be",
"1a26338f0d905e295fccb71fa9ea849ffa12aaf4",
"2ef47100e0787b915105fd5e3f4ff6752079d5cb",
"cd2a3d9f938e13cd947ec05abc7fe734df8dd826",
"6c386a4b26f73c802f34673f7248bb118f97424a",
"e4157b34ea9615cfbde6b4fda419828124b70c78"
}))
s_ret[Address(fromHex(i))] = Account(u256(1) << 200, Account::NormalCreation);
js::mValue val;
json_spirit::read_string(c_genesisInfo, val);
for (auto account: val.get_obj())
if (account.second.get_obj()["code"].get_str().size())
{
s_ret[Address(fromHex(account.first))] = Account(fromBigEndian<u256>(fromHex(account.second.get_obj()["balance"].get_str())), Account::ContractConception);
s_ret[Address(fromHex(account.first))].setCode(fromHex(account.second.get_obj()["code"].get_str()));
}
else
s_ret[Address(fromHex(account.first))] = Account(fromBigEndian<u256>(fromHex(account.second.get_obj()["balance"].get_str())), Account::NormalCreation);
}
return s_ret;
}

37
libethereum/GenesisInfo.cpp

@ -0,0 +1,37 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file GenesisInfo.cpp
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/
#include "GenesisInfo.h"
std::string const dev::eth::c_genesisInfo =
R"ETHEREUM(
{
"51ba59315b3a95761d0863b05ccc7a7f54703d99": { "balance": "0000000000000100000000000000000000000000000000000000000000000000" },
"e6716f9544a56c530d868e4bfbacb172315bdead": { "balance": "0000000000000100000000000000000000000000000000000000000000000000" },
"b9c015918bdaba24b4ff057a92a3873d6eb201be": { "balance": "0000000000000100000000000000000000000000000000000000000000000000" },
"1a26338f0d905e295fccb71fa9ea849ffa12aaf4": { "balance": "0000000000000100000000000000000000000000000000000000000000000000" },
"2ef47100e0787b915105fd5e3f4ff6752079d5cb": { "balance": "0000000000000100000000000000000000000000000000000000000000000000" },
"cd2a3d9f938e13cd947ec05abc7fe734df8dd826": { "balance": "0000000000000100000000000000000000000000000000000000000000000000" },
"6c386a4b26f73c802f34673f7248bb118f97424a": { "balance": "0000000000000100000000000000000000000000000000000000000000000000" },
"e4157b34ea9615cfbde6b4fda419828124b70c78": { "balance": "0000000000000100000000000000000000000000000000000000000000000000" },
"000000000000000000000000000000000000002a": { "balance": "0000000000000100000000000000000000000000000000000000000000000000", code: "60035415601c576000600060006000609660020a3360155a03f150005b610100331015602757005b60003560805260805160a060020a02330160a0523460a051540160a051553460805154016080515560006000546003600154041015607557506a027b46536c66c8e300000060005460015401115b608157600060025560a5565b600254608f574260025560a4565b62093a806002544203111560a35760016003555b5b5b" }
}
)ETHEREUM";

32
libethereum/GenesisInfo.h

@ -0,0 +1,32 @@
/*
This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file GenesisInfo.h
* @author Gav Wood <i@gavwood.com>
* @date 2014
*/
#pragma once
#include <string>
namespace dev {
namespace eth {
extern std::string const c_genesisInfo;
}
}
Loading…
Cancel
Save