From da4bf0adc296d837acdcdc65c7bb5f6566e5840a Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Tue, 23 Jun 2015 10:33:11 -0400 Subject: [PATCH] Issue #67 - add name/url to worker create operation --- libraries/chain/include/graphene/chain/config.hpp | 3 +++ libraries/chain/include/graphene/chain/operations.hpp | 4 +++- libraries/chain/operations.cpp | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libraries/chain/include/graphene/chain/config.hpp b/libraries/chain/include/graphene/chain/config.hpp index e594a7f5..757582b0 100644 --- a/libraries/chain/include/graphene/chain/config.hpp +++ b/libraries/chain/include/graphene/chain/config.hpp @@ -86,6 +86,9 @@ #define GRAPHENE_DEFAULT_MAX_ASSERT_OPCODE 1 #define GRAPHENE_GENESIS_TIMESTAMP (1431700000) /// Should be divisible by GRAPHENE_DEFAULT_BLOCK_INTERVAL +#define GRAPHENE_MAX_WORKER_NAME_LENGTH 63 +#define GRAPHENE_MAX_WORKER_URL_LENGTH 127 + // counter initialization values used to derive near and far future seeds for shuffling witnesses // we use the fractional bits of sqrt(2) in hex #define GRAPHENE_NEAR_SCHEDULE_CTR_IV ( (uint64_t( 0x6a09 ) << 0x30) \ diff --git a/libraries/chain/include/graphene/chain/operations.hpp b/libraries/chain/include/graphene/chain/operations.hpp index 05187a10..f6bf79ab 100644 --- a/libraries/chain/include/graphene/chain/operations.hpp +++ b/libraries/chain/include/graphene/chain/operations.hpp @@ -1305,6 +1305,8 @@ namespace graphene { namespace chain { time_point_sec work_begin_date; time_point_sec work_end_date; share_type daily_pay; + string name; + string url; /// This should be set to the initializer appropriate for the type of worker to be created. worker_initializer initializer; @@ -1613,7 +1615,7 @@ FC_REFLECT( graphene::chain::vesting_balance_create_operation, (fee)(creator)(ow FC_REFLECT( graphene::chain::vesting_balance_withdraw_operation, (fee)(vesting_balance)(owner)(amount) ) FC_REFLECT( graphene::chain::worker_create_operation, - (fee)(owner)(work_begin_date)(work_end_date)(daily_pay)(initializer) ) + (fee)(owner)(work_begin_date)(work_end_date)(daily_pay)(name)(url)(initializer) ) FC_REFLECT( graphene::chain::custom_operation, (fee)(payer)(required_auths)(id)(data) ) FC_REFLECT( graphene::chain::assert_operation, (fee)(fee_paying_account)(predicates)(required_auths) ) diff --git a/libraries/chain/operations.cpp b/libraries/chain/operations.cpp index 6167f17d..063ce897 100644 --- a/libraries/chain/operations.cpp +++ b/libraries/chain/operations.cpp @@ -778,6 +778,8 @@ void worker_create_operation::validate() const FC_ASSERT(work_end_date > work_begin_date); FC_ASSERT(daily_pay > 0); FC_ASSERT(daily_pay < GRAPHENE_BLOCKCHAIN_MAX_SHARES); + FC_ASSERT(name.size() < GRAPHENE_MAX_WORKER_NAME_LENGTH ); + FC_ASSERT(url.size() < GRAPHENE_MAX_WORKER_URL_LENGTH ); } share_type worker_create_operation::calculate_fee(const fee_schedule_type& k) const