Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
transaction_metadata.hpp
Go to the documentation of this file.
1#pragma once
4#include <boost/asio/io_context.hpp>
5#include <future>
6
7namespace boost { namespace asio {
8 class thread_pool;
9}}
10
11namespace sysio { namespace chain {
12
13class transaction_metadata;
14using transaction_metadata_ptr = std::shared_ptr<transaction_metadata>;
15using recover_keys_future = std::future<transaction_metadata_ptr>;
16
22 public:
23 enum class trx_type {
24 input,
28 };
29
30 private:
31 const packed_transaction_ptr _packed_trx;
32 const fc::microseconds _sig_cpu_usage;
33 const flat_set<public_key_type> _recovered_pub_keys;
34
35 public:
36 const bool implicit;
37 const bool scheduled;
38 const bool read_only;
39 bool accepted = false; // not thread safe
40 uint32_t billed_cpu_time_us = 0; // not thread safe
41
42 private:
43 struct private_type{};
44
45 static void check_variable_sig_size(const packed_transaction_ptr& trx, uint32_t max) {
46 for(const signature_type& sig : trx->get_signed_transaction().signatures)
47 SYS_ASSERT(sig.variable_size() <= max, sig_variable_size_limit_exception,
48 "signature variable length component size (${s}) greater than subjective maximum (${m})", ("s", sig.variable_size())("m", max));
49 }
50
51 public:
52 // creation of tranaction_metadata restricted to start_recover_keys and create_no_recover_keys below, public for make_shared
53 explicit transaction_metadata( const private_type& pt, packed_transaction_ptr ptrx,
54 fc::microseconds sig_cpu_usage, flat_set<public_key_type> recovered_pub_keys,
55 bool _implicit = false, bool _scheduled = false, bool _read_only = false)
56 : _packed_trx( std::move( ptrx ) )
57 , _sig_cpu_usage( sig_cpu_usage )
58 , _recovered_pub_keys( std::move( recovered_pub_keys ) )
59 , implicit( _implicit )
60 , scheduled( _scheduled )
61 , read_only( _read_only) {
62 }
63
69
70
71 const packed_transaction_ptr& packed_trx()const { return _packed_trx; }
72 const transaction_id_type& id()const { return _packed_trx->id(); }
73 fc::microseconds signature_cpu_usage()const { return _sig_cpu_usage; }
74 const flat_set<public_key_type>& recovered_keys()const { return _recovered_pub_keys; }
75 size_t get_estimated_size() const;
76
80 start_recover_keys( packed_transaction_ptr trx, boost::asio::io_context& thread_pool,
81 const chain_id_type& chain_id, fc::microseconds time_limit,
82 trx_type t, uint32_t max_variable_sig_size = UINT32_MAX );
83
87 return std::make_shared<transaction_metadata>( private_type(), std::move(trx),
88 fc::microseconds(), flat_set<public_key_type>(), t == trx_type::implicit, t == trx_type::scheduled, t==trx_type::read_only );
89 }
90
91};
92
93} } // sysio::chain
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
static recover_keys_future start_recover_keys(packed_transaction_ptr trx, boost::asio::io_context &thread_pool, const chain_id_type &chain_id, fc::microseconds time_limit, trx_type t, uint32_t max_variable_sig_size=UINT32_MAX)
transaction_metadata(const transaction_metadata &)=delete
transaction_metadata(const private_type &pt, packed_transaction_ptr ptrx, fc::microseconds sig_cpu_usage, flat_set< public_key_type > recovered_pub_keys, bool _implicit=false, bool _scheduled=false, bool _read_only=false)
fc::microseconds signature_cpu_usage() const
const packed_transaction_ptr & packed_trx() const
const transaction_id_type & id() const
const flat_set< public_key_type > & recovered_keys() const
transaction_metadata operator=(transaction_metadata &&)=delete
transaction_metadata(transaction_metadata &&)=delete
transaction_metadata operator=(transaction_metadata &)=delete
static transaction_metadata_ptr create_no_recover_keys(packed_transaction_ptr trx, trx_type t)
Definition name.hpp:106
std::future< transaction_metadata_ptr > recover_keys_future
std::shared_ptr< const packed_transaction > packed_transaction_ptr
std::shared_ptr< transaction_metadata > transaction_metadata_ptr
unsigned int uint32_t
Definition stdint.h:126
#define UINT32_MAX
Definition stdint.h:188