Skip to content
Snippets Groups Projects
2_actioninvokesentmoney.tex 1.06 KiB
Newer Older
Michael Kmoch's avatar
Michael Kmoch committed
\section{ActionInvokeSentMoney}
This action is invoked by the graphical user interface of the wallets.
The goal is to transfer an amount of FUCoins to a given wallet ID.
If this ID already has a mapping to an ActorRef, an
ActionInvokeDistributedCommitedTransfer will be send to the supervisor.
Otherwise a gossip is invoked using the ActionSearchWalletReference
following by ActionInvokeSentMoney after 200 ms.
\\
\begin{lstlisting}
protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context,
                        Wallet wallet) {
  log(wallet.getKnownNeighbors()+"");
  if(wallet.getKnownNeighbors().containsKey(name)){
    wallet.getRemoteSuperVisorActor().tell(
      new ActionInvokeDistributedCommitedTransfer(self,
        wallet.getKnownNeighbors().get(name), amount), sender);
  }else{
    ActionSearchWalletReference aswr = new ActionSearchWalletReference(name);
    for(ActorRef neighbor : wallet.getKnownNeighbors().values()){
      neighbor.tell(aswr, self);
    }
    sleep(self, context, 200);
    self.tell(this, self);
    }
}
\end{lstlisting}