GetBlockCount() public method

public GetBlockCount ( ) : int
return int
Ejemplo n.º 1
0
        public override WorkBlock GetWorkBlock()
        {
            WorkBlock work = null;

            JObject obj = null;
            try
            {
                // Get block from bitcoin
                BitnetClient bc = new BitnetClient("http://" + mURL + ":" + mPort);
                bc.Credentials = new NetworkCredential(mUser, mPass);
                mBlockCount = bc.GetBlockCount();
                obj = bc.GetWork();
                mNewBlockReady = false;
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to get work!");
                Console.WriteLine(e.Message);
            }

            if (obj != null)
            {
                work = new WorkBlock(obj);
            }
            return work;
        }
Ejemplo n.º 2
0
        void ThreadFunc()
        {
            while (true)
            {
                try
                {
                    if (mURL != null && mPort != 0 && mUser != null && mPass != null)
                    {
                        BitnetClient bc = new BitnetClient("http://" + mURL + ":" + mPort);
                        bc.Credentials = new NetworkCredential(mUser, mPass);
                        int blockCount = bc.GetBlockCount();
                        if (blockCount > mBlockCount)
                        {
                            mBlockCount = blockCount;
                            mNewBlockReady = true;
                        }
                    }
                }
                catch (Exception)
                {
                }

                Thread.Sleep(1000 * 10);
            }
        }