Skip to content

Commit

Permalink
Fix account pre-caching for rights in proto1, close #41
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed Apr 13, 2021
1 parent 9a1ab7f commit d53ce31
Showing 1 changed file with 8 additions and 7 deletions.
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
Expand Down Expand Up @@ -172,13 +173,13 @@ public virtual async Task Apply(Block block)
FutureBakingRights = (await Proto.Rpc.GetBakingRightsAsync(block.Level, futureCycle)).EnumerateArray();
FutureEndorsingRights = (await Proto.Rpc.GetEndorsingRightsAsync(block.Level, futureCycle)).EnumerateArray();

//foreach (var er in FutureEndorsingRights)
// if (!await Cache.Accounts.ExistsAsync(er.RequiredString("delegate")))
// throw new Exception($"Account {er.RequiredString("delegate")} doesn't exist");
foreach (var er in FutureEndorsingRights)
if (!await Cache.Accounts.ExistsAsync(er.RequiredString("delegate")))
throw new Exception($"Account {er.RequiredString("delegate")} doesn't exist");

//foreach (var br in FutureBakingRights)
// if (!await Cache.Accounts.ExistsAsync(br.RequiredString("delegate")))
// throw new Exception($"Account {br.RequiredString("delegate")} doesn't exist");
foreach (var br in FutureBakingRights)
if (!await Cache.Accounts.ExistsAsync(br.RequiredString("delegate")))
throw new Exception($"Account {br.RequiredString("delegate")} doesn't exist");

var conn = Db.Database.GetDbConnection() as NpgsqlConnection;
using var writer = conn.BeginBinaryImport(@"COPY ""BakingRights"" (""Cycle"", ""Level"", ""BakerId"", ""Type"", ""Status"", ""Priority"", ""Slots"") FROM STDIN (FORMAT BINARY)");
Expand Down

0 comments on commit d53ce31

Please sign in to comment.