|
5 | 5 | #include <golos/protocol/get_config.hpp> |
6 | 6 | #include <golos/protocol/exceptions.hpp> |
7 | 7 | #include <golos/chain/operation_notification.hpp> |
| 8 | +#include <golos/api/block_objects.hpp> |
8 | 9 |
|
9 | 10 | #include <fc/smart_ref_impl.hpp> |
10 | 11 |
|
|
15 | 16 |
|
16 | 17 | namespace golos { namespace plugins { namespace database_api { |
17 | 18 |
|
| 19 | +using golos::api::annotated_signed_block; |
| 20 | +using golos::api::block_operations; |
18 | 21 |
|
19 | 22 | template<typename arg> |
20 | 23 | struct callback_info { |
@@ -49,31 +52,6 @@ using pending_tx_callback_info = callback_info<const signed_transaction&>; |
49 | 52 | using pending_tx_callback = pending_tx_callback_info::callback_t; |
50 | 53 |
|
51 | 54 |
|
52 | | -// block_operation used in block_applied_callback to represent virtual operations. |
53 | | -// default operation type have no position info (trx, op_in_trx) |
54 | | -struct block_operation { |
55 | | - block_operation(const operation_notification& o) : |
56 | | - trx_in_block(o.trx_in_block), |
57 | | - op_in_trx(o.op_in_trx), |
58 | | - virtual_op(o.virtual_op), |
59 | | - op(o.op) {}; |
60 | | - |
61 | | - uint32_t trx_in_block = 0; |
62 | | - uint16_t op_in_trx = 0; |
63 | | - uint32_t virtual_op = 0; |
64 | | - operation op; |
65 | | -}; |
66 | | - |
67 | | -using block_operations = std::vector<block_operation>; |
68 | | - |
69 | | -struct block_with_vops : public signed_block { |
70 | | - block_with_vops(signed_block b, block_operations ops): signed_block(b), _virtual_operations(ops) { |
71 | | - }; |
72 | | - |
73 | | - // name field starting with _ coz it's not directly related to block |
74 | | - block_operations _virtual_operations; |
75 | | -}; |
76 | | - |
77 | 55 | struct virtual_operations { |
78 | 56 | virtual_operations(uint32_t block_num, block_operations ops): block_num(block_num), operations(ops) { |
79 | 57 | }; |
@@ -243,7 +221,7 @@ DEFINE_API(plugin, set_block_applied_callback) { |
243 | 221 | r = fc::variant(virtual_operations(block.block_num(), my->get_block_vops())); |
244 | 222 | break; |
245 | 223 | case full: |
246 | | - r = fc::variant(block_with_vops(block, my->get_block_vops())); |
| 224 | + r = fc::variant(annotated_signed_block(block, my->get_block_vops())); |
247 | 225 | break; |
248 | 226 | default: |
249 | 227 | break; |
@@ -926,9 +904,5 @@ void plugin::plugin_startup() { |
926 | 904 | } } } // golos::plugins::database_api |
927 | 905 |
|
928 | 906 | FC_REFLECT((golos::plugins::database_api::virtual_operations), (block_num)(operations)) |
929 | | -FC_REFLECT((golos::plugins::database_api::block_operation), |
930 | | - (trx_in_block)(op_in_trx)(virtual_op)(op)) |
931 | | -FC_REFLECT_DERIVED((golos::plugins::database_api::block_with_vops), ((golos::protocol::signed_block)), |
932 | | - (_virtual_operations)) |
933 | 907 | FC_REFLECT_ENUM(golos::plugins::database_api::block_applied_callback_result_type, |
934 | 908 | (block)(header)(virtual_ops)(full)) |
0 commit comments