Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
account_object.hpp
Go to the documentation of this file.
1#pragma once
7
9
10namespace sysio { namespace chain {
11
12 class account_object : public chainbase::object<account_object_type, account_object> {
14
15 id_type id;
16 account_name name; //< name should not be changed within a chainbase modifier lambda
17 block_timestamp_type creation_date;
18 shared_blob abi;
19
20 void set_abi( const sysio::chain::abi_def& a ) {
21 abi.resize_and_fill( fc::raw::pack_size( a ), [&a](char* data, std::size_t size) {
22 fc::datastream<char*> ds( data, size );
23 fc::raw::pack( ds, a );
24 });
25 }
26
27 sysio::chain::abi_def get_abi()const {
29 SYS_ASSERT( abi.size() != 0, abi_not_found_exception, "No ABI set on account ${n}", ("n",name) );
30
31 fc::datastream<const char*> ds( abi.data(), abi.size() );
32 fc::raw::unpack( ds, a );
33 return a;
34 }
35 };
37
38 struct by_name;
41 indexed_by<
42 ordered_unique<tag<by_id>, member<account_object, account_object::id_type, &account_object::id>>,
43 ordered_unique<tag<by_name>, member<account_object, account_name, &account_object::name>>
44 >
45 >;
46
47 class account_metadata_object : public chainbase::object<account_metadata_object_type, account_metadata_object>
48 {
50
51 enum class flags_fields : uint32_t {
52 privileged = 1
53 };
54
55 id_type id;
56 account_name name; //< name should not be changed within a chainbase modifier lambda
57 uint64_t recv_sequence = 0;
58 uint64_t auth_sequence = 0;
59 uint64_t code_sequence = 0;
60 uint64_t abi_sequence = 0;
61 digest_type code_hash;
62 time_point last_code_update;
63 uint32_t flags = 0;
64 uint8_t vm_type = 0;
65 uint8_t vm_version = 0;
66
67 bool is_privileged()const { return has_field( flags, flags_fields::privileged ); }
68
69 void set_privileged( bool privileged ) {
70 flags = set_field( flags, flags_fields::privileged, privileged );
71 }
72 };
73
74 struct by_name;
77 indexed_by<
78 ordered_unique<tag<by_id>, member<account_metadata_object, account_metadata_object::id_type, &account_metadata_object::id>>,
79 ordered_unique<tag<by_name>, member<account_metadata_object, account_name, &account_metadata_object::name>>
80 >
81 >;
82
83 class account_ram_correction_object : public chainbase::object<account_ram_correction_object_type, account_ram_correction_object>
84 {
86
87 id_type id;
88 account_name name; //< name should not be changed within a chainbase modifier lambda
89 uint64_t ram_correction = 0;
90 };
91
92 struct by_name;
95 indexed_by<
96 ordered_unique<tag<by_id>, member<account_ram_correction_object, account_ram_correction_object::id_type, &account_ram_correction_object::id>>,
97 ordered_unique<tag<by_name>, member<account_ram_correction_object, account_name, &account_ram_correction_object::name>>
98 >
99 >;
100
101} } // sysio::chain
102
106
107FC_REFLECT(sysio::chain::account_object, (name)(creation_date)(abi))
108FC_REFLECT(sysio::chain::account_metadata_object, (name)(recv_sequence)(auth_sequence)(code_sequence)(abi_sequence)
109 (code_hash)(last_code_update)(flags)(vm_type)(vm_version))
std::string name
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
Definition exceptions.hpp:7
#define OBJECT_CTOR(...)
Definition types.hpp:39
#define CHAINBASE_SET_INDEX_TYPE(OBJECT_TYPE, INDEX_TYPE)
void resize_and_fill(std::size_t new_size, F &&f)
boost::multi_index_container< Object, Args..., chainbase::node_allocator< Object > > shared_multi_index_container
void unpack(Stream &s, std::deque< T > &value)
Definition raw.hpp:540
void pack(Stream &s, const std::deque< T > &value)
Definition raw.hpp:531
size_t pack_size(const T &v)
Definition raw.hpp:671
chainbase::shared_multi_index_container< account_object, indexed_by< ordered_unique< tag< by_id >, member< account_object, account_object::id_type, &account_object::id > >, ordered_unique< tag< by_name >, member< account_object, account_name, &account_object::name > > > > account_index
chainbase::shared_multi_index_container< account_ram_correction_object, indexed_by< ordered_unique< tag< by_id >, member< account_ram_correction_object, account_ram_correction_object::id_type, &account_ram_correction_object::id > >, ordered_unique< tag< by_name >, member< account_ram_correction_object, account_name, &account_ram_correction_object::name > > > > account_ram_correction_index
chainbase::shared_multi_index_container< account_metadata_object, indexed_by< ordered_unique< tag< by_id >, member< account_metadata_object, account_metadata_object::id_type, &account_metadata_object::id > >, ordered_unique< tag< by_name >, member< account_metadata_object, account_name, &account_metadata_object::name > > > > account_metadata_index
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition reflect.hpp:311
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
Immutable except for fc::from_variant.
Definition name.hpp:43
pInfo flags