Skip to content

Commit

Permalink
Merge branch 'cbw-1250and1251/contract-details' into cbw-1250/contrac…
Browse files Browse the repository at this point in the history
…t-invoked-event
  • Loading branch information
schwartz-concordium committed Sep 14, 2023
2 parents 6428b77 + a18b5c4 commit 8bc2925
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ public void Configure(EntityTypeBuilder<ContractRejectEvent> builder)
builder.Property(x => x.CreatedAt)
.HasColumnName("created_at");
}
}
}
9 changes: 5 additions & 4 deletions backend/Application/Aggregates/Contract/ContractAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ private static async Task<uint> StorePossibleRejectEvent(
BlockItemSummary blockItemSummary
)
{
if (details.Effects is not None none || !IsRelevantReject(none.RejectReason, out var rejectReason))
if (details.Effects is not None none || !TryGetRelevantReject(none.RejectReason, out var rejectReason))
{
return 0;
}
Expand All @@ -417,9 +417,10 @@ await StoreReject(
}

/// <summary>
/// Map relevant rejected reasons to <see cref="TransactionRejectReason"/>.
/// Map relevant rejected reasons to <see cref="TransactionRejectReason"/>. Returns `false` if the rejected
/// event wasn't relevant for the aggregate.
/// </summary>
private static bool IsRelevantReject(IRejectReason rejectReason, out TransactionRejectReason? rejected)
private static bool TryGetRelevantReject(IRejectReason rejectReason, out TransactionRejectReason? rejected)
{
rejected = null;
switch (rejectReason)
Expand All @@ -434,7 +435,7 @@ private static bool IsRelevantReject(IRejectReason rejectReason, out Transaction
rejected = new ModuleHashAlreadyExists(x.ModuleReference.ToString());
return true;
case Concordium.Sdk.Types.RejectedReceive x:
rejected =new RejectedReceive(x.RejectReason,
rejected = new RejectedReceive(x.RejectReason,
ContractAddress.From(x.ContractAddress), x.ReceiveName.Receive, x.Parameter.ToHexString());
return true;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class ContractQuery
/// </remarks>
[UsePaging]
public IQueryable<Contract> GetContracts(
GraphQlDbContext context)
GraphQlDbContext context)
{
return context.Contract
.AsNoTracking()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ public async Task StartImport(CancellationToken token)

try
{
var from = 0;
var fromBatch = 0;
while (!token.IsCancellationRequested)
{
var finalHeight = await GetFinalHeight(token);

if (finalHeight < from * _jobOptions.BatchSize)
if (finalHeight < fromBatch * _jobOptions.BatchSize)
{
break;
}

var sequenceTo = (int)(finalHeight / _jobOptions.BatchSize);

var cycle = Parallel.ForEachAsync(
Enumerable.Range(from, sequenceTo),
Enumerable.Range(fromBatch, sequenceTo),
new ParallelOptions
{
MaxDegreeOfParallelism = _jobOptions.MaxParallelTasks
Expand All @@ -71,7 +71,7 @@ public async Task StartImport(CancellationToken token)
cts.Cancel();
await metricUpdater;

from = sequenceTo + 1;
fromBatch = sequenceTo + 1;
}

_logger.Information($"Done with job {nameof(ContractDatabaseImportJob)}");
Expand Down Expand Up @@ -133,7 +133,10 @@ private async ValueTask RunBatch(long height, CancellationToken token)
var blockHeightFrom = Math.Max((height - 1) * _jobOptions.BatchSize + 1, 0);
var affectedRows = await DatabaseBatchImportJob((ulong)blockHeightFrom, (ulong)blockHeightTo, token);

if (affectedRows == 0) return;
if (affectedRows == 0)
{
return;
};
_logger.Information("Written heights {From} to {To}", blockHeightFrom, blockHeightTo);
}

Expand Down

0 comments on commit 8bc2925

Please sign in to comment.