Move min_witness_count and min_committee_member_count from config.hpp to chain_properties #235
This commit is contained in:
parent
a888c81ac4
commit
4ecdea1ce2
8 changed files with 61 additions and 9 deletions
|
|
@ -70,7 +70,7 @@ namespace detail {
|
|||
dlog("Allocating all stake to ${key}", ("key", utilities::key_to_wif(nathan_key)));
|
||||
genesis_state_type initial_state;
|
||||
initial_state.initial_parameters.current_fees = fee_schedule::get_default();//->set_all_fees(GRAPHENE_BLOCKCHAIN_PRECISION);
|
||||
initial_state.initial_active_witnesses = 10;
|
||||
initial_state.initial_active_witnesses = GRAPHENE_DEFAULT_MIN_WITNESS_COUNT;
|
||||
initial_state.initial_timestamp = time_point_sec(time_point::now().sec_since_epoch() /
|
||||
initial_state.initial_parameters.block_interval *
|
||||
initial_state.initial_parameters.block_interval);
|
||||
|
|
@ -89,6 +89,7 @@ namespace detail {
|
|||
initial_state.initial_balances.push_back({nathan_key.get_public_key(),
|
||||
GRAPHENE_SYMBOL,
|
||||
GRAPHENE_MAX_SHARE_SUPPLY});
|
||||
|
||||
return initial_state;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -318,9 +318,14 @@ void database::init_genesis(const genesis_state_type& genesis_state)
|
|||
p.dynamic_flags = 0;
|
||||
p.witness_budget = 0;
|
||||
});
|
||||
|
||||
FC_ASSERT( (genesis_state.immutable_parameters.min_witness_count & 1) == 1, "min_witness_count must be odd" );
|
||||
FC_ASSERT( (genesis_state.immutable_parameters.min_committee_member_count & 1) == 1, "min_committee_member_count must be odd" );
|
||||
|
||||
create<chain_property_object>([&](chain_property_object& p)
|
||||
{
|
||||
p.chain_id = chain_id;
|
||||
p.immutable_parameters = genesis_state.immutable_parameters;
|
||||
} );
|
||||
create<block_summary_object>([&](block_summary_object&) {});
|
||||
|
||||
|
|
|
|||
|
|
@ -150,7 +150,8 @@ void database::update_active_witnesses()
|
|||
&& (stake_tally <= stake_target) )
|
||||
stake_tally += _witness_count_histogram_buffer[++witness_count];
|
||||
|
||||
auto wits = sort_votable_objects<witness_index>(std::max(witness_count*2+1, (size_t)GRAPHENE_MIN_WITNESS_COUNT));
|
||||
const chain_property_object& cpo = get_chain_properties();
|
||||
auto wits = sort_votable_objects<witness_index>(std::max(witness_count*2+1, (size_t)cpo.immutable_parameters.min_witness_count));
|
||||
const global_property_object& gpo = get_global_properties();
|
||||
|
||||
for( const witness_object& wit : wits )
|
||||
|
|
@ -223,7 +224,8 @@ void database::update_active_committee_members()
|
|||
&& (stake_tally <= stake_target) )
|
||||
stake_tally += _committee_count_histogram_buffer[++committee_member_count];
|
||||
|
||||
auto committee_members = sort_votable_objects<committee_member_index>(std::max(committee_member_count*2+1, (size_t)GRAPHENE_MIN_COMMITTEE_MEMBER_COUNT));
|
||||
const chain_property_object& cpo = get_chain_properties();
|
||||
auto committee_members = sort_votable_objects<committee_member_index>(std::max(committee_member_count*2+1, (size_t)cpo.immutable_parameters.min_committee_member_count));
|
||||
|
||||
for( const committee_member_object& del : committee_members )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@ fc::variant_object get_config()
|
|||
result[ "GRAPHENE_MAX_SHARE_SUPPLY" ] = GRAPHENE_MAX_SHARE_SUPPLY;
|
||||
result[ "GRAPHENE_MAX_PAY_RATE" ] = GRAPHENE_MAX_PAY_RATE;
|
||||
result[ "GRAPHENE_MAX_SIG_CHECK_DEPTH" ] = GRAPHENE_MAX_SIG_CHECK_DEPTH;
|
||||
result[ "GRAPHENE_MIN_WITNESS_COUNT" ] = GRAPHENE_MIN_WITNESS_COUNT;
|
||||
result[ "GRAPHENE_MIN_COMMITTEE_MEMBER_COUNT" ] = GRAPHENE_MIN_COMMITTEE_MEMBER_COUNT;
|
||||
result[ "GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT" ] = GRAPHENE_MIN_TRANSACTION_SIZE_LIMIT;
|
||||
result[ "GRAPHENE_MIN_BLOCK_INTERVAL" ] = GRAPHENE_MIN_BLOCK_INTERVAL;
|
||||
result[ "GRAPHENE_MAX_BLOCK_INTERVAL" ] = GRAPHENE_MAX_BLOCK_INTERVAL;
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#include <graphene/chain/immutable_chain_parameters.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
class chain_property_object;
|
||||
|
|
@ -29,12 +31,14 @@ class chain_property_object : public abstract_object<chain_property_object>
|
|||
public:
|
||||
static const uint8_t space_id = implementation_ids;
|
||||
static const uint8_t type_id = impl_chain_property_object_type;
|
||||
|
||||
|
||||
chain_id_type chain_id;
|
||||
immutable_chain_parameters immutable_parameters;
|
||||
};
|
||||
|
||||
} }
|
||||
|
||||
FC_REFLECT_DERIVED( graphene::chain::chain_property_object, (graphene::db::object),
|
||||
(chain_id)
|
||||
(immutable_parameters)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -31,8 +31,6 @@
|
|||
#define GRAPHENE_MAX_SHARE_SUPPLY int64_t(1000000000000000ll)
|
||||
#define GRAPHENE_MAX_PAY_RATE 10000 /* 100% */
|
||||
#define GRAPHENE_MAX_SIG_CHECK_DEPTH 2
|
||||
#define GRAPHENE_MIN_WITNESS_COUNT 10
|
||||
#define GRAPHENE_MIN_COMMITTEE_MEMBER_COUNT 10
|
||||
/**
|
||||
* Don't allow the committee_members to publish a limit that would
|
||||
* make the network unable to operate.
|
||||
|
|
@ -89,6 +87,8 @@
|
|||
|
||||
#define GRAPHENE_DEFAULT_NUM_WITNESSES (101)
|
||||
#define GRAPHENE_DEFAULT_NUM_COMMITTEE (11)
|
||||
#define GRAPHENE_DEFAULT_MIN_WITNESS_COUNT (11)
|
||||
#define GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT (11)
|
||||
#define GRAPHENE_DEFAULT_MAX_WITNESSES (1001) // SHOULD BE ODD
|
||||
#define GRAPHENE_DEFAULT_MAX_COMMITTEE (1001) // SHOULD BE ODD
|
||||
#define GRAPHENE_DEFAULT_MAX_PROPOSAL_LIFETIME_SEC (60*60*24*7*4) // Four weeks
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <graphene/chain/protocol/chain_parameters.hpp>
|
||||
#include <graphene/chain/protocol/types.hpp>
|
||||
#include <graphene/chain/immutable_chain_parameters.hpp>
|
||||
|
||||
#include <fc/crypto/sha256.hpp>
|
||||
|
||||
|
|
@ -78,6 +79,7 @@ struct genesis_state_type {
|
|||
time_point_sec initial_timestamp;
|
||||
share_type max_core_supply = GRAPHENE_MAX_SHARE_SUPPLY;
|
||||
chain_parameters initial_parameters;
|
||||
immutable_chain_parameters immutable_parameters;
|
||||
vector<initial_account_type> initial_accounts;
|
||||
vector<initial_asset_type> initial_assets;
|
||||
vector<initial_balance_type> initial_balances;
|
||||
|
|
@ -120,4 +122,5 @@ FC_REFLECT(graphene::chain::genesis_state_type::initial_worker_type, (owner_name
|
|||
FC_REFLECT(graphene::chain::genesis_state_type,
|
||||
(initial_timestamp)(max_core_supply)(initial_parameters)(initial_accounts)(initial_assets)(initial_balances)
|
||||
(initial_vesting_balances)(initial_active_witnesses)(initial_witness_candidates)
|
||||
(initial_committee_candidates)(initial_worker_candidates))
|
||||
(initial_committee_candidates)(initial_worker_candidates)
|
||||
(immutable_parameters))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Cryptonomex, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is provided for evaluation in private test networks only, until September 8, 2015. After this date, this license expires and
|
||||
* the code may not be used, modified or distributed for any purpose. Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted until September 8, 2015, provided that the following conditions are met:
|
||||
*
|
||||
* 1. The code and/or derivative works are used only for private test networks consisting of no more than 10 P2P nodes.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <fc/reflect/reflect.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <graphene/chain/config.hpp>
|
||||
|
||||
namespace graphene { namespace chain {
|
||||
|
||||
struct immutable_chain_parameters
|
||||
{
|
||||
uint16_t min_committee_member_count = GRAPHENE_DEFAULT_MIN_COMMITTEE_MEMBER_COUNT;
|
||||
uint16_t min_witness_count = GRAPHENE_DEFAULT_MIN_WITNESS_COUNT;
|
||||
};
|
||||
|
||||
} } // graphene::chain
|
||||
|
||||
FC_REFLECT( graphene::chain::immutable_chain_parameters,
|
||||
(min_committee_member_count)
|
||||
(min_witness_count)
|
||||
)
|
||||
Loading…
Reference in a new issue