mirror of
https://github.com/logos-storage/logos-storage-nim-cs-dist-tests.git
synced 2026-02-25 15:33:11 +00:00
Graceful fail-out for when geth is unavailable
This commit is contained in:
parent
c5ff76db69
commit
36cc93ebee
@ -8,9 +8,13 @@ namespace BiblioTech
|
||||
{
|
||||
protected override async Task Invoke(CommandContext context)
|
||||
{
|
||||
var gethConnector = GethConnector.GethConnector.Initialize(Program.Log);
|
||||
var gethConnector = GetGeth();
|
||||
if (gethConnector == null)
|
||||
{
|
||||
await context.Followup("Blockchain operations are (temporarily) unavailable.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (gethConnector == null) return;
|
||||
var gethNode = gethConnector.GethNode;
|
||||
var contracts = gethConnector.CodexContracts;
|
||||
|
||||
@ -23,6 +27,19 @@ namespace BiblioTech
|
||||
await Execute(context, gethNode, contracts);
|
||||
}
|
||||
|
||||
private GethConnector.GethConnector? GetGeth()
|
||||
{
|
||||
try
|
||||
{
|
||||
return GethConnector.GethConnector.Initialize(Program.Log);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Program.Log.Error("Failed to initialize geth connector: " + ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Task Execute(CommandContext context, IGethNode gethNode, ICodexContracts contracts);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user