Implement witness_update_operation #258
This commit is contained in:
parent
19d10e462c
commit
7db477b9d7
7 changed files with 76 additions and 3 deletions
|
|
@ -92,7 +92,14 @@ struct get_impacted_account_visitor
|
||||||
void operator()( const asset_settle_operation& op ) {}
|
void operator()( const asset_settle_operation& op ) {}
|
||||||
void operator()( const asset_global_settle_operation& op ) {}
|
void operator()( const asset_global_settle_operation& op ) {}
|
||||||
void operator()( const asset_publish_feed_operation& op ) {}
|
void operator()( const asset_publish_feed_operation& op ) {}
|
||||||
void operator()( const witness_create_operation& op ) {}
|
void operator()( const witness_create_operation& op )
|
||||||
|
{
|
||||||
|
_impacted.insert( op.witness_account );
|
||||||
|
}
|
||||||
|
void operator()( const witness_update_operation& op )
|
||||||
|
{
|
||||||
|
_impacted.insert( op.witness_account );
|
||||||
|
}
|
||||||
|
|
||||||
void operator()( const proposal_create_operation& op )
|
void operator()( const proposal_create_operation& op )
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -139,9 +139,10 @@ void database::initialize_evaluators()
|
||||||
register_evaluator<proposal_create_evaluator>();
|
register_evaluator<proposal_create_evaluator>();
|
||||||
register_evaluator<proposal_update_evaluator>();
|
register_evaluator<proposal_update_evaluator>();
|
||||||
register_evaluator<proposal_delete_evaluator>();
|
register_evaluator<proposal_delete_evaluator>();
|
||||||
register_evaluator<witness_create_evaluator>();
|
|
||||||
register_evaluator<vesting_balance_create_evaluator>();
|
register_evaluator<vesting_balance_create_evaluator>();
|
||||||
register_evaluator<vesting_balance_withdraw_evaluator>();
|
register_evaluator<vesting_balance_withdraw_evaluator>();
|
||||||
|
register_evaluator<witness_create_evaluator>();
|
||||||
|
register_evaluator<witness_update_evaluator>();
|
||||||
register_evaluator<withdraw_permission_create_evaluator>();
|
register_evaluator<withdraw_permission_create_evaluator>();
|
||||||
register_evaluator<withdraw_permission_claim_evaluator>();
|
register_evaluator<withdraw_permission_claim_evaluator>();
|
||||||
register_evaluator<withdraw_permission_update_evaluator>();
|
register_evaluator<withdraw_permission_update_evaluator>();
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ namespace graphene { namespace chain {
|
||||||
asset_global_settle_operation,
|
asset_global_settle_operation,
|
||||||
asset_publish_feed_operation,
|
asset_publish_feed_operation,
|
||||||
witness_create_operation,
|
witness_create_operation,
|
||||||
|
witness_update_operation,
|
||||||
proposal_create_operation,
|
proposal_create_operation,
|
||||||
proposal_update_operation,
|
proposal_update_operation,
|
||||||
proposal_delete_operation,
|
proposal_delete_operation,
|
||||||
|
|
|
||||||
|
|
@ -25,10 +25,37 @@ namespace graphene { namespace chain {
|
||||||
void validate()const;
|
void validate()const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Update a witness object's URL and block signing key.
|
||||||
|
* @ingroup operations
|
||||||
|
*/
|
||||||
|
struct witness_update_operation : public base_operation
|
||||||
|
{
|
||||||
|
struct fee_parameters_type
|
||||||
|
{
|
||||||
|
share_type fee = 20 * GRAPHENE_BLOCKCHAIN_PRECISION;
|
||||||
|
};
|
||||||
|
|
||||||
|
asset fee;
|
||||||
|
/// The witness object to update.
|
||||||
|
witness_id_type witness;
|
||||||
|
/// The account which owns the witness. This account pays the fee for this operation.
|
||||||
|
account_id_type witness_account;
|
||||||
|
/// The new URL.
|
||||||
|
optional< string > new_url;
|
||||||
|
/// The new block signing key.
|
||||||
|
optional< public_key_type > new_signing_key;
|
||||||
|
|
||||||
|
account_id_type fee_payer()const { return witness_account; }
|
||||||
|
void validate()const;
|
||||||
|
};
|
||||||
|
|
||||||
/// TODO: witness_resign_operation : public base_operation
|
/// TODO: witness_resign_operation : public base_operation
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::witness_create_operation::fee_parameters_type, (fee) )
|
FC_REFLECT( graphene::chain::witness_create_operation::fee_parameters_type, (fee) )
|
||||||
|
|
||||||
FC_REFLECT( graphene::chain::witness_create_operation, (fee)(witness_account)(url)(block_signing_key)(initial_secret) )
|
FC_REFLECT( graphene::chain::witness_create_operation, (fee)(witness_account)(url)(block_signing_key)(initial_secret) )
|
||||||
|
|
||||||
|
FC_REFLECT( graphene::chain::witness_update_operation::fee_parameters_type, (fee) )
|
||||||
|
FC_REFLECT( graphene::chain::witness_update_operation, (fee)(witness)(witness_account)(new_url)(new_signing_key) )
|
||||||
|
|
|
||||||
|
|
@ -30,4 +30,13 @@ namespace graphene { namespace chain {
|
||||||
object_id_type do_apply( const witness_create_operation& o );
|
object_id_type do_apply( const witness_create_operation& o );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class witness_update_evaluator : public evaluator<witness_update_evaluator>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef witness_update_operation operation_type;
|
||||||
|
|
||||||
|
void_result do_evaluate( const witness_update_operation& o );
|
||||||
|
void_result do_apply( const witness_update_operation& o );
|
||||||
|
};
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,11 @@ void witness_create_operation::validate() const
|
||||||
FC_ASSERT(url.size() < GRAPHENE_MAX_URL_LENGTH );
|
FC_ASSERT(url.size() < GRAPHENE_MAX_URL_LENGTH );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void witness_update_operation::validate() const
|
||||||
|
{
|
||||||
|
FC_ASSERT(fee.amount >= 0);
|
||||||
|
if( new_url.valid() )
|
||||||
|
FC_ASSERT(new_url->size() < GRAPHENE_MAX_URL_LENGTH );
|
||||||
|
}
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
|
|
@ -47,4 +47,25 @@ object_id_type witness_create_evaluator::do_apply( const witness_create_operatio
|
||||||
return new_witness_object.id;
|
return new_witness_object.id;
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
|
void_result witness_update_evaluator::do_evaluate( const witness_update_operation& op )
|
||||||
|
{ try {
|
||||||
|
FC_ASSERT(db().get(op.witness).witness_account == op.witness_account);
|
||||||
|
return void_result();
|
||||||
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
|
void_result witness_update_evaluator::do_apply( const witness_update_operation& op )
|
||||||
|
{ try {
|
||||||
|
database& _db = db();
|
||||||
|
_db.modify(
|
||||||
|
_db.get(op.witness),
|
||||||
|
[&]( witness_object& wit )
|
||||||
|
{
|
||||||
|
if( op.new_url.valid() )
|
||||||
|
wit.url = *op.new_url;
|
||||||
|
if( op.new_signing_key.valid() )
|
||||||
|
wit.signing_key = *op.new_signing_key;
|
||||||
|
});
|
||||||
|
return void_result();
|
||||||
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||||
|
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue