Create new blockchain parameters for peerplays that can be voted on by committee members part 1

This commit is contained in:
Roman Olearski 2016-10-28 19:35:49 +02:00
parent f078fed4fd
commit 8b0cdacb11
2 changed files with 45 additions and 5 deletions

View file

@ -69,6 +69,13 @@ namespace graphene { namespace chain {
uint16_t accounts_per_fee_scale = GRAPHENE_DEFAULT_ACCOUNTS_PER_FEE_SCALE; ///< number of accounts between fee scalings
uint8_t account_fee_scale_bitshifts = GRAPHENE_DEFAULT_ACCOUNT_FEE_SCALE_BITSHIFTS; ///< number of times to left bitshift account registration fee at each scaling
uint8_t max_authority_depth = GRAPHENE_MAX_SIG_CHECK_DEPTH;
/* rps tournament parameters constraints */
uint32_t min_round_delay = 0; ///< miniaml delay between games
uint32_t max_round_delay = 600; ///< maxiaml delay between games
uint32_t min_time_per_commit_move = 0; ///< minimal time to commit the next move
uint32_t max_time_per_commit_move = 600; ///< maximal time to commit the next move
uint32_t min_time_per_reveal_move = 0; ///< minimal time to reveal move
uint32_t max_time_per_reveal_move = 600; ///< maximal time to reveal move
extensions_type extensions;
/** defined in fee_schedule.cpp */
@ -106,5 +113,11 @@ FC_REFLECT( graphene::chain::chain_parameters,
(accounts_per_fee_scale)
(account_fee_scale_bitshifts)
(max_authority_depth)
(min_round_delay)
(max_round_delay)
(min_time_per_commit_move)
(max_time_per_commit_move)
(min_time_per_reveal_move)
(max_time_per_reveal_move)
(extensions)
)

View file

@ -56,11 +56,6 @@ namespace graphene { namespace chain {
else
FC_THROW("Must specify either a fixed start time or a delay");
// TODO: make this committee-set
const uint32_t maximum_round_delay = 60 * 60; // one hour
FC_ASSERT(op.options.round_delay < maximum_round_delay,
"Round delay is too long");
// TODO: make this committee-set
const uint32_t maximum_tournament_number_of_wins = 100;
FC_ASSERT(op.options.number_of_wins > 0);
@ -68,6 +63,38 @@ namespace graphene { namespace chain {
"Matches may not require more than ${number_of_wins} wins",
("number_of_wins", maximum_tournament_number_of_wins));
// round_delay constraints
const uint32_t minimum_round_delay = d.get_global_properties().parameters.min_round_delay;
FC_ASSERT(op.options.round_delay >= minimum_round_delay,
"Delay between games must not be less then ${min}",
("min", minimum_round_delay));
const uint32_t maximum_round_delay = d.get_global_properties().parameters.max_round_delay;
FC_ASSERT(op.options.round_delay <= maximum_round_delay,
"Delay between games must not be greater then ${max}",
("max", maximum_round_delay));
const rock_paper_scissors_game_options& game_options = op.options.game_options.get<rock_paper_scissors_game_options>();
// time_per_commit_move constraints
const uint32_t minimum_time_per_commit_move = d.get_global_properties().parameters.min_time_per_commit_move;
FC_ASSERT(game_options.time_per_commit_move >= minimum_time_per_commit_move,
"Time to commit the next move must not be less then ${min}",
("min", minimum_time_per_commit_move));
const uint32_t maximum_time_per_commit_move = d.get_global_properties().parameters.max_time_per_commit_move;
FC_ASSERT(game_options.time_per_commit_move <= maximum_time_per_commit_move,
"Time to commit the next move must not be greater then ${max}",
("max", maximum_time_per_commit_move));
// time_per_commit_reveal constraints
const uint32_t minimum_time_per_reveal_move = d.get_global_properties().parameters.min_time_per_reveal_move;
FC_ASSERT(game_options.time_per_reveal_move >= minimum_time_per_reveal_move,
"Time to reveal the move must not be less then ${min}",
("min", minimum_time_per_reveal_move));
const uint32_t maximum_time_per_reveal_move = d.get_global_properties().parameters.max_time_per_reveal_move;
FC_ASSERT(game_options.time_per_reveal_move <= maximum_time_per_reveal_move,
"Time to reveal the move must not be greater then ${max}",
("max", maximum_time_per_reveal_move));
return void_result();
} FC_CAPTURE_AND_RETHROW( (op) ) }