Skip to content

Commit

Permalink
rent modify
Browse files Browse the repository at this point in the history
  • Loading branch information
guoyongchang committed Mar 31, 2022
1 parent 4b40d34 commit 8472d59
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 35 deletions.
59 changes: 28 additions & 31 deletions StarSharksTool/BatchRentPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,36 +128,32 @@ public BatchRentPage()
}
});

//Task.Run(async () =>
//{
// while (true)
// {
// try
// {
// await Task.Delay(5000);
// bool isApproveContract = await Services.Service.IsApproveRentContract(this._accountModel.Account.Address);

// MethodInvoker mi = new MethodInvoker(() =>
// {
// var textboxPrice = Convert.ToInt32(priceTextbox.Text);
// if (isApproveContract == true)
// {
// approveContract.Enabled = false;
// }
// });
// BeginInvoke(mi);
// }
// catch (InvalidOperationException)
// {
// break;
// }
// catch (Exception e)
// {

// }
// }
//});

Task.Run(async () =>
{
while (true)
{
try
{
await Task.Delay(3);
MethodInvoker mi = new MethodInvoker(() =>
{
if (NeedRentAccounts.Count == 0) {
this.autoRent.Checked = false;
this.checkBox1.Checked = false;
}
});
BeginInvoke(mi);
}
catch (InvalidOperationException)
{
break;
}
catch (Exception e)
{
break;
}
}
});
}


Expand Down Expand Up @@ -246,7 +242,8 @@ public void RerenderRentHistory()
dt.Columns.Add("RentId");
dt.Columns.Add("RentPrice");
dt.Columns.Add("Status");
foreach (var item in RentHistory)
var tmp = RentHistory.Reverse();
foreach (var item in tmp)
{
dt.Rows.Add(item.Key.Item1, item.Key.Item2, item.Value);
}
Expand Down
2 changes: 2 additions & 0 deletions StarSharksTool/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ internal static HttpClient GetClient(string proxy)
clientHandler.Proxy = new WebProxy(PROXY);
}
_httpClient = new HttpClient(clientHandler);
_httpClient.DefaultRequestHeaders.ConnectionClose = true;
return _httpClient;
}

Expand All @@ -71,6 +72,7 @@ internal static HttpClient HTTPCLIENT
clientHandler.Proxy = new WebProxy(PROXY);
}
_httpClient = new HttpClient(clientHandler);
_httpClient.DefaultRequestHeaders.ConnectionClose = true;
return _httpClient;
}
set
Expand Down
13 changes: 9 additions & 4 deletions StarSharksTool/Services/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,14 @@ internal async static Task<MarketRentResponseModel> GetMarketplace(int maxPrice,
req.Speed = new List<int> { 1, 100 + r.Next(1, 50) };
req.RentExceptGain = new List<int> { 1, 13 + step + maxPrice };
req.Star = level;

if (step % 2 == 0)
{
req.Page = 2;
}

if (step % 4 == 0)
{
req.Sort = "LatestDesc";
}

Expand Down Expand Up @@ -345,18 +350,18 @@ internal static async Task<bool> ApproveContract(string rentAddress)
{
if (sharkResp.Message.StartsWith("shark was rented by others"))
{
return (-1, sharkResp.Message);
return (-1, "取消租赁:原因:" + sharkResp.Message);
}
else
{
return (-2, sharkResp.Message);
return (-2, "取消租赁:原因:" + sharkResp.Message);
}
}

var price = BigInteger.Parse(sharkResp.Data.Price) / 1000000000000000000;
if (price > maxPrice)
if (price != maxPrice)
{
return (-1, "价格超了");
return (-1, "价格不一致");
}
int nonce = obj.Nonce;
//lock (obj)
Expand Down

0 comments on commit 8472d59

Please sign in to comment.