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); }
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); } }
public static int GetTipHeight(string snetworkid) { try { InitializeNewBitnet(snetworkid); int iTipHeight = mBitnetNewClient.GetBlockCount(); if (snetworkid == "main" && iTipHeight > 0) { nCurrentTipHeightMain = iTipHeight; } return(iTipHeight); } catch (Exception) { return(-1); } }
void Button_scanClick(object sender, EventArgs e) { int block_from = 1; int blocks = client.GetBlockCount(); int progress = 1; for (int block_number = block_from; block_number <= blocks; block_number++) { scanBlock(block_number); if (progress == 1001) { //Debug.Print("Блок №" + block_number.ToString()); label_last_block.Text = block_number.ToString(); label5.Text = known_addresses.Count.ToString(); this.Refresh(); progress = 1; } progress++; } File.WriteAllLines("adresses.txt", known_addresses); File.WriteAllLines("transactions.txt", known_transactions); Debug.Print("Сканирование завершено"); alert("Сканирование завершено"); }