Newer
Older
package fucoin.actions.persist;
import akka.actor.ActorRef;
import akka.actor.UntypedActorContext;
Simon Könnecke
committed
import fucoin.wallet.AbstractWallet;
Simon Könnecke
committed
// Used to search a WalletImpl by name, i.e. the own wallet if we just
// joined the network; If a receiving participant holds the stored WalletImpl,
// he returns it, otherwise, he might use gossiping methods to go on
// with the search;
// Note: You should also forward the sender (the participant who actually
Simon Könnecke
committed
// searches for this WalletImpl, so that it can be returnd the direct way)
public class ActionSearchMyWallet extends Persist {
Simon Könnecke
committed
public ActionSearchMyWallet(String name) {
this.name = name;
}
Simon Könnecke
committed
@Override
protected void onAction(ActorRef sender, ActorRef self,
UntypedActorContext context, AbstractWallet wallet) {
wallet.addKnownNeighbor(name, sender);
AbstractWallet storedWallet = wallet.backedUpNeighbors.get(name);
if (storedWallet != null) {
sender.tell(new ActionSearchMyWalletAnswer(storedWallet), self);
}
}