core.protocols / ProtocolLogic / <init>

# <init>

`ProtocolLogic()`

A sub-class of ProtocolLogic implements a protocol flow using direct, straight line blocking code. Thus you can write complex protocol logic in an ordinary fashion, without having to think about callbacks, restarting after a node crash, how many instances of your protocol there are running and so on.

Invoking the network will cause the call stack to be suspended onto the heap and then serialized to a database using the Quasar fibers framework. Because of this, if you need access to data that might change over time, you should request it just-in-time via the serviceHub property which is provided. Dont try and keep data you got from a service across calls to send/receive/sendAndReceive because the world might change in arbitrary ways out from underneath you, for instance, if the node is restarted or reconfigured

Additionally, be aware of what data you pin either via the stack or in your ProtocolLogic implementation. Very large objects or datasets will hurt performance by increasing the amount of data stored in each checkpoint.

If youd like to use another ProtocolLogic class as a component of your own, construct it on the fly and then pass it to the subProtocol method. It will return the result of that protocol when it completes.