Merge conf
This commit is contained in:
@@ -46,10 +46,12 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
||||
private string? _lightfinderText;
|
||||
private string? _lightfinderTooltip;
|
||||
private Colors _lightfinderColors;
|
||||
private readonly object _localHashedCidLock = new();
|
||||
private string? _localHashedCid;
|
||||
private DateTime _localHashedCidFetchedAt = DateTime.MinValue;
|
||||
private DateTime _localHashedCidNextErrorLog = DateTime.MinValue;
|
||||
private DateTime _pairRequestNextErrorLog = DateTime.MinValue;
|
||||
private int _localHashedCidRefreshActive;
|
||||
|
||||
public DtrEntry(
|
||||
ILogger<DtrEntry> logger,
|
||||
@@ -339,29 +341,61 @@ public sealed class DtrEntry : IDisposable, IHostedService
|
||||
private string? GetLocalHashedCid()
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
if (_localHashedCid is not null && now - _localHashedCidFetchedAt < _localHashedCidCacheDuration)
|
||||
return _localHashedCid;
|
||||
|
||||
try
|
||||
lock (_localHashedCidLock)
|
||||
{
|
||||
var cid = _dalamudUtilService.GetCID();
|
||||
var hashedCid = cid.ToString().GetHash256();
|
||||
_localHashedCid = hashedCid;
|
||||
_localHashedCidFetchedAt = now;
|
||||
return hashedCid;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (now >= _localHashedCidNextErrorLog)
|
||||
if (_localHashedCid is not null && now - _localHashedCidFetchedAt < _localHashedCidCacheDuration)
|
||||
{
|
||||
_logger.LogDebug(ex, "Failed to refresh local hashed CID for Lightfinder DTR entry.");
|
||||
_localHashedCidNextErrorLog = now + _localHashedCidErrorCooldown;
|
||||
return _localHashedCid;
|
||||
}
|
||||
|
||||
_localHashedCid = null;
|
||||
_localHashedCidFetchedAt = now;
|
||||
return null;
|
||||
}
|
||||
|
||||
QueueLocalHashedCidRefresh();
|
||||
|
||||
lock (_localHashedCidLock)
|
||||
{
|
||||
return _localHashedCid;
|
||||
}
|
||||
}
|
||||
|
||||
private void QueueLocalHashedCidRefresh()
|
||||
{
|
||||
if (Interlocked.Exchange(ref _localHashedCidRefreshActive, 1) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var cid = _dalamudUtilService.GetCID();
|
||||
var hashedCid = cid.ToString().GetHash256();
|
||||
lock (_localHashedCidLock)
|
||||
{
|
||||
_localHashedCid = hashedCid;
|
||||
_localHashedCidFetchedAt = DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var now = DateTime.UtcNow;
|
||||
lock (_localHashedCidLock)
|
||||
{
|
||||
if (now >= _localHashedCidNextErrorLog)
|
||||
{
|
||||
_logger.LogDebug(ex, "Failed to refresh local hashed CID for Lightfinder DTR entry.");
|
||||
_localHashedCidNextErrorLog = now + _localHashedCidErrorCooldown;
|
||||
}
|
||||
|
||||
_localHashedCid = null;
|
||||
_localHashedCidFetchedAt = now;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
Interlocked.Exchange(ref _localHashedCidRefreshActive, 0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<string> GetNearbyBroadcasts()
|
||||
|
||||
Reference in New Issue
Block a user