提交 d0b21702 编写于 作者: N Nathan Hourt

Move genesis_state_type: chain -> native_contract

Aftermath of 55a84709 -- the chain
library no longer ever touches genesis_state_type; this type is only
recognized by native_contract now, so move its files from the chain
library to the native_contract library.
上级 185dc632
...@@ -8,7 +8,6 @@ add_library( eos_chain ...@@ -8,7 +8,6 @@ add_library( eos_chain
transaction.cpp transaction.cpp
block.cpp block.cpp
genesis_state.cpp
get_config.cpp get_config.cpp
block_log.cpp block_log.cpp
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <eos/chain/type_object.hpp> #include <eos/chain/type_object.hpp>
#include <eos/chain/node_property_object.hpp> #include <eos/chain/node_property_object.hpp>
#include <eos/chain/fork_database.hpp> #include <eos/chain/fork_database.hpp>
#include <eos/chain/genesis_state.hpp>
#include <eos/chain/block_log.hpp> #include <eos/chain/block_log.hpp>
#include <chainbase/chainbase.hpp> #include <chainbase/chainbase.hpp>
......
...@@ -4,7 +4,7 @@ add_library( eos_egenesis_none ...@@ -4,7 +4,7 @@ add_library( eos_egenesis_none
include/eos/egenesis/egenesis.hpp include/eos/egenesis/egenesis.hpp
) )
target_link_libraries( eos_egenesis_none eos_chain fc ) target_link_libraries( eos_egenesis_none eos_chain eos_native_contract fc )
target_include_directories( eos_egenesis_none target_include_directories( eos_egenesis_none
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
...@@ -42,8 +42,8 @@ add_custom_command( ...@@ -42,8 +42,8 @@ add_custom_command(
add_library( eos_egenesis_brief "${CMAKE_CURRENT_BINARY_DIR}/egenesis_brief.cpp" include/eos/egenesis/egenesis.hpp ) add_library( eos_egenesis_brief "${CMAKE_CURRENT_BINARY_DIR}/egenesis_brief.cpp" include/eos/egenesis/egenesis.hpp )
add_library( eos_egenesis_full "${CMAKE_CURRENT_BINARY_DIR}/egenesis_full.cpp" include/eos/egenesis/egenesis.hpp ) add_library( eos_egenesis_full "${CMAKE_CURRENT_BINARY_DIR}/egenesis_full.cpp" include/eos/egenesis/egenesis.hpp )
target_link_libraries( eos_egenesis_brief eos_chain fc ) target_link_libraries( eos_egenesis_brief eos_chain eos_native_contract fc )
target_link_libraries( eos_egenesis_full eos_chain fc ) target_link_libraries( eos_egenesis_full eos_chain eos_native_contract fc )
target_include_directories( eos_egenesis_brief target_include_directories( eos_egenesis_brief
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" ) PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
......
...@@ -34,10 +34,10 @@ ...@@ -34,10 +34,10 @@
#include <fc/smart_ref_impl.hpp> // required for gcc in release mode #include <fc/smart_ref_impl.hpp> // required for gcc in release mode
#include <fc/string.hpp> #include <fc/string.hpp>
#include <fc/io/json.hpp> #include <fc/io/json.hpp>
#include <eos/chain/genesis_state.hpp> #include <eos/native_contract/genesis_state.hpp>
#include <eos/chain/types.hpp>
using namespace eos::chain; using namespace eos::chain;
using eos::native_contract::genesis_state_type;
static const char generated_file_banner[] = static const char generated_file_banner[] =
"// _ _ __ _ _ //\n" "// _ _ __ _ _ //\n"
...@@ -54,7 +54,7 @@ static const char generated_file_banner[] = ...@@ -54,7 +54,7 @@ static const char generated_file_banner[] =
"// Warning: This is a generated file, any changes made here will be //\n" "// Warning: This is a generated file, any changes made here will be //\n"
"// overwritten by the build process. If you need to change what //\n" "// overwritten by the build process. If you need to change what //\n"
"// is generated here, you should use the CMake variable //\n" "// is generated here, you should use the CMake variable //\n"
"// EOS_EGENESIS_JSON to specify an embedded genesis state. //\n" "// EOS_EGENESIS_JSON to specify an embedded genesis state. //\n"
"// //\n" "// //\n"
; ;
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <fc/crypto/sha256.hpp> #include <fc/crypto/sha256.hpp>
#include <eos/chain/types.hpp> #include <eos/chain/types.hpp>
#include <eos/chain/genesis_state.hpp> #include <eos/native_contract/genesis_state.hpp>
namespace eos { namespace egenesis { namespace eos { namespace egenesis {
......
...@@ -7,6 +7,7 @@ add_library( eos_native_contract ...@@ -7,6 +7,7 @@ add_library( eos_native_contract
staked_balance_objects.cpp staked_balance_objects.cpp
system_contract.cpp system_contract.cpp
native_contract_chain_initializer.cpp native_contract_chain_initializer.cpp
genesis_state.cpp
${HEADERS} ${HEADERS}
) )
......
...@@ -22,16 +22,15 @@ ...@@ -22,16 +22,15 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include <eos/chain/genesis_state.hpp> #include <eos/native_contract/genesis_state.hpp>
// these are required to serialize a genesis_state // these are required to serialize a genesis_state
#include <fc/smart_ref_impl.hpp> // required for gcc in release mode #include <fc/smart_ref_impl.hpp> // required for gcc in release mode
namespace eos { namespace chain { namespace eos { namespace native_contract {
chain_id_type genesis_state_type::compute_chain_id() const chain::chain_id_type genesis_state_type::compute_chain_id() const {
{
return initial_chain_id; return initial_chain_id;
} }
} } // eos::chain } } // eos::native_contract
...@@ -32,40 +32,43 @@ ...@@ -32,40 +32,43 @@
#include <string> #include <string>
#include <vector> #include <vector>
namespace eos { namespace chain { namespace eos { namespace native_contract {
using std::string; using std::string;
using std::vector; using std::vector;
using chain::PublicKey;
using chain::Asset;
using chain::Time;
using chain::BlockchainConfiguration;
struct genesis_state_type { struct genesis_state_type {
struct initial_account_type { struct initial_account_type {
initial_account_type(const string& name = string(), initial_account_type(const string& name = string(),
uint64_t staking_bal = 0, uint64_t staking_bal = 0,
uint64_t liquid_bal = 0, uint64_t liquid_bal = 0,
const public_key_type& owner_key = public_key_type(), const PublicKey& owner_key = PublicKey(),
const public_key_type& active_key = public_key_type()) const PublicKey& active_key = PublicKey())
: name(name), staking_balance(staking_bal), liquid_balance(liquid_bal), : name(name), staking_balance(staking_bal), liquid_balance(liquid_bal),
owner_key(owner_key), owner_key(owner_key),
active_key(active_key == public_key_type()? owner_key : active_key) active_key(active_key == PublicKey()? owner_key : active_key)
{} {}
string name; string name;
Asset staking_balance; Asset staking_balance;
Asset liquid_balance; Asset liquid_balance;
public_key_type owner_key; PublicKey owner_key;
public_key_type active_key; PublicKey active_key;
}; };
struct initial_producer_type { struct initial_producer_type {
initial_producer_type(const string& name = string(), initial_producer_type(const string& name = string(),
const public_key_type& signing_key = public_key_type()) const PublicKey& signing_key = PublicKey())
: owner_name(name), block_signing_key(signing_key) : owner_name(name), block_signing_key(signing_key)
{} {}
/// Must correspond to one of the initial accounts /// Must correspond to one of the initial accounts
string owner_name; string owner_name;
public_key_type block_signing_key; PublicKey block_signing_key;
}; };
time_point_sec initial_timestamp; Time initial_timestamp;
BlockchainConfiguration initial_configuration = BlockchainConfiguration initial_configuration = {
{
config::DefaultMaxBlockSize, config::DefaultMaxBlockSize,
config::DefaultTargetBlockSize, config::DefaultTargetBlockSize,
config::DefaultMaxStorageSize, config::DefaultMaxStorageSize,
...@@ -80,23 +83,23 @@ struct genesis_state_type { ...@@ -80,23 +83,23 @@ struct genesis_state_type {
/** /**
* Temporary, will be moved elsewhere. * Temporary, will be moved elsewhere.
*/ */
chain_id_type initial_chain_id; chain::chain_id_type initial_chain_id;
/** /**
* Get the chain_id corresponding to this genesis state. * Get the chain_id corresponding to this genesis state.
* *
* This is the SHA256 serialization of the genesis_state. * This is the SHA256 serialization of the genesis_state.
*/ */
chain_id_type compute_chain_id() const; chain::chain_id_type compute_chain_id() const;
}; };
} } // namespace eos::chain } } // namespace eos::native_contract
FC_REFLECT(eos::chain::genesis_state_type::initial_account_type, FC_REFLECT(eos::native_contract::genesis_state_type::initial_account_type,
(name)(staking_balance)(liquid_balance)(owner_key)(active_key)) (name)(staking_balance)(liquid_balance)(owner_key)(active_key))
FC_REFLECT(eos::chain::genesis_state_type::initial_producer_type, (owner_name)(block_signing_key)) FC_REFLECT(eos::native_contract::genesis_state_type::initial_producer_type, (owner_name)(block_signing_key))
FC_REFLECT(eos::chain::genesis_state_type, FC_REFLECT(eos::native_contract::genesis_state_type,
(initial_timestamp)(initial_configuration)(initial_accounts) (initial_timestamp)(initial_configuration)(initial_accounts)
(initial_producers)(initial_chain_id)) (initial_producers)(initial_chain_id))
#pragma once #pragma once
#include <eos/native_contract/genesis_state.hpp>
#include <eos/chain/chain_controller.hpp> #include <eos/chain/chain_controller.hpp>
namespace eos { namespace native_contract { namespace eos { namespace native_contract {
class native_contract_chain_initializer : public chain::chain_initializer { class native_contract_chain_initializer : public chain::chain_initializer {
chain::genesis_state_type genesis; genesis_state_type genesis;
public: public:
native_contract_chain_initializer(const chain::genesis_state_type& genesis) : genesis(genesis) {} native_contract_chain_initializer(const genesis_state_type& genesis) : genesis(genesis) {}
virtual ~native_contract_chain_initializer() {} virtual ~native_contract_chain_initializer() {}
virtual std::vector<chain::Message> prepare_database(chain::chain_controller& chain, chainbase::database& db); virtual std::vector<chain::Message> prepare_database(chain::chain_controller& chain, chainbase::database& db);
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
#include <eos/chain/fork_database.hpp> #include <eos/chain/fork_database.hpp>
#include <eos/chain/block_log.hpp> #include <eos/chain/block_log.hpp>
#include <eos/chain/exceptions.hpp> #include <eos/chain/exceptions.hpp>
#include <eos/chain/genesis_state.hpp>
#include <eos/chain/producer_object.hpp> #include <eos/chain/producer_object.hpp>
#include <eos/native_contract/native_contract_chain_initializer.hpp> #include <eos/native_contract/native_contract_chain_initializer.hpp>
#include <eos/native_contract/genesis_state.hpp>
#include <fc/io/json.hpp> #include <fc/io/json.hpp>
#include <fc/variant.hpp> #include <fc/variant.hpp>
...@@ -94,7 +94,7 @@ void chain_plugin::plugin_initialize(const variables_map& options) { ...@@ -94,7 +94,7 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
void chain_plugin::plugin_startup() { void chain_plugin::plugin_startup() {
auto& db = app().get_plugin<database_plugin>().db(); auto& db = app().get_plugin<database_plugin>().db();
auto genesis = fc::json::from_file(my->genesis_file).as<chain::genesis_state_type>(); auto genesis = fc::json::from_file(my->genesis_file).as<native_contract::genesis_state_type>();
native_contract::native_contract_chain_initializer initializer(genesis); native_contract::native_contract_chain_initializer initializer(genesis);
my->fork_db = fork_database(); my->fork_db = fork_database();
......
...@@ -72,11 +72,11 @@ fc::path testing_fixture::get_temp_dir(std::string id) { ...@@ -72,11 +72,11 @@ fc::path testing_fixture::get_temp_dir(std::string id) {
return named_temp_dirs.emplace(std::make_pair(id, fc::temp_directory())).first->second.path(); return named_temp_dirs.emplace(std::make_pair(id, fc::temp_directory())).first->second.path();
} }
const genesis_state_type&testing_fixture::genesis_state() const { const native_contract::genesis_state_type& testing_fixture::genesis_state() const {
return default_genesis_state; return default_genesis_state;
} }
genesis_state_type&testing_fixture::genesis_state() { native_contract::genesis_state_type& testing_fixture::genesis_state() {
return default_genesis_state; return default_genesis_state;
} }
......
...@@ -55,11 +55,11 @@ extern uint32_t EOS_TESTING_GENESIS_TIMESTAMP; ...@@ -55,11 +55,11 @@ extern uint32_t EOS_TESTING_GENESIS_TIMESTAMP;
("exc_type", #exc_type) \ ("exc_type", #exc_type) \
); \ ); \
if( fc::enable_record_assert_trip ) \ if( fc::enable_record_assert_trip ) \
std::cout << "EOS_REQUIRE_THROW begin " \ std::cout << "EOS_REQUIRE_THROW begin " \
<< req_throw_info << std::endl; \ << req_throw_info << std::endl; \
BOOST_REQUIRE_THROW( expr, exc_type ); \ BOOST_REQUIRE_THROW( expr, exc_type ); \
if( fc::enable_record_assert_trip ) \ if( fc::enable_record_assert_trip ) \
std::cout << "EOS_REQUIRE_THROW end " \ std::cout << "EOS_REQUIRE_THROW end " \
<< req_throw_info << std::endl; \ << req_throw_info << std::endl; \
} }
...@@ -73,11 +73,11 @@ extern uint32_t EOS_TESTING_GENESIS_TIMESTAMP; ...@@ -73,11 +73,11 @@ extern uint32_t EOS_TESTING_GENESIS_TIMESTAMP;
("exc_type", #exc_type) \ ("exc_type", #exc_type) \
); \ ); \
if( fc::enable_record_assert_trip ) \ if( fc::enable_record_assert_trip ) \
std::cout << "EOS_CHECK_THROW begin " \ std::cout << "EOS_CHECK_THROW begin " \
<< req_throw_info << std::endl; \ << req_throw_info << std::endl; \
BOOST_CHECK_THROW( expr, exc_type ); \ BOOST_CHECK_THROW( expr, exc_type ); \
if( fc::enable_record_assert_trip ) \ if( fc::enable_record_assert_trip ) \
std::cout << "EOS_CHECK_THROW end " \ std::cout << "EOS_CHECK_THROW end " \
<< req_throw_info << std::endl; \ << req_throw_info << std::endl; \
} }
...@@ -109,8 +109,8 @@ public: ...@@ -109,8 +109,8 @@ public:
*/ */
fc::path get_temp_dir(std::string id = std::string()); fc::path get_temp_dir(std::string id = std::string());
const genesis_state_type& genesis_state() const; const native_contract::genesis_state_type& genesis_state() const;
genesis_state_type& genesis_state(); native_contract::genesis_state_type& genesis_state();
private_key_type get_private_key(const public_key_type& public_key) const; private_key_type get_private_key(const public_key_type& public_key) const;
...@@ -118,7 +118,7 @@ protected: ...@@ -118,7 +118,7 @@ protected:
std::vector<fc::temp_directory> anonymous_temp_dirs; std::vector<fc::temp_directory> anonymous_temp_dirs;
std::map<std::string, fc::temp_directory> named_temp_dirs; std::map<std::string, fc::temp_directory> named_temp_dirs;
std::map<public_key_type, private_key_type> key_ring; std::map<public_key_type, private_key_type> key_ring;
genesis_state_type default_genesis_state; native_contract::genesis_state_type default_genesis_state;
}; };
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册