Skip to content

Commit

Permalink
Merge pull request #1676 from bitshares/vop-numbering
Browse files Browse the repository at this point in the history
Apply deterministic virtual_op numbering rule
  • Loading branch information
pmconrad authored Apr 10, 2019
2 parents e44cd00 + da6c386 commit 860d241
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions libraries/chain/db_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,12 @@ void database::_apply_block( const signed_block& next_block )
const auto& dynamic_global_props = get_dynamic_global_properties();
bool maint_needed = (dynamic_global_props.next_maintenance_time <= next_block.timestamp);

// trx_in_block starts from 0.
// For real operations which are explicitly included in a transaction, op_in_trx starts from 0, virtual_op is 0.
// For virtual operations that are derived directly from a real operation,
// use the real operation's (block_num,trx_in_block,op_in_trx), virtual_op starts from 1.
// For virtual operations created after processed all transactions,
// trx_in_block = the_block.trsanctions.size(), op_in_trx is 0, virtual_op starts from 0.
_current_block_num = next_block_num;
_current_trx_in_block = 0;

Expand All @@ -569,6 +575,9 @@ void database::_apply_block( const signed_block& next_block )
++_current_trx_in_block;
}

_current_op_in_trx = 0;
_current_virtual_op = 0;

const uint32_t missed = update_witness_missed_blocks( next_block );
update_global_dynamic_data( next_block, missed );
update_signing_witness(signing_witness, next_block);
Expand Down Expand Up @@ -680,6 +689,7 @@ processed_transaction database::_apply_transaction(const signed_transaction& trx
_current_op_in_trx = 0;
for( const auto& op : ptrx.operations )
{
_current_virtual_op = 0;
eval_state.operation_results.emplace_back(apply_operation(eval_state, op));
++_current_op_in_trx;
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/graphene/chain/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
#define GRAPHENE_RECENTLY_MISSED_COUNT_INCREMENT 4
#define GRAPHENE_RECENTLY_MISSED_COUNT_DECREMENT 3

#define GRAPHENE_CURRENT_DB_VERSION "20190323"
#define GRAPHENE_CURRENT_DB_VERSION "20190403"

#define GRAPHENE_IRREVERSIBLE_THRESHOLD (70 * GRAPHENE_1_PERCENT)

Expand Down
2 changes: 1 addition & 1 deletion libraries/chain/include/graphene/chain/database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ namespace graphene { namespace chain {
uint32_t _current_block_num = 0;
uint16_t _current_trx_in_block = 0;
uint16_t _current_op_in_trx = 0;
uint16_t _current_virtual_op = 0;
uint32_t _current_virtual_op = 0;

vector<uint64_t> _vote_tally_buffer;
vector<uint64_t> _witness_count_histogram_buffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace graphene { namespace chain {
/** the operation within the transaction */
uint16_t op_in_trx = 0;
/** any virtual operations implied by operation in block */
uint16_t virtual_op = 0;
uint32_t virtual_op = 0;
};

/**
Expand Down

0 comments on commit 860d241

Please sign in to comment.