Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio::chain::transaction Struct Reference

#include <transaction.hpp>

Inheritance diagram for sysio::chain::transaction:
Collaboration diagram for sysio::chain::transaction:

Public Member Functions

transaction_id_type id () const
 
digest_type sig_digest (const chain_id_type &chain_id, const vector< bytes > &cfd=vector< bytes >()) const
 
fc::microseconds get_signature_keys (const vector< signature_type > &signatures, const chain_id_type &chain_id, fc::time_point deadline, const vector< bytes > &cfd, flat_set< public_key_type > &recovered_pub_keys, bool allow_duplicate_keys=false) const
 
uint32_t total_actions () const
 
account_name first_authorizer () const
 
flat_multimap< uint16_t, transaction_extensionvalidate_and_extract_extensions () const
 
- Public Member Functions inherited from sysio::chain::transaction_header
block_num_type get_ref_blocknum (block_num_type head_blocknum) const
 number of seconds to delay this transaction for during which it may be canceled.
 
void set_reference_block (const block_id_type &reference_block)
 
bool verify_reference_block (const block_id_type &reference_block) const
 
void validate () const
 

Public Attributes

vector< actioncontext_free_actions
 
vector< actionactions
 
extensions_type transaction_extensions
 
- Public Attributes inherited from sysio::chain::transaction_header
time_point_sec expiration
 the time at which a transaction expires
 
uint16_t ref_block_num = 0U
 specifies a block num in the last 2^16 blocks.
 
uint32_t ref_block_prefix = 0UL
 specifies the lower 32 bits of the blockid at get_ref_blocknum
 
fc::unsigned_int max_net_usage_words = 0UL
 
uint8_t max_cpu_usage_ms = 0
 upper limit on total network bandwidth (in 8 byte words) billed for this transaction
 
fc::unsigned_int delay_sec = 0UL
 upper limit on the total CPU time billed for this transaction
 

Detailed Description

A transaction consits of a set of messages which must all be applied or all are rejected. These messages have access to data within the given read and write scopes.

Definition at line 83 of file transaction.hpp.

Member Function Documentation

◆ first_authorizer()

account_name sysio::chain::transaction::first_authorizer ( ) const
inline

Definition at line 99 of file transaction.hpp.

99 {
100 for( const auto& a : actions ) {
101 for( const auto& u : a.authorization )
102 return u.actor;
103 }
104 return account_name();
105 }
name account_name
Definition types.hpp:120
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
vector< action > actions

◆ get_signature_keys()

fc::microseconds sysio::chain::transaction::get_signature_keys ( const vector< signature_type > & signatures,
const chain_id_type & chain_id,
fc::time_point deadline,
const vector< bytes > & cfd,
flat_set< public_key_type > & recovered_pub_keys,
bool allow_duplicate_keys = false ) const

Definition at line 59 of file transaction.cpp.

62{ try {
64 recovered_pub_keys.clear();
65 const digest_type digest = sig_digest(chain_id, cfd);
66
67 for(const signature_type& sig : signatures) {
68 auto now = fc::time_point::now();
69 SYS_ASSERT( now < deadline, tx_cpu_usage_exceeded, "transaction signature verification executed for too long ${time}us",
70 ("time", now - start)("now", now)("deadline", deadline)("start", start) );
71 auto[ itr, successful_insertion ] = recovered_pub_keys.emplace( sig, digest );
72 SYS_ASSERT( allow_duplicate_keys || successful_insertion, tx_duplicate_sig,
73 "transaction includes more than one signature signed using the same key associated with public key: ${key}",
74 ("key", *itr ) );
75 }
76
77 return fc::time_point::now() - start;
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
static time_point now()
Definition time.cpp:14
#define FC_CAPTURE_AND_RETHROW(...)
fc::sha256 digest(const T &value)
Definition digest.hpp:9
checksum_type digest_type
Definition types.hpp:237
fc::crypto::signature signature_type
Definition types.hpp:78
digest_type sig_digest(const chain_id_type &chain_id, const vector< bytes > &cfd=vector< bytes >()) const
Here is the call graph for this function:
Here is the caller graph for this function:

◆ id()

transaction_id_type sysio::chain::transaction::id ( ) const

Definition at line 41 of file transaction.cpp.

41 {
42 digest_type::encoder enc;
43 fc::raw::pack( enc, *this );
44 return enc.result();
45}
void pack(Stream &s, const std::deque< T > &value)
Definition raw.hpp:531
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sig_digest()

digest_type sysio::chain::transaction::sig_digest ( const chain_id_type & chain_id,
const vector< bytes > & cfd = vector<bytes>() ) const

Definition at line 47 of file transaction.cpp.

47 {
48 digest_type::encoder enc;
49 fc::raw::pack( enc, chain_id );
50 fc::raw::pack( enc, *this );
51 if( cfd.size() ) {
53 } else {
54 fc::raw::pack( enc, digest_type() );
55 }
56 return enc.result();
57}
static sha256 hash(const char *d, uint32_t dlen)
Definition sha256.cpp:44
Here is the call graph for this function:
Here is the caller graph for this function:

◆ total_actions()

uint32_t sysio::chain::transaction::total_actions ( ) const
inline

Definition at line 97 of file transaction.hpp.

97{ return context_free_actions.size() + actions.size(); }
vector< action > context_free_actions

◆ validate_and_extract_extensions()

flat_multimap< uint16_t, transaction_extension > sysio::chain::transaction::validate_and_extract_extensions ( ) const

Definition at line 80 of file transaction.cpp.

80 {
82
83 flat_multimap<uint16_t, transaction_extension> results;
84
85 uint16_t id_type_lower_bound = 0;
86
87 for( size_t i = 0; i < transaction_extensions.size(); ++i ) {
88 const auto& e = transaction_extensions[i];
89 auto id = e.first;
90
91 SYS_ASSERT( id >= id_type_lower_bound, invalid_transaction_extension,
92 "Transaction extensions are not in the correct order (ascending id types required)"
93 );
94
95 auto iter = results.emplace(std::piecewise_construct,
96 std::forward_as_tuple(id),
97 std::forward_as_tuple()
98 );
99
100 auto match = decompose_t::extract<transaction_extension>( id, e.second, iter->second );
101 SYS_ASSERT( match, invalid_transaction_extension,
102 "Transaction extension with id type ${id} is not supported",
103 ("id", id)
104 );
105
106 if( match->enforce_unique ) {
107 SYS_ASSERT( i == 0 || id > id_type_lower_bound, invalid_transaction_extension,
108 "Transaction extension with id type ${id} is not allowed to repeat",
109 ("id", id)
110 );
111 }
112
113 id_type_lower_bound = id;
114 }
115
116 return results;
117}
unsigned short uint16_t
Definition stdint.h:125
extensions_type transaction_extensions
transaction_id_type id() const
account_query_db::get_accounts_by_authorizers_result results
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ actions

vector<action> sysio::chain::transaction::actions

Definition at line 85 of file transaction.hpp.

◆ context_free_actions

vector<action> sysio::chain::transaction::context_free_actions

Definition at line 84 of file transaction.hpp.

◆ transaction_extensions

extensions_type sysio::chain::transaction::transaction_extensions

Definition at line 86 of file transaction.hpp.


The documentation for this struct was generated from the following files: