wip
This commit is contained in:
parent
1b7c11b849
commit
678b719cef
@ -21,6 +21,7 @@ namespace CodexContractsPlugin
|
|||||||
|
|
||||||
Request[] GetStorageRequests(TimeRange range);
|
Request[] GetStorageRequests(TimeRange range);
|
||||||
EthAddress GetSlotHost(Request storageRequest, decimal slotIndex);
|
EthAddress GetSlotHost(Request storageRequest, decimal slotIndex);
|
||||||
|
// add 'RequestFulfilled' to see request is started.
|
||||||
SlotFilledEventDTO[] GetSlotFilledEvents(TimeRange timeRange);
|
SlotFilledEventDTO[] GetSlotFilledEvents(TimeRange timeRange);
|
||||||
SlotFreedEventDTO[] GetSlotFreedEvents(TimeRange timeRange);
|
SlotFreedEventDTO[] GetSlotFreedEvents(TimeRange timeRange);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ namespace TestNetRewarder
|
|||||||
[Uniform("interval-minutes", "im", "INTERVALMINUTES", false, "time in minutes between reward updates. (default 15)")]
|
[Uniform("interval-minutes", "im", "INTERVALMINUTES", false, "time in minutes between reward updates. (default 15)")]
|
||||||
public int Interval { get; set; } = 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 int CheckHistoryTimestamp { get; set; } = 0;
|
||||||
|
|
||||||
public string LogPath
|
public string LogPath
|
||||||
|
@ -14,15 +14,10 @@ namespace TestNetRewarder
|
|||||||
this.log = log;
|
this.log = log;
|
||||||
|
|
||||||
if (configuration.Interval < 0) configuration.Interval = 15;
|
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);
|
segmentSize = TimeSpan.FromSeconds(configuration.Interval);
|
||||||
if (configuration.CheckHistoryTimestamp != 0)
|
start = DateTimeOffset.FromUnixTimeSeconds(configuration.CheckHistoryTimestamp).UtcDateTime;
|
||||||
{
|
|
||||||
start = DateTimeOffset.FromUnixTimeSeconds(configuration.CheckHistoryTimestamp).UtcDateTime;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
start = DateTime.UtcNow - segmentSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Log("Starting time segments at " + start);
|
log.Log("Starting time segments at " + start);
|
||||||
log.Log("Segment size: " + Time.FormatDuration(segmentSize));
|
log.Log("Segment size: " + Time.FormatDuration(segmentSize));
|
||||||
@ -32,16 +27,21 @@ namespace TestNetRewarder
|
|||||||
{
|
{
|
||||||
var now = DateTime.UtcNow;
|
var now = DateTime.UtcNow;
|
||||||
var end = start + segmentSize;
|
var end = start + segmentSize;
|
||||||
|
var waited = false;
|
||||||
if (end > now)
|
if (end > now)
|
||||||
{
|
{
|
||||||
// Wait for the entire time segment to be in the past.
|
// Wait for the entire time segment to be in the past.
|
||||||
var delay = (end - now).Add(TimeSpan.FromSeconds(3));
|
var delay = (end - now).Add(TimeSpan.FromSeconds(3));
|
||||||
|
waited = true;
|
||||||
await Task.Delay(delay, Program.CancellationToken);
|
await Task.Delay(delay, Program.CancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Program.CancellationToken.IsCancellationRequested) return;
|
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);
|
var range = new TimeRange(start, end);
|
||||||
start = end;
|
start = end;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user