abstract class ProtocolLogic<T>
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.
<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. |
logger |
val logger: Logger This is where you should log things to. |
progressTracker |
open val progressTracker: ProgressTracker? Override this to provide a ProgressTracker. If one is provided and stepped, the framework will do something helpful with the progress reports. If this protocol is invoked as a sub-protocol of another, then the tracker will be made a child of the current step in the parent. If its null, this protocol doesnt track progress. |
psm |
lateinit var psm: ProtocolStateMachine<*> Reference to the Fiber instance that is the top level controller for the entire flow. |
serviceHub |
val serviceHub: ServiceHub Provides access to big, heavy classes that may be reconstructed from time to time, e.g. across restarts |
call |
abstract fun call(): T This is where you fill out your business logic. |
receive |
fun <T : Any> receive(topic: String, sessionIDForReceive: Long): UntrustworthyData<T> |
send |
fun send(topic: String, destination: MessageRecipients, sessionID: Long, obj: Any): Unit |
sendAndReceive |
fun <T : Any> sendAndReceive(topic: String, destination: MessageRecipients, sessionIDForSend: Long, sessionIDForReceive: Long, obj: Any): UntrustworthyData<T> |
subProtocol |
fun <R> subProtocol(subLogic: ProtocolLogic<R>): R Invokes the given subprotocol by simply passing through this ProtocolLogics reference to the ProtocolStateMachine and then calling the call method. |
Buyer |
class Buyer : ProtocolLogic<SignedTransaction> |
FetchDataProtocol |
abstract class FetchDataProtocol<T : NamedByHash, W : Any> : ProtocolLogic<Result<T>> An abstract protocol for fetching typed data from a remote peer. |
ResolveTransactionsProtocol |
class ResolveTransactionsProtocol : ProtocolLogic<Unit> This protocol fetches each transaction identified by the given hashes from either disk or network, along with all their dependencies, and verifies them together using a single TransactionGroup. If no exception is thrown, then all the transactions have been successfully verified and inserted into the local database. |
Seller |
class Seller : ProtocolLogic<SignedTransaction> |
TimestampingProtocol |
class TimestampingProtocol : ProtocolLogic<LegallyIdentifiable> The TimestampingProtocol class is the client code that talks to a NodeTimestamperService on some remote node. It is a ProtocolLogic, meaning it can either be a sub-protocol of some other protocol, or be driven independently. |
TraderDemoProtocolBuyer |
class TraderDemoProtocolBuyer : ProtocolLogic<Unit> |
TraderDemoProtocolSeller |
class TraderDemoProtocolSeller : ProtocolLogic<Unit> |