Exemple #1
0
        private static void Main(string[] args)
        {
            byte[] test = CryptoNight(new byte[] { 0x00, 0x01 });

            json       = new JsonRPC(config.IniReadValue("daemon-json-rpc"));
            Walletjson = new JsonRPC(config.IniReadValue("wallet-json-rpc"));

            redis = ConnectionMultiplexer.Connect(config.IniReadValue("redis-server"));

            redisDb = redis.GetDatabase();

            JObject test2 = json.InvokeMethod("getblockcount");

            CurrentBlockHeight = (int)test2["result"]["count"];

            Console.WriteLine("beginning listen");

            StartListening();

            while (true)
            {
                Thread.Sleep(5000);
                test2 = json.InvokeMethod("getblockcount");
                CurrentBlockHeight = (int)test2["result"]["count"];


                /*ConnectedClients =
                 *  ConnectedClients.AsParallel()
                 *                  .Where(x => (DateTime.Now - x.Value.last_heard).Seconds < 60)
                 *                  .ToDictionary(x => x.Key, x => x.Value); */
                //, new JObject(new JProperty("reserve_size", 4), new JProperty("wallet_address", "41jhre5xFk92GYaJgxvHuzUC5uZtQ4UDU1APv3aRAc27DWBqKEzubC2WSvmnbxaswLdB1BsQnSfxfYXvEqkXPvcuS4go3aV")));
            }
        }
Exemple #2
0
        /// <summary>
        /// Application Entry Point.
        /// </summary>
        /// <param name="args"></param>
        private static void Main(string[] args)
        {
            // Get a new global configuration instance.
            Configuration = new Configuration();

            // Initialize redis configuration
            RedisConfigurationOptions = new ConfigurationOptions
            {
                ResolveDns = true
            };

            // Add redis connection.
            RedisConfigurationOptions.EndPoints.Add(
                Configuration.GetRedisAddress(),
                Configuration.GetRedisPort()
                );

            // Initialize Redis Connection.
            InitializeRedis();

            // Initialize Block Objects.
            HashRate               = new PoolHashRateCalculation();
            BlocksPendingPayment   = new List <PoolBlock>();
            BlocksPendingSubmition = new List <PoolBlock>();
            ConnectedClients       = new Dictionary <string, ConnectedWorker>();
            DaemonJson             = new JsonRPC(Configuration.GetDaemonRpc());
            WalletJson             = new JsonRPC(Configuration.GetWalletRpc());

            // Create local instances to keep classes in memory.
            var backgroundSaticUpdater = new BackgroundStaticUpdater();
            var blockPayment           = new BlockPayment();
            var blockSubmitter         = new BlockSubmitter();
            var difficultyRetargeter   = new DifficultyRetargeter();
            var cryptoNightPool        = new CryptoNightPool();

            // Start routines.
            backgroundSaticUpdater.Start();
            blockPayment.Start();
            blockSubmitter.Start();
            difficultyRetargeter.Start();
            cryptoNightPool.Start();


            // Pointless loop to keep the application running.
            while (true)
            {
                Thread.Sleep(Timeout.Infinite);
            }
        }