lisk-docs icon indicating copy to clipboard operation
lisk-docs copied to clipboard

New guide: How to utilize lifecycle hooks to perform state changes per block

Open Tschakki opened this issue 3 years ago • 0 comments

Description

How to change the chain state & account state without a transaction. With the the beforeblockapply and afterblockapply lifecycle hooks, it can be also executed per block.

Additional information

Maybe we can provide more examples of useful usages of the different lifecycle hooks, e.g. for afterBlockApply() and beforeBlockApply(), and include there an example, which makes a computation based on data off all transaction included in a block


"Hey folks! I want your opinion. In my module the afterBlockApply() lifecycle hook is supposed to do a set of computations when there were 1...n of the module's transactions in this block included. I am thinking about a ""good"" pattern to do this - do you have an opinion? I could of course define a variable in my module's class and create a reducer to modify it - each of the module's transactions can then call that reducer and set this variable to toBeProcessedAfterBlockApply. And the lifecycle hook acts on this variable's state... But could it be done in a ""more lisk-native"" way?"

Tschakki avatar Nov 10 '21 12:11 Tschakki