In substrate node template we can see that blocks are producing and finalizing if no transaction happening so how I can make my node to only generate blocks when there are transactions happening.
-
2Same question, but without an accepted answer. substrate.stackexchange.com/questions/1783/…– AurevoirXavierNov 16, 2022 at 3:06
-
Some resources that you can refer about Instant Seal + youtube.com/watch?v=uhkV0jAcWDY + substrate.recipes/kitchen-node.html + Configure service in Moonbeam– CocDapNov 16, 2022 at 7:08
-
i noticed that if you use --dev option it does not generate blocks until other validators show up or you cast a transaction so that might be usefull for you to dig more how that works because you will understand the code more yourself in depth– dadzerlazeNov 16, 2022 at 10:14
1 Answer
There are two consensus (or "block authoring" --whichever you prefer to call them) algorithms that might be exactly what you need:
1- Manual seal: Where there is one author and it authors a block whenever you tell it via an RPC call.
2- Instant seal: Where there is one author and it attempts to author a block as soon as it sees a transaction in the pool, most often leading to one transaction per block
There is a substrate seminar where they build a substrate node that uses manual seal and instant seal consensus.