Skip to content

Commit

Permalink
merge hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Sep 22, 2022
2 parents 4f5eab1 + 5ce5b48 commit 68cdaaf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,21 @@ public async Task<string> BuyPostageBatchAsync(long amount, int depth, string? l
{
var batchId = await Client.DebugClient!.BuyPostageBatchAsync(amount, depth, label, immutable, gasPrice);

//add batchId with full status refresh
RequireFullStatusRefresh = true;
//immediately add the batch to the node
await statusRefreshSemaphore.WaitAsync();
try
{
Status = new BeeNodeStatus(
Status.Errors,
Status.HeartbeatTimeStamp,
Status.IsAlive,
Status.PinnedHashes,
(Status.PostageBatchesId ?? Array.Empty<string>()).Append(batchId).ToArray());
}
finally
{
statusRefreshSemaphore.Release();
}

return batchId;
}
Expand Down Expand Up @@ -220,8 +233,14 @@ e is HttpRequestException ||
//postage batches
try
{
/* Union is required, because postage batches just created could not appear from the node request.
* Because of this, if we added a new created postage, and we try to refresh with only info from node,
* the postage Id reference could be lost.
* Unione instead never remove a postage batch id. This is fine, because an owned postage batch can't be removed
* by node's logic. It only can expire, but this is not concern of this part of code.
*/
var batches = await Client.DebugClient!.GetOwnedPostageBatchesByNodeAsync();
postageBatchesId = batches.Select(b => b.Id);
postageBatchesId = (postageBatchesId ?? Array.Empty<string>()).Union(batches.Select(b => b.Id)).ToArray();
}
catch { errors.Add("Can't read postage batches"); }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Etherna.BeehiveManager.Services.Utilities.Models
[SuppressMessage("Performance", "CA1815:Override equals and operator equals on value types", Justification = "Status comparison is not a required function")]
public struct BeeNodeStatus
{
// Constructor.
public BeeNodeStatus(
IEnumerable<string>? errors,
DateTime heartbeatTimeStamp,
Expand Down

0 comments on commit 68cdaaf

Please sign in to comment.