예제 #1
0
        public PoolClient(PoolInstance poolInstance, ICoinHandlerPool pool, ICoinHandlerMiner miner)
        {
            this.poolHandler  = pool;
            this.coinHandler  = miner;
            this.poolInstance = poolInstance;

            //Create a new instance of the MinerServer, which creates an instance of Network.Sockets.Server
            minerServer = new MinerServer(poolInstance.localListenPort, this, minerManager, coinHandler);

            //Create a new instance of the Network.Sockets.Client
            poolClient = new Client(poolInstance.GetCurrentPool().poolAddress, poolInstance.GetCurrentPool().poolPort);

            //define pool events
            poolClient.OnServerConnected    += PoolClient_OnServerConnected;
            poolClient.OnServerDataReceived += PoolClient_OnServerDataReceived;
            poolClient.OnServerDisconnected += PoolClient_OnServerDisconnected;
            poolClient.OnServerError        += PoolClient_OnServerError;

            //setup coin miner handler
            coinHandler.SetMinerServer(minerServer);
            coinHandler.SetPoolClient(this);
            coinHandler.SetMinerManager(minerManager);

            //setup coin Pool handler
            poolHandler.SetMinerServer(minerServer);
            poolHandler.SetPoolClient(this);
            poolHandler.SetMinerManager(minerManager);

            //this.Start();
            minerServer.ListenForMiners();

            Log.Information("[{0}] waiting for miners before connecting to pool..", poolWorkerName);
        }
예제 #2
0
        public MinerServer(int port, PoolClient pool, MinerManager minerManager, ICoinHandlerMiner coinHandler)
        {
            Log.Debug("MinerServer initialized for {0}", pool.poolEndPoint);

            this._minerManager = minerManager;
            this.port          = port;

            _poolClient  = pool;
            _coinHandler = coinHandler;
            _coinHandler.SetMinerServer(this);
            _coinHandler.SetPoolClient(_poolClient);

            minerServer = new Server();
            minerServer.OnClientDataReceived += MinerServer_OnClientDataReceived;
            minerServer.OnClientConnected    += MinerServer_OnClientConnected;
            minerServer.OnClientDisconnected += MinerServer_OnClientDisconnected;
            minerServer.OnClientError        += MinerServer_OnClientError;
        }