Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package fucoin.actions.transaction;
import akka.actor.ActorRef;
import akka.actor.UntypedActorContext;
import fucoin.Wallet;
import fucoin.actions.search.ActionSearchWalletReference;
public class ActionInvokeSentMoney extends Transaction{
public final String name;
public final int amount;
public ActionInvokeSentMoney(String name, int amount) {
this.name=name;
this.amount = amount;
}
@Override
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{
for(ActorRef neighbor : wallet.getKnownNeighbors().values()){
neighbor.tell(new ActionSearchWalletReference(name), self);
}
try {
context.unwatch(self);
Thread.sleep(200);
context.watch(self);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//getContext().unwatch(getSelf());
self.tell(new ActionInvokeSentMoney(name, amount), self);
}
}
}