From 897dbaf5843a0d577f9835d0183432debde96d8b Mon Sep 17 00:00:00 2001 From: Nathan Hourt Date: Thu, 6 Apr 2017 14:53:58 -0500 Subject: [PATCH] Resolve #1: Replace operations with messages I've already removed operations from the system; in this commit I add a new message type and integrate it into the transaction type. --- libraries/chain/include/eos/chain/message.hpp | 32 +++++++++++++++++++ .../eos/chain/protocol/transaction.hpp | 4 ++- .../include/eos/chain/protocol/types.hpp | 7 ++-- 3 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 libraries/chain/include/eos/chain/message.hpp diff --git a/libraries/chain/include/eos/chain/message.hpp b/libraries/chain/include/eos/chain/message.hpp new file mode 100644 index 000000000..b693901a8 --- /dev/null +++ b/libraries/chain/include/eos/chain/message.hpp @@ -0,0 +1,32 @@ +#pragma once + +#include + +namespace eos { namespace chain { + +/** + * @brief The message struct defines a blockchain message + * + * Messages are the heart of all activity on the blockchain -- all events and actions which take place in the chain are + * recorded as messages. Messages are sent from one account (@ref sender) to another account (@ref recipient), and are + * optionally also delivered to several other accounts (@ref notify_accounts). + * + * A message has a header that defines who sent it and who will be processing it. The message content is a binary blob, + * @ref data, whose type is determined by @ref type, which is dynamic and defined by the scripting language. + */ +struct message { + /// The account which sent the message + account sender; + /// The account to receive the message + account recipient; + /// Other accounts to notify about this message + vector 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 + vector data; +}; + +} } // namespace eos::chain + +FC_REFLECT(eos::chain::message, (sender)(recipient)(notify_accounts)(type)(data)) diff --git a/libraries/chain/include/eos/chain/protocol/transaction.hpp b/libraries/chain/include/eos/chain/protocol/transaction.hpp index e7c40d980..2e9a965eb 100644 --- a/libraries/chain/include/eos/chain/protocol/transaction.hpp +++ b/libraries/chain/include/eos/chain/protocol/transaction.hpp @@ -23,6 +23,7 @@ */ #pragma once #include +#include #include @@ -81,7 +82,8 @@ namespace eos { namespace chain { */ fc::time_point_sec expiration; - vector messages; + /// The messages in this transaction + vector messages; /// Calculate the digest for a transaction digest_type digest()const; diff --git a/libraries/chain/include/eos/chain/protocol/types.hpp b/libraries/chain/include/eos/chain/protocol/types.hpp index 57a039b1c..cfa7375d2 100644 --- a/libraries/chain/include/eos/chain/protocol/types.hpp +++ b/libraries/chain/include/eos/chain/protocol/types.hpp @@ -90,8 +90,11 @@ namespace eos { namespace chain { using chainbase::allocator; using shared_string = boost::interprocess::basic_string, allocator>; - typedef fc::ecc::private_key private_key_type; - typedef fc::sha256 chain_id_type; + using private_key_type = fc::ecc::private_key; + using chain_id_type = fc::sha256; + + using account = std::string; + using message_type = std::string; /** * List all object types from all namespaces here so they can -- GitLab