Skip to content

Commit

Permalink
HSDBidder: Added option to skip failed domains
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathanwoodburn committed Feb 23, 2023
1 parent 5b20a5a commit 952e81a
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 14 deletions.
16 changes: 15 additions & 1 deletion BidderGUI/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 57 additions & 13 deletions BidderGUI/Form1.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.DirectoryServices.ActiveDirectory;

namespace BidderGUI
{
public partial class Form1 : Form
Expand Down Expand Up @@ -148,7 +150,7 @@ private void start_button_Click(object sender, EventArgs e)

timetaken = 0;
countdowntimer.Start();
timer1.Interval = (int)intervalnumericUpDown.Value*1000*60;
timer1.Interval = (int)intervalnumericUpDown.Value*1000;
timer1.Start();

// Make all fields uneditable
Expand All @@ -165,8 +167,13 @@ private void start_button_Click(object sender, EventArgs e)
sendtransaction();
}

int oldtime = 0;
private async void batch_timer_Tick(object sender, EventArgs e)
{
if (oldtime != 0)
{
timer1.Interval = oldtime;
}
// reset time since last batch variable
timetaken = 0;
// Run send transaction function
Expand Down Expand Up @@ -291,7 +298,7 @@ async void sendbatchbid(string[] domains)
addlog(responseBody);

// Check for errors
if (!Checkerrors(responseBody))
if (!Checkerrors(responseBody,domains))
{
// Remove domains from list
foreach (string domain in domains)
Expand Down Expand Up @@ -355,7 +362,7 @@ async void sendbatch(string[] domains, string method)
addlog(responseBody);

// Remove domains from list
if (!Checkerrors(responseBody))
if (!Checkerrors(responseBody, domains))
{
// Remove domains from list
foreach (string domain in domains)
Expand Down Expand Up @@ -421,7 +428,8 @@ async void sendapicall(HttpRequestMessage request,string domain)
// Log response
addlog(responseBody);
// Remove domain from list
if (!Checkerrors(responseBody))
string[] domains = { domain };
if (!Checkerrors(responseBody, domains ))
{
// Remove domains from list
domainslistBox.Items.Remove(domain);
Expand Down Expand Up @@ -548,7 +556,7 @@ private void countdowntimer_Tick(object sender, EventArgs e)
timetaken += 1;

// Calculate time to minutes and seconds
int timeleftsec = (int)intervalnumericUpDown.Value * 60 - timetaken;
int timeleftsec = (int)intervalnumericUpDown.Value - timetaken;
TimeSpan time = TimeSpan.FromSeconds(timeleftsec);

// Update time label
Expand All @@ -571,22 +579,53 @@ private void button_cleardomains_Click(object sender, EventArgs e)
{
domainslistBox.Items.Clear();
}
string[] errors = { "tx exceeds maximum unconfirmed ancestors" ,"error\":{\"message"};
public bool Checkerrors(string log)
public bool Checkerrors(string log, string[] domains)
{
log = log.ToLower();
// If there is an error in the log
foreach (string error in errors)
if (log.Contains("tx exceeds maximum unconfirmed ancestors"))
{
if (log.Contains(error))
if (skiperrorscheck.Checked)
{
oldtime = timer1.Interval;
timer1.Interval = 600000;
}
else
{
stopbutton.PerformClick();
// Log error
addlog("Errors Found");
return true;
}
// Temporarily set the timer to 10 minutes before restending the batch.
// Log error
addlog("Errors Found");
return true;
}
else if (log.Contains("error\":{\"message"))
{
if (skiperrorscheck.Checked)
{
StreamWriter streamWriter = new StreamWriter(Environment.CurrentDirectory + "\\log.txt", true);
foreach (string domain in domains)
{
domainslistBox.Items.Remove(domain);
streamWriter.WriteLine(domain);
}
streamWriter.Close();
streamWriter.Dispose();
addlog("Added log at: " + Environment.CurrentDirectory + "\\log.txt");
}
else
{
stopbutton.PerformClick();
}
// Log error
addlog("Errors Found");
return true;

}
else
{
return false;
}
return false;
}
public void addlog(string log)
{
Expand All @@ -607,5 +646,10 @@ public void addlog(string log)

logtextBox.Text = string.Join(Environment.NewLine, newlines) + Environment.NewLine + log;
}

private void Form1_Load(object sender, EventArgs e)
{

}
}
}

0 comments on commit 952e81a

Please sign in to comment.