Newer
Older
\section{ActionPrepareDistributedCommitedTransfer}
The clients will reply to a request with an acknowlegment if one of two
cases occur. In the first case the Supervisor (bank) will send FUCoins
to a user. Otherwise the client would need to know the sender, who also
needs to have sufficient funds.
\\
\begin{lstlisting}
protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context,
Wallet wallet) {
// sender is supervisor (bank) and always has funds
boolean granted = sender.compareTo(source) == 0
// sender is unknown, might be valid
||(wallet.amounts.containsKey(source)
// sender have enough money
&&wallet.amounts.getOrDefault(source,0)>=amount);
sender.tell(new ActionPrepareDistributedCommitedTransferAnswer (source, target,
amount, timestamp, granted, id), self);
}
\end{lstlisting}