package fucoin.actions.join;

import akka.actor.ActorRef;
import akka.actor.UntypedActorContext;
import fucoin.AbstractNode;
import fucoin.actions.ClientAction;
import fucoin.wallet.AbstractWallet;

//Used to join the network (a pre known participant/WalletImpl must be known)
public class ActionJoin extends ClientAction {

    @Override
    protected void onAction(ActorRef sender, ActorRef self, UntypedActorContext context, AbstractWallet node) {
        ActionJoinAnswer aja = new ActionJoinAnswer(node.getRemoteSuperVisorActor());
        aja.someNeighbors.putAll(node.getKnownNeighbors());
        System.out.println("Answer to " + sender.path().name());
        sender.tell(aja, self);
    }
}