mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-01-04 06:23:09 +00:00
Adds logging to debug active chain roles
This commit is contained in:
parent
0eb14988d0
commit
e4d99932dd
@ -11,8 +11,7 @@
|
||||
return
|
||||
Errors.Length > 0 ||
|
||||
EventsOverview.Length > 0 ||
|
||||
ActiveChainAddresses.Hosts.Length > 0 ||
|
||||
ActiveChainAddresses.Clients.Length > 0;
|
||||
ActiveChainAddresses.HasAny();
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,5 +25,15 @@
|
||||
{
|
||||
public string[] Hosts { get; set; } = Array.Empty<string>();
|
||||
public string[] Clients { get; set; } = Array.Empty<string>();
|
||||
|
||||
public bool HasAny()
|
||||
{
|
||||
return Hosts.Length > 0 || Clients.Length > 0;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Hosts:" + string.Join(",", Hosts) + "Clients:" + string.Join(",", Clients);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,10 +18,24 @@ namespace BiblioTech.Rewards
|
||||
|
||||
public async Task Process(ActiveChainAddresses activeChainAddresses)
|
||||
{
|
||||
if (!activeChainAddresses.HasAny())
|
||||
{
|
||||
Log("Received empty activeChainAddresses.");
|
||||
return;
|
||||
}
|
||||
|
||||
var activeUserIds = ConvertToUserIds(activeChainAddresses);
|
||||
if (!activeUserIds.HasAny()) return;
|
||||
if (!activeUserIds.HasAny())
|
||||
{
|
||||
Log("Empty userIds after lookup of addresses: " + activeChainAddresses);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HasChanged(activeUserIds)) return;
|
||||
if (!HasChanged(activeUserIds))
|
||||
{
|
||||
Log("Active userIds has not changed: " + activeUserIds);
|
||||
return;
|
||||
}
|
||||
|
||||
await GiveAndRemoveRoles(activeUserIds);
|
||||
}
|
||||
@ -116,6 +130,11 @@ namespace BiblioTech.Rewards
|
||||
return result.Order().ToArray();
|
||||
}
|
||||
|
||||
private void Log(string msg)
|
||||
{
|
||||
log.Log(msg);
|
||||
}
|
||||
|
||||
private class ActiveUserIds
|
||||
{
|
||||
public ActiveUserIds(IEnumerable<ulong> hosts, IEnumerable<ulong> clients)
|
||||
@ -131,6 +150,11 @@ namespace BiblioTech.Rewards
|
||||
{
|
||||
return Hosts.Any() || Clients.Any();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return "Hosts:" + string.Join(",", Hosts) + "Clients:" + string.Join(",", Clients);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,7 @@ namespace BiblioTech.Rewards
|
||||
|
||||
public async Task GiveRole(ulong userId, ulong roleId)
|
||||
{
|
||||
Log($"Giving role {roleId} to user {userId}");
|
||||
var role = GetRole(roleId);
|
||||
var guildUser = GetUser(userId);
|
||||
if (role == null) return;
|
||||
@ -46,6 +47,7 @@ namespace BiblioTech.Rewards
|
||||
|
||||
public async Task RemoveRole(ulong userId, ulong roleId)
|
||||
{
|
||||
Log($"Removing role {roleId} from user {userId}");
|
||||
var role = GetRole(roleId);
|
||||
var guildUser = GetUser(userId);
|
||||
if (role == null) return;
|
||||
@ -67,6 +69,11 @@ namespace BiblioTech.Rewards
|
||||
return null;
|
||||
}
|
||||
|
||||
private void Log(string msg)
|
||||
{
|
||||
log.Log(msg);
|
||||
}
|
||||
|
||||
private async Task<Dictionary<ulong, IGuildUser>> LoadAllUsers(SocketGuild guild)
|
||||
{
|
||||
log.Log("Loading all users..");
|
||||
|
||||
@ -45,6 +45,7 @@ namespace TestNetRewarder
|
||||
|
||||
Log.Log("Starting TestNet Rewarder...");
|
||||
var segmenter = new TimeSegmenter(Log, Config.Interval, Config.HistoryStartUtc, processor);
|
||||
await EnsureBotOnline();
|
||||
await processor.Initialize();
|
||||
|
||||
while (!CancellationToken.IsCancellationRequested)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user