This commit is contained in:
benbierens 2024-01-22 11:47:28 +01:00
parent 1b7c11b849
commit 678b719cef
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 11 additions and 10 deletions

View File

@ -21,6 +21,7 @@ namespace CodexContractsPlugin
Request[] GetStorageRequests(TimeRange range);
EthAddress GetSlotHost(Request storageRequest, decimal slotIndex);
// add 'RequestFulfilled' to see request is started.
SlotFilledEventDTO[] GetSlotFilledEvents(TimeRange timeRange);
SlotFreedEventDTO[] GetSlotFreedEvents(TimeRange timeRange);
}

View File

@ -16,7 +16,7 @@ namespace TestNetRewarder
[Uniform("interval-minutes", "im", "INTERVALMINUTES", false, "time in minutes between reward updates. (default 15)")]
public int Interval { get; set; } = 15;
[Uniform("check-history", "ch", "CHECKHISTORY", false, "if not 0, Unix epoc timestamp of a moment in history on which processing should begin. (default 0)")]
[Uniform("check-history", "ch", "CHECKHISTORY", true, "Unix epoc timestamp of a moment in history on which processing begins. Required for hosting rewards. Should be 'launch of the testnet'.")]
public int CheckHistoryTimestamp { get; set; } = 0;
public string LogPath

View File

@ -14,15 +14,10 @@ namespace TestNetRewarder
this.log = log;
if (configuration.Interval < 0) configuration.Interval = 15;
if (configuration.CheckHistoryTimestamp == 0) throw new Exception("'check-history' unix timestamp is required. Set it to the start/launch moment of the testnet.");
segmentSize = TimeSpan.FromSeconds(configuration.Interval);
if (configuration.CheckHistoryTimestamp != 0)
{
start = DateTimeOffset.FromUnixTimeSeconds(configuration.CheckHistoryTimestamp).UtcDateTime;
}
else
{
start = DateTime.UtcNow - segmentSize;
}
start = DateTimeOffset.FromUnixTimeSeconds(configuration.CheckHistoryTimestamp).UtcDateTime;
log.Log("Starting time segments at " + start);
log.Log("Segment size: " + Time.FormatDuration(segmentSize));
@ -32,16 +27,21 @@ namespace TestNetRewarder
{
var now = DateTime.UtcNow;
var end = start + segmentSize;
var waited = false;
if (end > now)
{
// Wait for the entire time segment to be in the past.
var delay = (end - now).Add(TimeSpan.FromSeconds(3));
waited = true;
await Task.Delay(delay, Program.CancellationToken);
}
if (Program.CancellationToken.IsCancellationRequested) return;
log.Log($"Time segment {start} to {end}");
var postfix = "(Catching up...)";
if (waited) postfix = "(Real-time)";
log.Log($"Time segment [{start} to {end}] {postfix}");
var range = new TimeRange(start, end);
start = end;