Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Progress #2: Define types
Browse files Browse the repository at this point in the history
Add structs and types to facilitate the explicitly declared authority
level described in issue #2.

May or may not be revisiting this to tweak it later... :P
  • Loading branch information
nathanielhourt committed Apr 11, 2017
1 parent 7584ca2 commit 7836ec1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
6 changes: 3 additions & 3 deletions libraries/chain/include/eos/chain/message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ namespace eos { namespace chain {
*/
struct message {
/// The account which sent the message
account sender;
account_name sender;
/// The account to receive the message
account recipient;
account_name recipient;
/// Other accounts to notify about this message
vector<account> notify_accounts;
vector<account_name> notify_accounts;
/// The message type -- this is defined by the contract(s) which create and/or process this message
message_type type;
/// The message contents
Expand Down
43 changes: 39 additions & 4 deletions libraries/chain/include/eos/chain/protocol/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,15 @@ namespace eos { namespace chain {
struct transaction
{
/**
* Least significant 16 bits from the reference block number. If @ref relative_expiration is zero, this field
* must be zero as well.
* Least significant 16 bits from the reference block number.
*/
uint16_t ref_block_num = 0;
uint16_t ref_block_num = 0;
/**
* The first non-block-number 32-bits of the reference block ID. Recall that block IDs have 32 bits of block
* number followed by the actual block hash, so this field should be set using the second 32 bits in the
* @ref block_id_type
*/
uint32_t ref_block_prefix = 0;
uint32_t ref_block_prefix = 0;

/**
* This field specifies the absolute expiration for this transaction.
Expand All @@ -96,6 +95,27 @@ namespace eos { namespace chain {
void set_reference_block( const block_id_type& reference_block );
};

/**
* @brief A single authorization used to authorize a transaction
*
* Transactions may have several accounts that must authorize them before they may be evaluated. Each of those
* accounts has several different authority levels, some of which may be sufficient to authorize the transaction in
* question and some of which may not. This struct records an account, an the authority level on that account, that
* must/did authorize a transaction.
*
* Objects of this struct shall be added to a @ref signed_transaction when it is being signed, to declare that a
* given account/authority level has approved the transaction. These permissions will then be checked by blockchain
* nodes, when receiving the transaction over the network, to verify that the transaction bears signatures
* corresponding to all of the permissions it declares. Finally, when processing the transaction in context with
* blockchain state, it will be verified that the transaction declared all of the appropriate permissions.
*/
struct authorization {
/// The account authorizing the transaction
account_name authorizing_account;
/// The privileges being invoked to authorize the transaction
privilege_class level;
};

/**
* @brief adds a signature to a transaction
*/
Expand All @@ -112,7 +132,22 @@ namespace eos { namespace chain {

flat_set<public_key_type> get_signature_keys( const chain_id_type& chain_id )const;

/**
* @brief This is the list of signatures that are provided for this transaction
*
* These should roughly parallel @ref provided_authorizations below. It is possible that two authorizations may
* use the same key, however, in which case there would be a single signature for multiple authorizations.
*/
vector<signature_type> signatures;
/**
* @brief This is the list of authorizations that are provided for this transaction
*
* Note that this is NOT the set of authorizations that are <i>required</i> for the transaction! The difference
* is subtle since for a properly authorized transaction, the provided authorizations are the required
* authorizations, but in practice it must be verified that the provided_authorizations are sufficient to fully
* authorize the transaction.
*/
vector<authorization> provided_authorizations;

/// Removes all messages and signatures
void clear() { messages.clear(); signatures.clear(); }
Expand Down
3 changes: 2 additions & 1 deletion libraries/chain/include/eos/chain/protocol/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ namespace eos { namespace chain {
using private_key_type = fc::ecc::private_key;
using chain_id_type = fc::sha256;

using account = std::string;
using account_name = std::string;
using message_type = std::string;
using privilege_class = std::string;

/**
* List all object types from all namespaces here so they can
Expand Down

0 comments on commit 7836ec1

Please sign in to comment.