Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve #1506: Break protocol off into its own library #1737

Merged
merged 16 commits into from
May 7, 2019
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
build*/
nathanielhourt marked this conversation as resolved.
Show resolved Hide resolved

*.a
*.sw*

Expand Down
1 change: 1 addition & 0 deletions libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ add_subdirectory( utilities )
add_subdirectory( app )
add_subdirectory( plugins )
add_subdirectory( wallet )
add_subdirectory( protocol )
2 changes: 1 addition & 1 deletion libraries/app/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <graphene/chain/database.hpp>
#include <graphene/chain/get_config.hpp>
#include <graphene/utilities/key_conversion.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/market_object.hpp>
#include <graphene/chain/transaction_object.hpp>
Expand Down
4 changes: 2 additions & 2 deletions libraries/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

#include <graphene/chain/db_with.hpp>
#include <graphene/chain/genesis_state.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/protocol/types.hpp>

#include <graphene/egenesis/egenesis.hpp>

Expand Down
2 changes: 1 addition & 1 deletion libraries/app/application_impl.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <graphene/app/application.hpp>
#include <graphene/app/api_access.hpp>
#include <graphene/chain/genesis_state.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/types.hpp>
#include <graphene/net/message.hpp>

namespace graphene { namespace app { namespace detail {
Expand Down
4 changes: 2 additions & 2 deletions libraries/app/include/graphene/app/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

#include <graphene/app/database_api.hpp>

#include <graphene/chain/protocol/types.hpp>
#include <graphene/chain/protocol/confidential.hpp>
#include <graphene/protocol/types.hpp>
#include <graphene/protocol/confidential.hpp>

#include <graphene/market_history/market_history_plugin.hpp>

Expand Down
2 changes: 1 addition & 1 deletion libraries/app/include/graphene/app/database_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

#include <graphene/app/full_account.hpp>

#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/types.hpp>

#include <graphene/chain/database.hpp>

Expand Down
3 changes: 3 additions & 0 deletions libraries/app/include/graphene/app/full_account.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/vesting_balance_object.hpp>
#include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/market_object.hpp>
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/htlc_object.hpp>

namespace graphene { namespace app {
using namespace graphene::chain;
Expand Down
4 changes: 2 additions & 2 deletions libraries/app/include/graphene/app/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@

#include <fc/uint128.hpp>

#include <graphene/chain/protocol/asset.hpp>
#include <graphene/protocol/asset.hpp>

namespace graphene { namespace app {
using namespace graphene::chain;
using namespace graphene::protocol;

typedef boost::multiprecision::uint256_t u256;

Expand Down
2 changes: 1 addition & 1 deletion libraries/app/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

#include <graphene/app/plugin.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/protocol/fee_schedule.hpp>

namespace graphene { namespace app {

Expand Down
31 changes: 1 addition & 30 deletions libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ set_source_files_properties( "${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain
add_dependencies( build_hardfork_hpp cat-parts )

file(GLOB HEADERS "include/graphene/chain/*.hpp")
file(GLOB PROTOCOL_HEADERS "include/graphene/chain/protocol/*.hpp")

if( GRAPHENE_DISABLE_UNITY_BUILD )
set( GRAPHENE_DB_FILES
Expand Down Expand Up @@ -36,35 +35,9 @@ add_library( graphene_chain
${GRAPHENE_DB_FILES}
fork_database.cpp

protocol/types.cpp
protocol/address.cpp
protocol/authority.cpp
protocol/asset.cpp
protocol/assert.cpp
protocol/account.cpp
protocol/transfer.cpp
protocol/chain_parameters.cpp
protocol/committee_member.cpp
protocol/witness.cpp
protocol/market.cpp
protocol/proposal.cpp
protocol/withdraw_permission.cpp
protocol/asset_ops.cpp
protocol/memo.cpp
protocol/worker.cpp
protocol/custom.cpp
protocol/operations.cpp
protocol/transaction.cpp
protocol/block.cpp
protocol/fee_schedule.cpp
protocol/confidential.cpp
protocol/vote.cpp
protocol/htlc.cpp
genesis_state.cpp
get_config.cpp

pts_address.cpp

evaluator.cpp
balance_evaluator.cpp
account_evaluator.cpp
Expand Down Expand Up @@ -95,12 +68,11 @@ add_library( graphene_chain
is_authorized_asset.cpp

${HEADERS}
${PROTOCOL_HEADERS}
"${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp"
)

add_dependencies( graphene_chain build_hardfork_hpp )
target_link_libraries( graphene_chain fc graphene_db )
target_link_libraries( graphene_chain fc graphene_db graphene_protocol )
target_include_directories( graphene_chain
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" )

Expand All @@ -116,4 +88,3 @@ INSTALL( TARGETS
ARCHIVE DESTINATION lib
)
INSTALL( FILES ${HEADERS} DESTINATION "include/graphene/chain" )
INSTALL( FILES ${PROTOCOL_HEADERS} DESTINATION "include/graphene/chain/protocol" )
2 changes: 1 addition & 1 deletion libraries/chain/block_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
#include <graphene/chain/block_database.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <fc/io/raw.hpp>

namespace graphene { namespace chain {
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/buyback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* THE SOFTWARE.
*/

#include <graphene/chain/protocol/buyback.hpp>
#include <graphene/protocol/buyback.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/hardfork.hpp>
Expand Down
6 changes: 3 additions & 3 deletions libraries/chain/committee_member_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <graphene/chain/database.hpp>
#include <graphene/chain/hardfork.hpp>
#include <graphene/chain/account_object.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/protocol/vote.hpp>
#include <graphene/protocol/fee_schedule.hpp>
#include <graphene/protocol/vote.hpp>
#include <graphene/chain/transaction_evaluation_state.hpp>

namespace graphene { namespace chain {
Expand All @@ -42,7 +42,7 @@ object_id_type committee_member_create_evaluator::do_apply( const committee_memb
{ try {
vote_id_type vote_id;
db().modify(db().get_global_properties(), [&vote_id](global_property_object& p) {
vote_id = get_next_vote_id(p, vote_id_type::committee);
vote_id = vote_id_type(vote_id_type::committee, p.next_available_vote_id++);
});

const auto& new_del_object = db().create<committee_member_object>( [&]( committee_member_object& obj ){
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/confidential_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/protocol/confidential.hpp>
#include <graphene/protocol/confidential.hpp>
#include <graphene/chain/confidential_evaluator.hpp>
#include <graphene/chain/confidential_object.hpp>
#include <graphene/chain/database.hpp>
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/db_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@
#include <graphene/chain/proposal_object.hpp>
#include <graphene/chain/transaction_object.hpp>
#include <graphene/chain/witness_object.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/evaluator.hpp>

#include <graphene/protocol/fee_schedule.hpp>

#include <fc/thread/parallel.hpp>

namespace graphene { namespace chain {
Expand Down
2 changes: 0 additions & 2 deletions libraries/chain/db_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@
#include <graphene/chain/worker_evaluator.hpp>
#include <graphene/chain/htlc_evaluator.hpp>

#include <graphene/chain/protocol/fee_schedule.hpp>

#include <fc/uint128.hpp>
#include <fc/crypto/digest.hpp>

Expand Down
2 changes: 2 additions & 0 deletions libraries/chain/db_maint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

#include <fc/uint128.hpp>

#include <graphene/protocol/market.hpp>

#include <graphene/chain/database.hpp>
#include <graphene/chain/fba_accumulator_id.hpp>
#include <graphene/chain/hardfork.hpp>
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/db_management.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
#include <graphene/chain/witness_schedule_object.hpp>
#include <graphene/chain/special_authority_object.hpp>
#include <graphene/chain/operation_history_object.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>

#include <graphene/protocol/fee_schedule.hpp>

#include <fc/io/fstream.hpp>

Expand Down
7 changes: 4 additions & 3 deletions libraries/chain/db_notify.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#include <fc/container/flat.hpp>

#include <graphene/chain/protocol/authority.hpp>
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/chain/protocol/transaction.hpp>
#include <graphene/protocol/authority.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/protocol/transaction.hpp>

#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/worker_object.hpp>
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/db_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <graphene/chain/withdraw_permission_object.hpp>
#include <graphene/chain/witness_object.hpp>

#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/protocol/fee_schedule.hpp>

#include <fc/uint128.hpp>

Expand Down
4 changes: 2 additions & 2 deletions libraries/chain/evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include <graphene/chain/fba_object.hpp>
#include <graphene/chain/committee_member_object.hpp>
#include <graphene/chain/market_evaluator.hpp>
#include <graphene/chain/protocol/fee_schedule.hpp>
#include <graphene/protocol/fee_schedule.hpp>

#include <fc/uint128.hpp>

Expand All @@ -58,7 +58,7 @@ database& generic_evaluator::db()const { return trx_state->db(); }
fee_paying_account = &account_id(d);
fee_paying_account_statistics = &fee_paying_account->statistics(d);

fee_asset = &fee.asset_id(d);
fee_asset = &asset_id_type(fee.asset_id)(d);
nathanielhourt marked this conversation as resolved.
Show resolved Hide resolved
fee_asset_dyn_data = &fee_asset->dynamic_asset_data_id(d);

FC_ASSERT( is_authorized_asset( d, *fee_paying_account, *fee_asset ),
Expand Down
3 changes: 3 additions & 0 deletions libraries/chain/genesis_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

#include <graphene/chain/genesis_state.hpp>

// this is required to serialize a genesis_state
#include <graphene/protocol/fee_schedule.hpp>

namespace graphene { namespace chain {

chain_id_type genesis_state_type::compute_chain_id() const
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/get_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <graphene/chain/get_config.hpp>
#include <graphene/chain/config.hpp>
#include <graphene/chain/protocol/types.hpp>
#include <graphene/protocol/types.hpp>

namespace graphene { namespace chain {

Expand Down
9 changes: 8 additions & 1 deletion libraries/chain/include/graphene/chain/account_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/db/generic_index.hpp>
#include <graphene/chain/types.hpp>
#include <boost/multi_index/composite_key.hpp>

namespace graphene { namespace chain {
class database;
class account_object;
class vesting_balance_object;

/**
* @class account_statistics_object
Expand Down Expand Up @@ -438,6 +441,10 @@ namespace graphene { namespace chain {

}}

MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_balance_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::account_statistics_object)

FC_REFLECT_DERIVED( graphene::chain::account_object,
(graphene::db::object),
(membership_expiration_date)(registrar)(referrer)(lifetime_referrer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/graphene/chain/asset_evaluator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/operations.hpp>
#include <graphene/protocol/operations.hpp>
#include <graphene/chain/evaluator.hpp>
#include <graphene/chain/database.hpp>

Expand Down
12 changes: 9 additions & 3 deletions libraries/chain/include/graphene/chain/asset_object.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
* THE SOFTWARE.
*/
#pragma once
#include <graphene/chain/protocol/asset_ops.hpp>
#include <graphene/protocol/asset_ops.hpp>
#include <boost/multi_index/composite_key.hpp>
#include <graphene/db/generic_index.hpp>
#include <graphene/chain/types.hpp>

/**
* @defgroup prediction_market Prediction Market
Expand All @@ -38,6 +39,7 @@

namespace graphene { namespace chain {
class account_object;
class asset_bitasset_data_object;
class database;
using namespace graphene::db;

Expand Down Expand Up @@ -106,13 +108,13 @@ namespace graphene { namespace chain {
string amount_to_string(share_type amount)const;
/// Convert an asset to a textual representation, i.e. "123.45"
string amount_to_string(const asset& amount)const
{ FC_ASSERT(amount.asset_id == id); return amount_to_string(amount.amount); }
{ FC_ASSERT(amount.asset_id == get_id()); return amount_to_string(amount.amount); }
/// Convert an asset to a textual representation with symbol, i.e. "123.45 USD"
string amount_to_pretty_string(share_type amount)const
{ return amount_to_string(amount) + " " + symbol; }
/// Convert an asset to a textual representation with symbol, i.e. "123.45 USD"
string amount_to_pretty_string(const asset &amount)const
{ FC_ASSERT(amount.asset_id == id); return amount_to_pretty_string(amount.amount); }
{ FC_ASSERT(amount.asset_id == get_id()); return amount_to_pretty_string(amount.amount); }

/// Ticker symbol for this asset, i.e. "USD"
string symbol;
Expand Down Expand Up @@ -312,6 +314,10 @@ namespace graphene { namespace chain {

} } // graphene::chain

MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_dynamic_data_object)
MAP_OBJECT_ID_TO_TYPE(graphene::chain::asset_bitasset_data_object)

FC_REFLECT_DERIVED( graphene::chain::asset_dynamic_data_object, (graphene::db::object),
(current_supply)(confidential_supply)(accumulated_fees)(fee_pool) )

Expand Down
Loading