Skip to content

Commit

Permalink
Add max collisions calculation and warning messages to console output
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Apr 22, 2024
1 parent 072ab4d commit 22ff0c5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/BeeBucketExplorer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,20 @@ static async Task Main(string[] args)

foreach (var postage in postageBatches)
{
var maxCollisions = (int)Math.Pow(2, postage.Depth - postage.BucketDepth);
var bucketBatch = await beeClient.GetStampsBucketsForBatchAsync(postage.Id);

Console.WriteLine($"postage Id: {postage.Id}, depth: {postage.Depth}");
Console.WriteLine($"postage Id: {postage.Id}, depth: {postage.Depth}, max collisions: {maxCollisions}");

var maxCollisionsBucket = bucketBatch.Buckets.MaxBy(b => b.Collisions)!;
Console.WriteLine($" max collisions bucket: {maxCollisionsBucket.Collisions}");
Console.WriteLine($" max collisions bucket: {maxCollisionsBucket.BucketId} with {maxCollisionsBucket.Collisions}");

if (maxCollisionsBucket.Collisions == maxCollisions)
Console.WriteLine(" WARNING: batch fulfilled!");
else if (maxCollisionsBucket.Collisions > maxCollisions)
Console.WriteLine(" ERROR: bucket over collided!!");

Console.WriteLine("-----");
}
}
}

0 comments on commit 22ff0c5

Please sign in to comment.