Closed acoutts closed 6 years ago
As far as I know there are only deferred transactions. I think that's what you mean. Only actions can be inline. Can you give an example how are you generating those transactions from contract?
I think this plugin wasn't tested with deferred transactions, so this is probably a necessary change.
As I understand it block_state->block->transactions
contain all transactions, not just deferred ones, right? In that case, I think it would be a better idea to modify existing loop to iterate through block_state->block->transactions
instead of adding another loop. Would be much more efficient.
@sim31 - please feel free to send the pull request with other changes
Ahh, we would need to unpack all the normal transactions then to get tx ids. Not sure if it's worth it, then.
I just submitted https://github.com/eosauthority/eosio-watcher-plugin/pull/6 with the new change
With normal user->user transfers, the action is visible in
block_state->trxs
, but for transactions coming from a smart contract they will not be visible in this area. Originally this code would successfully detect the inline actions and add them to the actions_queue, but because none of the inline transaction IDs were found inblock_state->trxs
when it was checked inon_accepted_block
, the actions were all thrown away and never notified.By looking additionally within
block_state->block->transactions
on each new block, we can see and match on these inline transactions as they have a different pattern than the normal transactions.Specifically, the
block_state->block->transactions->trx
items look like this when it's a normal transaction from a user:And this when it's a transaction sent from a smart contract, where the second array member is the associated transaction ID:
By iterating through all of the
block_state->block->transactions->trx
and checking if they contain a transaction ID, we can narrow down to process only the inline ones.After making these modifications, the watcher plugin now catches all actions including the inline ones, so this can now be used to watch actions coming out of a smart contract.
A better future implementation would be to only loop through the
block_state->block->transactions->trx
items and unpack the transaction data in there to get at the transaction ID from the 'normal' transactions, to prevent having to run two loops on each block.