Skip to content

Commit

Permalink
merge hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Oct 12, 2024
2 parents cb77cd2 + 671da9e commit e9372cb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/BeehiveManager.Services/BeehiveManager.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bee.Net.Client" Version="0.4.0-alpha.55" />
<PackageReference Include="Bee.Net.Client" Version="0.4.0-alpha.58" />
<PackageReference Include="Etherna.DomainEvents.AspNetCore" Version="1.4.0" />
<PackageReference Include="MongODM.Hangfire" Version="0.24.0" />
<PackageReference Include="Nethereum.JsonRpc.WebSocketClient" Version="4.26.0" />
Expand Down
32 changes: 20 additions & 12 deletions src/BeehiveManager.Services/Tasks/PinContentInNodeTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,36 @@
// If not, see <https://www.gnu.org/licenses/>.

using Etherna.BeehiveManager.Services.Utilities;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Etherna.BeehiveManager.Services.Tasks
{
public class PinContentInNodeTask : IPinContentInNodeTask
public class PinContentInNodeTask(IBeeNodeLiveManager beeNodeLiveManager)
: IPinContentInNodeTask
{
private readonly IBeeNodeLiveManager beeNodeLiveManager;

public PinContentInNodeTask(
IBeeNodeLiveManager beeNodeLiveManager)
{
this.beeNodeLiveManager = beeNodeLiveManager;
}

public const int MaxRetries = 5;
public static readonly TimeSpan RetryWaitTime = TimeSpan.FromSeconds(5);

public async Task RunAsync(string contentHash, string nodeId)
{
var beeNodeInstance = await beeNodeLiveManager.GetBeeNodeLiveInstanceAsync(nodeId);

// Try to pin.
try { await beeNodeInstance.PinResourceAsync(contentHash); }
catch (KeyNotFoundException) { }
for (int i = 0; i < MaxRetries; i++)
{
try
{
await beeNodeInstance.PinResourceAsync(contentHash);
}
catch (KeyNotFoundException)
{
if (i + 1 == MaxRetries)
throw;
await Task.Delay(RetryWaitTime);
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/BeehiveManager/BeehiveManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="MongODM" Version="0.24.0" />
<PackageReference Include="MongODM.AspNetCore.UI" Version="0.24.0" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="10.0.0" />
Expand Down

0 comments on commit e9372cb

Please sign in to comment.